Class LegacyBehavior


  • public class LegacyBehavior
    extends java.lang.Object
    This class encapsulates legacy runtime behavior for the process engine.

    Since 7.3 the behavior of certain bpmn elements has changed slightly.

    1. Some elements which did not used to be scopes are now scopes:

    • Sequential multi instance Embedded Subprocess: is now a scope, used to be non-scope.
    • Event subprocess: is now a scope, used to be non-scope.
    2. In certain situations, executions which were both scope and concurrent were created. This used to be the case if a scope execution already had a single scope child execution and then concurrency was introduced (by a on interrupting boundary event or a non-interrupting event subprocess). In that case the existing scope execution was made concurrent. Starting from 7.3 this behavior is considered legacy. The new behavior is that the existing scope execution will not be made concurrent, instead, a new, concurrent execution will be created and be interleaved between the parent and the existing scope execution.

    Since:
    7.3
    Author:
    Daniel Meyer
    • Constructor Detail

      • LegacyBehavior

        public LegacyBehavior()
    • Method Detail

      • pruneConcurrentScope

        public static void pruneConcurrentScope​(PvmExecutionImpl execution)
        Prunes a concurrent scope. This can only happen if (a) the process instance has been migrated from a previous version to a new version of the process engine This is an inverse operation to #createConcurrentScope(PvmExecutionImpl). See: javadoc of this class for note about concurrent scopes.
        Parameters:
        execution -
      • cancelConcurrentScope

        public static void cancelConcurrentScope​(PvmExecutionImpl execution,
                                                 PvmActivity cancelledScopeActivity)
        Cancels an execution which is both concurrent and scope. This can only happen if (a) the process instance has been migrated from a previous version to a new version of the process engine See: javadoc of this class for note about concurrent scopes.
        Parameters:
        execution - the concurrent scope execution to destroy
        cancelledScopeActivity - the activity that cancels the execution; it must hold that cancellingActivity's event scope is the scope the execution is responsible for
      • destroyConcurrentScope

        public static void destroyConcurrentScope​(PvmExecutionImpl execution)
        Destroys a concurrent scope Execution. This can only happen if (a) the process instance has been migrated from a previous version to a 7.3+ version of the process engine See: javadoc of this class for note about concurrent scopes.
        Parameters:
        execution - the execution to destroy
      • eventSubprocessComplete

        public static boolean eventSubprocessComplete​(ActivityExecution scopeExecution)
      • eventSubprocessConcurrentChildExecutionEnded

        public static boolean eventSubprocessConcurrentChildExecutionEnded​(ActivityExecution scopeExecution,
                                                                           ActivityExecution endedExecution)
      • destroySecondNonScope

        public static boolean destroySecondNonScope​(PvmExecutionImpl execution)
        Destroy an execution for an activity that was previously not a scope and now is (e.g. event subprocess)
      • isLegacyBehaviorRequired

        protected static boolean isLegacyBehaviorRequired​(ActivityExecution scopeExecution)
        This method
        Parameters:
        scopeExecution -
        Returns:
      • getScopeExecution

        public static PvmExecutionImpl getScopeExecution​(ScopeImpl scope,
                                                         java.util.Map<ScopeImpl,​PvmExecutionImpl> activityExecutionMapping)
        In case the process instance was migrated from a previous version, activities which are now parsed as scopes do not have scope executions. Use the flow scopes of these activities in order to find their execution. - For an event subprocess this is the scope execution of the scope in which the event subprocess is embeded in - For a multi instance sequential subprocess this is the multi instace scope body.
        Parameters:
        scope -
        activityExecutionMapping -
        Returns:
      • ensureConcurrentScope

        protected static void ensureConcurrentScope​(PvmExecutionImpl execution)
      • ensureConcurrent

        protected static void ensureConcurrent​(PvmExecutionImpl execution)
      • ensureScope

        protected static void ensureScope​(PvmExecutionImpl execution)
      • createActivityExecutionMapping

        public static java.util.Map<ScopeImpl,​PvmExecutionImpl> createActivityExecutionMapping​(java.util.List<PvmExecutionImpl> scopeExecutions,
                                                                                                     java.util.List<ScopeImpl> scopes)
        Creates an activity execution mapping, when the scope hierarchy and the execution hierarchy are out of sync.
        Parameters:
        scopeExecutions -
        scopes -
        Returns:
      • wasNoScope

        protected static boolean wasNoScope​(ActivityImpl activity,
                                            PvmExecutionImpl scopeExecutionCandidate)
        Determines whether the given scope was a scope in previous versions
      • wasNoScope72

        protected static boolean wasNoScope72​(ActivityImpl activity)
      • isMultiInstanceInCompensation

        protected static boolean isMultiInstanceInCompensation​(ActivityImpl activity,
                                                               PvmExecutionImpl scopeExecutionCandidate)
      • isLegacyAsyncAtMultiInstance

        protected static boolean isLegacyAsyncAtMultiInstance​(PvmExecutionImpl execution)
        This returns true only if the provided execution has reached its wait state in a legacy engine version, because only in that case, it can be async and waiting at the inner activity wrapped by the miBody. In versions >= 7.3, the execution would reference the multi-instance body instead.
      • determinePropagatingExecutionOnEnd

        public static PvmExecutionImpl determinePropagatingExecutionOnEnd​(PvmExecutionImpl propagatingExecution,
                                                                          java.util.Map<ScopeImpl,​PvmExecutionImpl> activityExecutionMapping)
        Tolerates the broken execution trees fixed with CAM-3727 where there may be more ancestor scope executions than ancestor flow scopes; In that case, the argument execution is removed, the parent execution of the argument is returned such that one level of mismatch is corrected. Note that this does not necessarily skip the correct scope execution, since the broken parent-child relationships may be anywhere in the tree (e.g. consider a non-interrupting boundary event followed by a subprocess (i.e. scope), when the subprocess ends, we would skip the subprocess's execution).
      • isConcurrentScope

        public static boolean isConcurrentScope​(PvmExecutionImpl propagatingExecution)
        Concurrent + scope executions are legacy and could occur in processes with non-interrupting boundary events or event subprocesses
      • removeLegacySubscriptionOnParent

        public static void removeLegacySubscriptionOnParent​(ExecutionEntity execution,
                                                            EventSubscriptionEntity eventSubscription)

        Required for migrating active sequential MI receive tasks. These activities were formerly not scope, but are now. This has the following implications:

        Before migration:

        • the event subscription is attached to the miBody scope execution

        After migration:

        • a new subscription is created for every instance
        • the new subscription is attached to a dedicated scope execution as a child of the miBody scope execution

        Thus, this method removes the subscription on the miBody scope

      • areEqualEventSubscriptions

        protected static boolean areEqualEventSubscriptions​(EventSubscriptionEntity subscription1,
                                                            EventSubscriptionEntity subscription2)
        Checks if the parameters are the same apart from the execution id
      • valuesEqual

        protected static <T> boolean valuesEqual​(T value1,
                                                 T value2)
      • removeLegacyNonScopesFromMapping

        public static void removeLegacyNonScopesFromMapping​(java.util.Map<ScopeImpl,​PvmExecutionImpl> mapping)
        Remove all entries for legacy non-scopes given that the assigned scope execution is also responsible for another scope
      • getTopMostScope

        protected static ScopeImpl getTopMostScope​(java.util.List<ScopeImpl> scopes)
      • repairParentRelationships

        public static void repairParentRelationships​(java.util.Collection<ActivityInstanceImpl> values,
                                                     java.lang.String processInstanceId)
        This is relevant for GetActivityInstanceCmd where in case of legacy multi-instance execution trees, the default algorithm omits multi-instance activity instances.
      • migrateMultiInstanceJobDefinitions

        public static void migrateMultiInstanceJobDefinitions​(ProcessDefinitionEntity processDefinition,
                                                              java.util.List<JobDefinitionEntity> jobDefinitions)
        When deploying an async job definition for an activity wrapped in an miBody, set the activity id to the miBody except the wrapped activity is marked as async. Background: in <= 7.2 async job definitions were created for the inner activity, although the semantics are that they are executed before the miBody is entered
      • isAsync

        protected static boolean isAsync​(ActivityImpl activity)
      • isAsyncJobDefinition

        protected static boolean isAsyncJobDefinition​(JobDefinitionEntity jobDefinition)
      • isActivityWrappedInMultiInstanceBody

        protected static boolean isActivityWrappedInMultiInstanceBody​(ActivityImpl activity)
      • repairMultiInstanceAsyncJob

        public static void repairMultiInstanceAsyncJob​(ExecutionEntity execution)
        When executing an async job for an activity wrapped in an miBody, set the execution to the miBody except the wrapped activity is marked as async. Background: in <= 7.2 async jobs were created for the inner activity, although the semantics are that they are executed before the miBody is entered
      • signalCancelBoundaryEvent

        public static boolean signalCancelBoundaryEvent​(java.lang.String signalName)
        With prior versions, the boundary event was already executed when compensation was performed; Thus, after compensation completes, the execution is signalled waiting at the boundary event.
      • hasInvalidIntermediaryActivityId

        public static boolean hasInvalidIntermediaryActivityId​(PvmExecutionImpl execution)

        In general, only leaf executions have activity ids.

        Exception to that rule: compensation throwing executions.

        Legacy exception (<= 7.2) to that rule: miBody executions and parallel gateway executions

        Returns:
        true, if the argument is not a leaf and has an invalid (i.e. legacy) non-null activity id
      • isCompensationThrowing

        public static boolean isCompensationThrowing​(PvmExecutionImpl execution,
                                                     java.util.Map<ScopeImpl,​PvmExecutionImpl> activityExecutionMapping)
        Returns true if the given execution is in a compensation-throwing activity but there is no dedicated scope execution in the given mapping.
      • isCompensationThrowing

        public static boolean isCompensationThrowing​(PvmExecutionImpl execution)
      • createMissingHistoricVariables

        public static void createMissingHistoricVariables​(PvmExecutionImpl execution)
        See #CAM-10978 Use case process instance with asyncBefore startEvent After unifying the history variable's creation
        The following changed:
        * variables will receive the processInstanceId as activityInstanceId in such cases (previously was the startEvent id)
        * historic details have new initial property to track initial variables that process is started with
        The jobs created prior 7.13 and not executed before do not have historic information of variables. This method takes care of that.