Search in sources :

Example 11 with PvmActivity

use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.

the class AbstractPvmAtomicOperationTransitionNotifyListenerTake method eventNotificationsCompleted.

protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    PvmActivity destination = execution.getTransition().getDestination();
    // check start behavior of next activity
    switch(destination.getActivityStartBehavior()) {
        case DEFAULT:
            execution.setActivity(destination);
            execution.dispatchDelayedEventsAndPerformOperation(TRANSITION_CREATE_SCOPE);
            break;
        case INTERRUPT_FLOW_SCOPE:
            execution.setActivity(null);
            execution.performOperation(TRANSITION_INTERRUPT_FLOW_SCOPE);
            break;
        default:
            throw new ProcessEngineException("Unsupported start behavior for activity '" + destination + "' started from a sequence flow: " + destination.getActivityStartBehavior());
    }
}
Also used : PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 12 with PvmActivity

use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationActivityEnd method execute.

public void execute(PvmExecutionImpl execution) {
    // restore activity instance id
    if (execution.getActivityInstanceId() == null) {
        execution.setActivityInstanceId(execution.getParentActivityInstanceId());
    }
    PvmActivity activity = execution.getActivity();
    Map<ScopeImpl, PvmExecutionImpl> activityExecutionMapping = execution.createActivityExecutionMapping();
    PvmExecutionImpl propagatingExecution = execution;
    if (execution.isScope() && activity.isScope()) {
        if (!LegacyBehavior.destroySecondNonScope(execution)) {
            execution.destroy();
            if (!execution.isConcurrent()) {
                execution.remove();
                propagatingExecution = execution.getParent();
                propagatingExecution.setActivity(execution.getActivity());
            }
        }
    }
    propagatingExecution = LegacyBehavior.determinePropagatingExecutionOnEnd(propagatingExecution, activityExecutionMapping);
    PvmScope flowScope = activity.getFlowScope();
    // 1. flow scope = Process Definition
    if (flowScope == activity.getProcessDefinition()) {
        // 1.1 concurrent execution => end + tryPrune()
        if (propagatingExecution.isConcurrent()) {
            propagatingExecution.remove();
            propagatingExecution.getParent().tryPruneLastConcurrentChild();
            propagatingExecution.getParent().forceUpdate();
        } else {
            // 1.2 Process End
            propagatingExecution.setEnded(true);
            if (!propagatingExecution.isPreserveScope()) {
                propagatingExecution.performOperation(PROCESS_END);
            }
        }
    } else {
        // 2. flowScope != process definition
        PvmActivity flowScopeActivity = (PvmActivity) flowScope;
        ActivityBehavior activityBehavior = flowScopeActivity.getActivityBehavior();
        if (activityBehavior instanceof CompositeActivityBehavior) {
            CompositeActivityBehavior compositeActivityBehavior = (CompositeActivityBehavior) activityBehavior;
            // 2.1 Concurrent execution => composite behavior.concurrentExecutionEnded()
            if (propagatingExecution.isConcurrent() && !LegacyBehavior.isConcurrentScope(propagatingExecution)) {
                compositeActivityBehavior.concurrentChildExecutionEnded(propagatingExecution.getParent(), propagatingExecution);
            } else {
                // 2.2 Scope Execution => composite behavior.complete()
                propagatingExecution.setActivity(flowScopeActivity);
                compositeActivityBehavior.complete(propagatingExecution);
            }
        } else {
            // activity behavior is not composite => this is unexpected
            throw new ProcessEngineException("Expected behavior of composite scope " + activity + " to be a CompositeActivityBehavior but got " + activityBehavior);
        }
    }
}
Also used : PvmScope(org.camunda.bpm.engine.impl.pvm.PvmScope) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) CompositeActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior) CompositeActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 13 with PvmActivity

use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationActivityInstanceStart method eventNotificationsCompleted.

protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    // hack around execution tree structure not being in sync with activity instance concept:
    // if we start a scope activity, remember current activity instance in parent
    PvmExecutionImpl parent = execution.getParent();
    PvmActivity activity = execution.getActivity();
    if (parent != null && execution.isScope() && activity.isScope() && canHaveChildScopes(execution)) {
        parent.setActivityInstanceId(execution.getActivityInstanceId());
    }
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 14 with PvmActivity

use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationCancelActivity method execute.

public void execute(PvmExecutionImpl execution) {
    // Assumption: execution is scope
    PvmActivity cancellingActivity = execution.getNextActivity();
    execution.setNextActivity(null);
    // first, cancel and destroy the current scope
    execution.setActive(true);
    PvmExecutionImpl propagatingExecution = null;
    if (LegacyBehavior.isConcurrentScope(execution)) {
        // this is legacy behavior
        LegacyBehavior.cancelConcurrentScope(execution, (PvmActivity) cancellingActivity.getEventScope());
        propagatingExecution = execution;
    } else {
        // Unlike PvmAtomicOperationTransitionDestroyScope this needs to use delete() (instead of destroy() and remove()).
        // The reason is that PvmAtomicOperationTransitionDestroyScope is executed when a scope (or non scope) is left using
        // a sequence flow. In that case the execution will have completed all the work inside the current activity
        // and will have no more child executions. In PvmAtomicOperationCancelScope the scope is cancelled due to
        // a boundary event firing. In that case the execution has not completed all the work in the current scope / activity
        // and it is necessary to delete the complete hierarchy of executions below and including the execution itself.
        execution.deleteCascade("Cancel scope activity " + cancellingActivity + " executed.");
        propagatingExecution = execution.getParent();
    }
    propagatingExecution.setActivity(cancellingActivity);
    propagatingExecution.setActive(true);
    propagatingExecution.setEnded(false);
    activityCancelled(propagatingExecution);
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 15 with PvmActivity

use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationCreateScope method execute.

public void execute(PvmExecutionImpl execution) {
    // reset activity instance id before creating the scope
    execution.setActivityInstanceId(execution.getParentActivityInstanceId());
    PvmExecutionImpl propagatingExecution = null;
    PvmActivity activity = execution.getActivity();
    if (activity.isScope()) {
        propagatingExecution = execution.createExecution();
        propagatingExecution.setActivity(activity);
        propagatingExecution.setTransition(execution.getTransition());
        execution.setTransition(null);
        execution.setActive(false);
        execution.setActivity(null);
        LOG.createScope(execution, propagatingExecution);
        propagatingExecution.initialize();
    } else {
        propagatingExecution = execution;
    }
    scopeCreated(propagatingExecution);
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Aggregations

PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)39 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)13 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)7 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)6 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)6 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)4 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)4 ReferenceWalker (org.camunda.bpm.engine.impl.tree.ReferenceWalker)4 ArrayList (java.util.ArrayList)3 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)3 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)3 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)3 List (java.util.List)2 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)2 ExecutionStartContext (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)2 ActivityExecutionHierarchyWalker (org.camunda.bpm.engine.impl.tree.ActivityExecutionHierarchyWalker)2 ActivityExecutionMappingCollector (org.camunda.bpm.engine.impl.tree.ActivityExecutionMappingCollector)2 ActivityExecutionTuple (org.camunda.bpm.engine.impl.tree.ActivityExecutionTuple)2