implemented message on transaction creation/update
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.constants.Field;
|
||||
import de.srsoftware.umbrella.core.constants.Module;
|
||||
import de.srsoftware.umbrella.core.constants.Text;
|
||||
import de.srsoftware.umbrella.core.model.Transaction;
|
||||
@@ -10,9 +11,11 @@ import de.srsoftware.umbrella.core.model.UnTranslatable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.accountingService;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
import static java.text.MessageFormat.format;
|
||||
|
||||
public class TransactionEvent extends Event<Transaction> {
|
||||
private Collection<UmbrellaUser> audience;
|
||||
@@ -22,6 +25,11 @@ public class TransactionEvent extends Event<Transaction> {
|
||||
audience = null;
|
||||
}
|
||||
|
||||
public TransactionEvent(UmbrellaUser initiator, Transaction transaction, Map<String, Object> oldData){
|
||||
super(initiator,Module.ACCOUNTING,transaction,oldData);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<UmbrellaUser> audience() {
|
||||
if (audience == null) audience = accountingService().loadAccount(payload().accountId()).userMap().values();
|
||||
@@ -30,14 +38,17 @@ public class TransactionEvent extends Event<Transaction> {
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return new UnTranslatable(payload().purpose());
|
||||
return switch (eventType()){
|
||||
case UPDATE -> new UnTranslatable(diff().orElse(""));
|
||||
case null, default -> new UnTranslatable(payload().toString());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable subject() {
|
||||
return switch (eventType()){
|
||||
case CREATE -> t("user_created_entity",initiator().name(), Text.TRANSACTION);
|
||||
case UPDATE -> t("user_updated_entity",initiator().name(), Text.TRANSACTION);
|
||||
case CREATE -> t("user_created_entity", Field.USER,initiator().name(), Field.ENTITY, t(Text.TRANSACTION));
|
||||
case UPDATE -> t("user_updated_entity", Field.USER,initiator().name(), Field.ENTITY, t(Text.TRANSACTION));
|
||||
case null, default -> t("TODO"); // TODO
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user