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 ) ; }
Collect all compensate event subscriptions for scope of given execution .