Search in sources :

Example 6 with ScopeImpl

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);
}
Also used : ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 7 with ScopeImpl

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;
}
Also used : ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 8 with ScopeImpl

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);
        }
    }
}
Also used : VariableDeclaration(org.camunda.bpm.engine.impl.variable.VariableDeclaration) List(java.util.List) ArrayList(java.util.ArrayList) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl) EventSubscriptionDeclaration(org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Example 9 with ScopeImpl

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");
        }
    }
}
Also used : ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) ScopeImpl(org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)

Example 10 with ScopeImpl

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

Aggregations

ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)37 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)10 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)10 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)6 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)6 FlowScopeWalker (org.camunda.bpm.engine.impl.tree.FlowScopeWalker)5 HashMap (java.util.HashMap)4 List (java.util.List)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 ReferenceWalker (org.camunda.bpm.engine.impl.tree.ReferenceWalker)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)3 Deployment (org.camunda.bpm.engine.test.Deployment)3 MigratingActivityInstance (org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance)2 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)2 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)2 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)2 CompositeActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior)2