Search in sources :

Example 1 with ActivityExecution

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

Example 2 with ActivityExecution

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

Example 3 with ActivityExecution

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

Example 4 with ActivityExecution

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);
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ArrayList(java.util.ArrayList) ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)

Example 5 with ActivityExecution

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

Aggregations

ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)21 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)6 ArrayList (java.util.ArrayList)5 PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)5 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)4 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)3 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)2 BpmnError (org.camunda.bpm.engine.delegate.BpmnError)1 Condition (org.camunda.bpm.engine.impl.Condition)1 ExternalTaskActivityBehavior (org.camunda.bpm.engine.impl.bpmn.behavior.ExternalTaskActivityBehavior)1 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)1 PvmScope (org.camunda.bpm.engine.impl.pvm.PvmScope)1 ModificationObserverBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)1 ExecutionStartContext (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)1 InstantiationStack (org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack)1