use of org.camunda.bpm.engine.impl.tree.TreeVisitor in project camunda-bpm-platform by camunda.
the class CompensationUtil method collectCompensateEventSubscriptionsForScope.
/**
* Collect all compensate event subscriptions for scope of given execution.
*/
public static List<EventSubscriptionEntity> collectCompensateEventSubscriptionsForScope(ActivityExecution execution) {
final Map<ScopeImpl, PvmExecutionImpl> scopeExecutionMapping = execution.createActivityExecutionMapping();
ScopeImpl activity = (ScopeImpl) execution.getActivity();
// <LEGACY>: different flow scopes may have the same scope execution =>
// collect subscriptions in a set
final Set<EventSubscriptionEntity> subscriptions = new HashSet<EventSubscriptionEntity>();
TreeVisitor<ScopeImpl> eventSubscriptionCollector = new TreeVisitor<ScopeImpl>() {
@Override
public void visit(ScopeImpl obj) {
PvmExecutionImpl execution = scopeExecutionMapping.get(obj);
subscriptions.addAll(((ExecutionEntity) execution).getCompensateEventSubscriptions());
}
};
new FlowScopeWalker(activity).addPostVisitor(eventSubscriptionCollector).walkUntil(new ReferenceWalker.WalkCondition<ScopeImpl>() {
@Override
public boolean isFulfilled(ScopeImpl element) {
Boolean consumesCompensationProperty = (Boolean) element.getProperty(BpmnParse.PROPERTYNAME_CONSUMES_COMPENSATION);
return consumesCompensationProperty == null || consumesCompensationProperty == Boolean.TRUE;
}
});
return new ArrayList<EventSubscriptionEntity>(subscriptions);
}
use of org.camunda.bpm.engine.impl.tree.TreeVisitor in project camunda-bpm-platform by camunda.
the class ExecutionEntity method dispatchEvent.
@Override
public void dispatchEvent(VariableEvent variableEvent) {
final List<ExecutionEntity> execs = new ArrayList<ExecutionEntity>();
new ExecutionTopDownWalker(this).addPreVisitor(new TreeVisitor<ExecutionEntity>() {
@Override
public void visit(ExecutionEntity obj) {
if (!obj.getEventSubscriptions().isEmpty() && (obj.isInState(ActivityInstanceState.DEFAULT) || (!obj.getActivity().isScope()))) {
// state is default or tree is compacted
execs.add(obj);
}
}
}).walkUntil();
for (ExecutionEntity execution : execs) {
execution.handleConditionalEventOnVariableChange(variableEvent);
}
}
Aggregations