Search in sources :

Example 1 with StateTransition

use of org.estatio.module.capex.dom.state.StateTransition in project estatio by estatio.

the class EnforceTaskAssignmentPolicySubscriber method on.

@EventHandler
@Subscribe
public void on(Task_mixinActAbstract.ActionDomainEvent ev) {
    if (ev.getSemantics().isSafeInNature()) {
        return;
    }
    final Class stateTransitionClass = ev.getStateTransitionClass();
    final Task task = (Task) ev.getMixedIn();
    final StateTransition transition = stateTransitionService.findFor(task);
    if (transition == null) {
        // shouldn't occur
        return;
    }
    final Class taskTransitionClass = stateTransitionService.transitionClassFor(transition.getTransitionType());
    if (stateTransitionClass != taskTransitionClass) {
        // or, maybe should hide (and then we can delete code in the subtypes of the mixinAbstract
        return;
    }
    final Object domainObject = transition.getDomainObject();
    applyPolicy(stateTransitionClass, domainObject, ev);
}
Also used : Task(org.estatio.module.capex.dom.task.Task) StateTransition(org.estatio.module.capex.dom.state.StateTransition) EventHandler(org.axonframework.eventhandling.annotation.EventHandler) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)1 EventHandler (org.axonframework.eventhandling.annotation.EventHandler)1 StateTransition (org.estatio.module.capex.dom.state.StateTransition)1 Task (org.estatio.module.capex.dom.task.Task)1