use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class CancelEndEventActivityBehavior method doLeave.
public void doLeave(ActivityExecution execution) {
// continue via the appropriate cancel boundary event
ScopeImpl eventScope = (ScopeImpl) cancelBoundaryEvent.getEventScope();
ActivityExecution boundaryEventScopeExecution = execution.findExecutionForFlowScope(eventScope);
boundaryEventScopeExecution.executeActivity(cancelBoundaryEvent);
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class InclusiveGatewayActivityBehavior method isReachable.
protected boolean isReachable(PvmActivity srcActivity, PvmActivity targetActivity, Set<PvmActivity> visitedActivities) {
if (srcActivity.equals(targetActivity)) {
return true;
}
// To avoid infinite looping, we must capture every node we visit and
// check before going further in the graph if we have already visited the node.
visitedActivities.add(srcActivity);
List<PvmTransition> outgoingTransitions = srcActivity.getOutgoingTransitions();
if (outgoingTransitions.isEmpty()) {
ScopeImpl flowScope = srcActivity.getFlowScope();
if (flowScope == null || !(flowScope instanceof PvmActivity)) {
return false;
}
return isReachable((PvmActivity) flowScope, targetActivity, visitedActivities);
} else {
for (PvmTransition pvmTransition : outgoingTransitions) {
PvmActivity destinationActivity = pvmTransition.getDestination();
if (destinationActivity != null && !visitedActivities.contains(destinationActivity)) {
boolean reachable = isReachable(destinationActivity, targetActivity, visitedActivities);
// If false, we should investigate other paths, and not yet return the result
if (reachable) {
return true;
}
}
}
}
return false;
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class ExecutionEntity method initialize.
// scopes ///////////////////////////////////////////////////////////////////
@Override
@SuppressWarnings("unchecked")
public void initialize() {
LOG.initializeExecution(this);
ScopeImpl scope = getScopeActivity();
ensureParentInitialized();
List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS);
if (variableDeclarations != null) {
for (VariableDeclaration variableDeclaration : variableDeclarations) {
variableDeclaration.initialize(this, parent);
}
}
if (isProcessInstanceExecution()) {
String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
if (initiatorVariableName != null) {
String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId();
setVariable(initiatorVariableName, authenticatedUserId);
}
}
// create event subscriptions for the current scope
for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) {
if (!declaration.isStartEvent()) {
declaration.createSubscriptionForExecution(this);
}
}
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl in project camunda-bpm-platform by camunda.
the class GatewayMappingValidator method validateParentScopeMigrates.
protected void validateParentScopeMigrates(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions, MigrationInstructionValidationReportImpl report) {
ActivityImpl sourceActivity = instruction.getSourceActivity();
ScopeImpl flowScope = sourceActivity.getFlowScope();
if (flowScope != flowScope.getProcessDefinition()) {
if (instructions.getInstructionsBySourceScope(flowScope).isEmpty()) {
report.addFailure("The gateway's flow scope '" + flowScope.getId() + "' must be mapped");
}
}
}
use of org.camunda.bpm.engine.impl.pvm.process.ScopeImpl 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);
}
}
}
Aggregations