Search in sources :

Example 16 with PvmTransition

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

the class While method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmTransition more = execution.getActivity().findOutgoingTransition("more");
    PvmTransition done = execution.getActivity().findOutgoingTransition("done");
    Integer value = (Integer) execution.getVariable(variableName);
    if (value == null) {
        execution.setVariable(variableName, from);
        execution.leaveActivityViaTransition(more);
    } else {
        value = value + 1;
        if (value < to) {
            execution.setVariable(variableName, value);
            execution.leaveActivityViaTransition(more);
        } else {
            execution.leaveActivityViaTransition(done);
        }
    }
}
Also used : PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 17 with PvmTransition

use of org.camunda.bpm.engine.impl.pvm.PvmTransition 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 PvmTransition

use of org.camunda.bpm.engine.impl.pvm.PvmTransition 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 PvmTransition

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

the class ThrowsExceptionBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    String var = (String) execution.getVariable("var");
    PvmTransition transition = null;
    try {
        executeLogic(var);
        transition = execution.getActivity().findOutgoingTransition("no-exception");
    } catch (Exception e) {
        transition = execution.getActivity().findOutgoingTransition("exception");
    }
    execution.leaveActivityViaTransition(transition);
}
Also used : PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Aggregations

PvmTransition (org.camunda.bpm.engine.impl.pvm.PvmTransition)19 PvmActivity (org.camunda.bpm.engine.impl.pvm.PvmActivity)7 ActivityExecution (org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution)5 Condition (org.camunda.bpm.engine.impl.Condition)4 ArrayList (java.util.ArrayList)3 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)3 TransitionImpl (org.camunda.bpm.engine.impl.pvm.process.TransitionImpl)3 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)2 CommandExecutor (org.camunda.bpm.engine.impl.interceptor.CommandExecutor)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 List (java.util.List)1 RepositoryServiceImpl (org.camunda.bpm.engine.impl.RepositoryServiceImpl)1 AsyncContinuationConfiguration (org.camunda.bpm.engine.impl.jobexecutor.AsyncContinuationJobHandler.AsyncContinuationConfiguration)1 ReadOnlyProcessDefinition (org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition)1 ModificationObserverBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior)1 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)1 ExecutionStartContext (org.camunda.bpm.engine.impl.pvm.runtime.ExecutionStartContext)1