Search in sources :

Example 16 with ActivityExecution

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.

the class EventScopeCreatingSubprocess method complete.

/*
   * Incoming execution is transformed into an event scope,
   * new, non-concurrent execution leaves activity
   */
public void complete(ActivityExecution execution) {
    ActivityExecution outgoingExecution = execution.getParent().createExecution();
    outgoingExecution.setConcurrent(false);
    outgoingExecution.setActivity(execution.getActivity());
    // eventscope execution
    execution.setConcurrent(false);
    execution.setActive(false);
    ((PvmExecutionImpl) execution).setEventScope(true);
    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    if (outgoingTransitions.isEmpty()) {
        outgoingExecution.end(true);
    } else {
        outgoingExecution.leaveActivityViaTransitions(outgoingTransitions, Collections.EMPTY_LIST);
    }
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 17 with ActivityExecution

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.

the class ParallelGateway method execute.

public void execute(ActivityExecution execution) {
    PvmActivity activity = execution.getActivity();
    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    execution.inactivate();
    List<ActivityExecution> joinedExecutions = execution.findInactiveConcurrentExecutions(activity);
    int nbrOfExecutionsToJoin = execution.getActivity().getIncomingTransitions().size();
    int nbrOfExecutionsJoined = joinedExecutions.size();
    if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin) {
        LOG.debug("parallel gateway '" + activity.getId() + "' activates: " + nbrOfExecutionsJoined + " of " + nbrOfExecutionsToJoin + " joined");
        execution.leaveActivityViaTransitions(outgoingTransitions, joinedExecutions);
    } else {
        LOG.debug("parallel gateway '" + activity.getId() + "' does not activate: " + nbrOfExecutionsJoined + " of " + nbrOfExecutionsToJoin + " joined");
    }
}
Also used : ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 18 with ActivityExecution

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.

the class PvmAtomicOperationActivityInitStackNotifyListenerStart method eventNotificationsCompleted.

protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
    super.eventNotificationsCompleted(execution);
    execution.activityInstanceStarted();
    ExecutionStartContext startContext = execution.getExecutionStartContext();
    InstantiationStack instantiationStack = startContext.getInstantiationStack();
    PvmExecutionImpl propagatingExecution = execution;
    ActivityImpl activity = execution.getActivity();
    if (activity.getActivityBehavior() instanceof ModificationObserverBehavior) {
        ModificationObserverBehavior behavior = (ModificationObserverBehavior) activity.getActivityBehavior();
        List<ActivityExecution> concurrentExecutions = behavior.initializeScope(propagatingExecution, 1);
        propagatingExecution = (PvmExecutionImpl) concurrentExecutions.get(0);
    }
    // if the stack has been instantiated
    if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetActivity() != null) {
        // as if we are entering the target activity instance id via a transition
        propagatingExecution.setActivityInstanceId(null);
        // execute the target activity with this execution
        startContext.applyVariables(propagatingExecution);
        propagatingExecution.setActivity(instantiationStack.getTargetActivity());
        propagatingExecution.performOperation(ACTIVITY_START_CREATE_SCOPE);
    } else if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetTransition() != null) {
        // as if we are entering the target activity instance id via a transition
        propagatingExecution.setActivityInstanceId(null);
        // execute the target transition with this execution
        PvmTransition transition = instantiationStack.getTargetTransition();
        startContext.applyVariables(propagatingExecution);
        propagatingExecution.setActivity(transition.getSource());
        propagatingExecution.setTransition((TransitionImpl) transition);
        propagatingExecution.performOperation(TRANSITION_START_NOTIFY_LISTENER_TAKE);
    } else {
        // else instantiate the activity stack further
        propagatingExecution.setActivity(null);
        propagatingExecution.performOperation(ACTIVITY_INIT_STACK);
    }
}
Also used : TransitionImpl(org.camunda.bpm.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) InstantiationStack(org.camunda.bpm.engine.impl.pvm.runtime.InstantiationStack) PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) ExecutionStartContext(org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext) ModificationObserverBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 19 with ActivityExecution

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.

the class AbstractBpmnActivityBehavior method createCompensateEventSubscription.

protected void createCompensateEventSubscription(ActivityExecution execution, ActivityImpl compensationHandler) {
    // the compensate event subscription is created at subprocess or miBody of the the current activity
    PvmActivity currentActivity = execution.getActivity();
    ActivityExecution scopeExecution = execution.findExecutionForFlowScope(currentActivity.getFlowScope());
    EventSubscriptionEntity.createAndInsert((ExecutionEntity) scopeExecution, EventType.COMPENSATE, compensationHandler);
}
Also used : ActivityExecution(org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity)

Example 20 with ActivityExecution

use of org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution in project camunda-bpm-platform by camunda.

the class InclusiveGatewayActivityBehavior method activatesGateway.

protected boolean activatesGateway(ActivityExecution execution, PvmActivity gatewayActivity) {
    int numExecutionsGuaranteedToActivate = gatewayActivity.getIncomingTransitions().size();
    ActivityExecution scopeExecution = execution.isScope() ? execution : execution.getParent();
    List<ActivityExecution> executionsAtGateway = execution.findInactiveConcurrentExecutions(gatewayActivity);
    if (executionsAtGateway.size() >= numExecutionsGuaranteedToActivate) {
        return true;
    } else {
        Collection<ActivityExecution> executionsNotAtGateway = getLeafExecutions(scopeExecution);
        executionsNotAtGateway.removeAll(executionsAtGateway);
        for (ActivityExecution executionNotAtGateway : executionsNotAtGateway) {
            if (canReachActivity(executionNotAtGateway, gatewayActivity)) {
                return false;
            }
        }
        // if no more token may arrive, then activate
        return true;
    }
}
Also used : 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