use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.
the class PvmAtomicOperationDeleteCascadeFireActivityEnd method eventNotificationsCompleted.
@Override
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
PvmActivity activity = execution.getActivity();
if (execution.isScope() && (executesNonScopeActivity(execution) || isAsyncBeforeActivity(execution)) && !CompensationBehavior.executesNonScopeCompensationHandler(execution)) {
execution.removeAllTasks();
// case this is a scope execution and the activity is not a scope
execution.leaveActivityInstance();
execution.setActivity(getFlowScopeActivity(activity));
execution.performOperation(DELETE_CASCADE_FIRE_ACTIVITY_END);
} else {
if (execution.isScope()) {
execution.destroy();
}
// remove this execution and its concurrent parent (if exists)
execution.remove();
boolean continueRemoval = !execution.isDeleteRoot();
if (continueRemoval) {
PvmExecutionImpl propagatingExecution = execution.getParent();
if (propagatingExecution != null && !propagatingExecution.isScope() && !propagatingExecution.hasChildren()) {
propagatingExecution.remove();
continueRemoval = !propagatingExecution.isDeleteRoot();
propagatingExecution = propagatingExecution.getParent();
}
if (continueRemoval) {
if (propagatingExecution != null) {
// set activity on parent in case the parent is an inactive scope execution and activity has been set to 'null'.
if (propagatingExecution.getActivity() == null && activity != null && activity.getFlowScope() != null) {
propagatingExecution.setActivity(getFlowScopeActivity(activity));
}
}
}
}
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.
the class PvmAtomicOperationProcessEnd method eventNotificationsCompleted.
@Override
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
execution.leaveActivityInstance();
PvmExecutionImpl superExecution = execution.getSuperExecution();
CmmnActivityExecution superCaseExecution = execution.getSuperCaseExecution();
SubProcessActivityBehavior subProcessActivityBehavior = null;
TransferVariablesActivityBehavior transferVariablesBehavior = null;
// copy variables before destroying the ended sub process instance
if (superExecution != null) {
PvmActivity activity = superExecution.getActivity();
subProcessActivityBehavior = (SubProcessActivityBehavior) activity.getActivityBehavior();
try {
subProcessActivityBehavior.passOutputVariables(superExecution, execution);
} catch (RuntimeException e) {
LOG.exceptionWhileCompletingSupProcess(execution, e);
throw e;
} catch (Exception e) {
LOG.exceptionWhileCompletingSupProcess(execution, e);
throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
}
} else if (superCaseExecution != null) {
CmmnActivity activity = superCaseExecution.getActivity();
transferVariablesBehavior = (TransferVariablesActivityBehavior) activity.getActivityBehavior();
try {
transferVariablesBehavior.transferVariables(execution, superCaseExecution);
} catch (RuntimeException e) {
LOG.exceptionWhileCompletingSupProcess(execution, e);
throw e;
} catch (Exception e) {
LOG.exceptionWhileCompletingSupProcess(execution, e);
throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
}
}
execution.destroy();
execution.remove();
// and trigger execution afterwards
if (superExecution != null) {
superExecution.setSubProcessInstance(null);
try {
subProcessActivityBehavior.completed(superExecution);
} catch (RuntimeException e) {
LOG.exceptionWhileCompletingSupProcess(execution, e);
throw e;
} catch (Exception e) {
LOG.exceptionWhileCompletingSupProcess(execution, e);
throw new ProcessEngineException("Error while completing sub process of execution " + execution, e);
}
} else if (superCaseExecution != null) {
superCaseExecution.complete();
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.
the class PvmAtomicOperationTransitionDestroyScope method execute.
public void execute(PvmExecutionImpl execution) {
// calculate the propagating execution
PvmExecutionImpl propagatingExecution = execution;
PvmActivity activity = execution.getActivity();
List<PvmTransition> transitionsToTake = execution.getTransitionsToTake();
execution.setTransitionsToTake(null);
// check whether the current scope needs to be destroyed
if (execution.isScope() && activity.isScope()) {
if (!LegacyBehavior.destroySecondNonScope(execution)) {
if (execution.isConcurrent()) {
// legacy behavior
LegacyBehavior.destroyConcurrentScope(execution);
} else {
propagatingExecution = execution.getParent();
LOG.debugDestroyScope(execution, propagatingExecution);
execution.destroy();
propagatingExecution.setActivity(execution.getActivity());
propagatingExecution.setTransition(execution.getTransition());
propagatingExecution.setActive(true);
execution.remove();
}
}
} else {
// activity is not scope => nothing to do
propagatingExecution = execution;
}
// take the specified transitions
if (transitionsToTake.isEmpty()) {
throw new ProcessEngineException(execution.toString() + ": No outgoing transitions from " + "activity " + activity);
} else if (transitionsToTake.size() == 1) {
propagatingExecution.setTransition(transitionsToTake.get(0));
propagatingExecution.take();
} else {
propagatingExecution.inactivate();
List<OutgoingExecution> outgoingExecutions = new ArrayList<OutgoingExecution>();
for (int i = 0; i < transitionsToTake.size(); i++) {
PvmTransition transition = transitionsToTake.get(i);
PvmExecutionImpl scopeExecution = propagatingExecution.isScope() ? propagatingExecution : propagatingExecution.getParent();
// reuse concurrent, propagating execution for first transition
PvmExecutionImpl concurrentExecution = null;
if (i == 0) {
concurrentExecution = propagatingExecution;
} else {
concurrentExecution = scopeExecution.createConcurrentExecution();
if (i == 1 && !propagatingExecution.isConcurrent()) {
outgoingExecutions.remove(0);
// get a hold of the concurrent execution that replaced the scope propagating execution
PvmExecutionImpl replacingExecution = null;
for (PvmExecutionImpl concurrentChild : scopeExecution.getNonEventScopeExecutions()) {
if (!(concurrentChild == propagatingExecution)) {
replacingExecution = concurrentChild;
break;
}
}
outgoingExecutions.add(new OutgoingExecution(replacingExecution, transitionsToTake.get(0)));
}
}
outgoingExecutions.add(new OutgoingExecution(concurrentExecution, transition));
}
// start executions in reverse order (order will be reversed again in command context with the effect that they are
// actually be started in correct order :) )
Collections.reverse(outgoingExecutions);
for (OutgoingExecution outgoingExecution : outgoingExecutions) {
outgoingExecution.take();
}
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.
the class MigratingActivityInstanceVisitor method instantiateScopes.
protected void instantiateScopes(MigratingScopeInstance ancestorScopeInstance, MigratingScopeInstanceBranch executionBranch, List<ScopeImpl> scopesToInstantiate) {
if (scopesToInstantiate.isEmpty()) {
return;
}
// must always be an activity instance
MigratingActivityInstance ancestorActivityInstance = (MigratingActivityInstance) ancestorScopeInstance;
ExecutionEntity newParentExecution = ancestorActivityInstance.createAttachableExecution();
Map<PvmActivity, PvmExecutionImpl> createdExecutions = newParentExecution.instantiateScopes((List) scopesToInstantiate, skipCustomListeners, skipIoMappings);
for (ScopeImpl scope : scopesToInstantiate) {
ExecutionEntity createdExecution = (ExecutionEntity) createdExecutions.get(scope);
createdExecution.setActivity(null);
createdExecution.setActive(false);
executionBranch.visited(new MigratingActivityInstance(scope, createdExecution));
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmActivity in project camunda-bpm-platform by camunda.
the class ActivityBehaviorUtil method getActivityBehavior.
public static ActivityBehavior getActivityBehavior(PvmExecutionImpl execution) {
String id = execution.getId();
PvmActivity activity = execution.getActivity();
ensureNotNull(PvmException.class, "Execution '" + id + "' has no current activity.", "activity", activity);
ActivityBehavior behavior = activity.getActivityBehavior();
ensureNotNull(PvmException.class, "There is no behavior specified in " + activity + " for execution '" + id + "'.", "behavior", behavior);
return behavior;
}
Aggregations