implemented transaction propagation via event bus
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -65,7 +65,7 @@ public class MessageApi extends BaseHandler{
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEvent(PrintWriter out, Event event) {
|
||||
private void sendEvent(PrintWriter out, Event<?> event) {
|
||||
if (event == null) return;
|
||||
out.print("event: ");
|
||||
out.println(event.eventType());
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package de.srsoftware.umbrella.messagebus.events;
|
||||
|
||||
import de.srsoftware.umbrella.core.ModuleRegistry;
|
||||
import de.srsoftware.umbrella.core.constants.Module;
|
||||
import de.srsoftware.umbrella.core.constants.Text;
|
||||
import de.srsoftware.umbrella.core.model.Transaction;
|
||||
import de.srsoftware.umbrella.core.model.Translatable;
|
||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||
import de.srsoftware.umbrella.core.model.UnTranslatable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static de.srsoftware.umbrella.core.ModuleRegistry.accountingService;
|
||||
import static de.srsoftware.umbrella.core.model.Translatable.t;
|
||||
|
||||
public class TransactionEvent extends Event<Transaction> {
|
||||
private Collection<UmbrellaUser> audience;
|
||||
|
||||
public TransactionEvent(UmbrellaUser initiator, Transaction transaction, EventType type) {
|
||||
super(initiator, Module.ACCOUNTING, transaction, type);
|
||||
audience = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UmbrellaUser> audience() {
|
||||
if (audience == null) audience = accountingService().loadAccount(payload().accountId()).userMap().values();
|
||||
return audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Translatable describe() {
|
||||
return new UnTranslatable(payload().purpose());
|
||||
}
|
||||
|
||||
@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 null, default -> t("TODO"); // TODO
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user