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());
}
}
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);
}
}
}
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());
}
}
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);
}
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);
}
Aggregations