use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class ParallelMultiInstanceActivityBehavior method onParseMigratingInstance.
@Override
public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) {
ExecutionEntity scopeExecution = migratingInstance.resolveRepresentativeExecution();
List<ActivityExecution> concurrentInActiveExecutions = scopeExecution.findInactiveChildExecutions(getInnerActivity((ActivityImpl) migratingInstance.getSourceScope()));
// them from the parse context here to avoid a validation exception
for (ActivityExecution execution : concurrentInActiveExecutions) {
for (VariableInstanceEntity variable : ((ExecutionEntity) execution).getVariablesInternal()) {
parseContext.consume(variable);
}
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class ParallelMultiInstanceActivityBehavior method createInstances.
@Override
protected void createInstances(ActivityExecution execution, int nrOfInstances) throws Exception {
PvmActivity innerActivity = getInnerActivity(execution.getActivity());
// initialize the scope and create the desired number of child executions
prepareScopeExecution(execution, nrOfInstances);
List<ActivityExecution> concurrentExecutions = new ArrayList<ActivityExecution>();
for (int i = 0; i < nrOfInstances; i++) {
concurrentExecutions.add(createConcurrentExecution(execution));
}
// actually be started in correct order :) )
for (int i = (nrOfInstances - 1); i >= 0; i--) {
ActivityExecution activityExecution = concurrentExecutions.get(i);
performInstance(activityExecution, innerActivity, i);
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class ParallelMultiInstanceActivityBehavior method initializeScope.
@Override
public List<ActivityExecution> initializeScope(ActivityExecution scopeExecution, int numberOfInstances) {
prepareScopeExecution(scopeExecution, numberOfInstances);
List<ActivityExecution> executions = new ArrayList<ActivityExecution>();
for (int i = 0; i < numberOfInstances; i++) {
ActivityExecution concurrentChild = createConcurrentExecution(scopeExecution);
setLoopVariable(concurrentChild, LOOP_COUNTER, i);
executions.add(concurrentChild);
}
return executions;
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class ParallelMultiInstanceActivityBehavior method concurrentChildExecutionEnded.
@Override
public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) {
int nrOfCompletedInstances = getLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1;
setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances);
int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) - 1;
setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances);
// inactivate the concurrent execution
endedExecution.inactivate();
endedExecution.setActivityInstanceId(null);
// join
scopeExecution.forceUpdate();
// TODO: should the completion condition be evaluated on the scopeExecution or on the endedExecution?
if (completionConditionSatisfied(endedExecution) || allExecutionsEnded(scopeExecution, endedExecution)) {
ArrayList<ActivityExecution> childExecutions = new ArrayList<ActivityExecution>(((PvmExecutionImpl) scopeExecution).getNonEventScopeExecutions());
for (ActivityExecution childExecution : childExecutions) {
// delete all not-ended instances; these are either active (for non-scope tasks) or inactive but have no activity id (for subprocesses, etc.)
if (childExecution.isActive() || childExecution.getActivity() == null) {
((PvmExecutionImpl) childExecution).deleteCascade("Multi instance completion condition satisfied.");
} else {
childExecution.remove();
}
}
scopeExecution.setActivity((PvmActivity) endedExecution.getActivity().getFlowScope());
scopeExecution.setActive(true);
leave(scopeExecution);
} else {
((ExecutionEntity) scopeExecution).dispatchDelayedEventsAndPerformOperation((Callback<PvmExecutionImpl, Void>) null);
}
}
use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.
the class GatewayActivityBehavior method lockConcurrentRoot.
protected void lockConcurrentRoot(ActivityExecution execution) {
ActivityExecution concurrentRoot = null;
if (execution.isConcurrent()) {
concurrentRoot = execution.getParent();
} else {
concurrentRoot = execution;
}
((ExecutionEntity) concurrentRoot).forceUpdate();
}
Aggregations