Search in sources :

Example 6 with PvmTransition

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

the class PvmAtomicOperationTransitionDestroyScope method execute.

public void execute(PvmExecutionImpl execution) {
    // calculate the propagating execution
    PvmExecutionImpl propagatingExecution = execution;
    PvmActivity activity = execution.getActivity();
    List<PvmTransition> transitionsToTake = execution.getTransitionsToTake();
    execution.setTransitionsToTake(null);
    // check whether the current scope needs to be destroyed
    if (execution.isScope() && activity.isScope()) {
        if (!LegacyBehavior.destroySecondNonScope(execution)) {
            if (execution.isConcurrent()) {
                // legacy behavior
                LegacyBehavior.destroyConcurrentScope(execution);
            } else {
                propagatingExecution = execution.getParent();
                LOG.debugDestroyScope(execution, propagatingExecution);
                execution.destroy();
                propagatingExecution.setActivity(execution.getActivity());
                propagatingExecution.setTransition(execution.getTransition());
                propagatingExecution.setActive(true);
                execution.remove();
            }
        }
    } else {
        // activity is not scope => nothing to do
        propagatingExecution = execution;
    }
    // take the specified transitions
    if (transitionsToTake.isEmpty()) {
        throw new ProcessEngineException(execution.toString() + ": No outgoing transitions from " + "activity " + activity);
    } else if (transitionsToTake.size() == 1) {
        propagatingExecution.setTransition(transitionsToTake.get(0));
        propagatingExecution.take();
    } else {
        propagatingExecution.inactivate();
        List<OutgoingExecution> outgoingExecutions = new ArrayList<OutgoingExecution>();
        for (int i = 0; i < transitionsToTake.size(); i++) {
            PvmTransition transition = transitionsToTake.get(i);
            PvmExecutionImpl scopeExecution = propagatingExecution.isScope() ? propagatingExecution : propagatingExecution.getParent();
            // reuse concurrent, propagating execution for first transition
            PvmExecutionImpl concurrentExecution = null;
            if (i == 0) {
                concurrentExecution = propagatingExecution;
            } else {
                concurrentExecution = scopeExecution.createConcurrentExecution();
                if (i == 1 && !propagatingExecution.isConcurrent()) {
                    outgoingExecutions.remove(0);
                    // get a hold of the concurrent execution that replaced the scope propagating execution
                    PvmExecutionImpl replacingExecution = null;
                    for (PvmExecutionImpl concurrentChild : scopeExecution.getNonEventScopeExecutions()) {
                        if (!(concurrentChild == propagatingExecution)) {
                            replacingExecution = concurrentChild;
                            break;
                        }
                    }
                    outgoingExecutions.add(new OutgoingExecution(replacingExecution, transitionsToTake.get(0)));
                }
            }
            outgoingExecutions.add(new OutgoingExecution(concurrentExecution, transition));
        }
        // start executions in reverse order (order will be reversed again in command context with the effect that they are
        // actually be started in correct order :) )
        Collections.reverse(outgoingExecutions);
        for (OutgoingExecution outgoingExecution : outgoingExecutions) {
            outgoingExecution.take();
        }
    }
}
Also used : PvmExecutionImpl(org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl) List(java.util.List) ArrayList(java.util.ArrayList) OutgoingExecution(org.camunda.bpm.engine.impl.pvm.runtime.OutgoingExecution) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 7 with PvmTransition

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

the class RepositoryServiceTest method testProcessDefinitionIntrospection.

public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/repository/processOne.bpmn20.xml").deploy().getId();
    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(procDefId);
    assertEquals(procDefId, processDefinition.getId());
    assertEquals("Process One", processDefinition.getName());
    assertEquals("the first process", processDefinition.getProperty("documentation"));
    PvmActivity start = processDefinition.findActivity("start");
    assertNotNull(start);
    assertEquals("start", start.getId());
    assertEquals("S t a r t", start.getProperty("name"));
    assertEquals("the start event", start.getProperty("documentation"));
    assertEquals(Collections.EMPTY_LIST, start.getActivities());
    List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions();
    assertEquals(1, outgoingTransitions.size());
    assertEquals("${a == b}", outgoingTransitions.get(0).getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT));
    PvmActivity end = processDefinition.findActivity("end");
    assertNotNull(end);
    assertEquals("end", end.getId());
    PvmTransition transition = outgoingTransitions.get(0);
    assertEquals("flow1", transition.getId());
    assertEquals("Flow One", transition.getProperty("name"));
    assertEquals("The only transitions in the process", transition.getProperty("documentation"));
    assertSame(start, transition.getSource());
    assertSame(end, transition.getDestination());
    repositoryService.deleteDeployment(deploymentId);
}
Also used : ReadOnlyProcessDefinition(org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition) RepositoryServiceImpl(org.camunda.bpm.engine.impl.RepositoryServiceImpl) PvmActivity(org.camunda.bpm.engine.impl.pvm.PvmActivity) PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 8 with PvmTransition

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

the class Noop method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0);
    execution.leaveActivityViaTransition(transition);
}
Also used : PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 9 with PvmTransition

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

the class Decision method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmTransition transition = null;
    String creditRating = (String) execution.getVariable("creditRating");
    if (creditRating.equals("AAA+")) {
        transition = execution.getActivity().findOutgoingTransition("wow");
    } else if (creditRating.equals("Aaa-")) {
        transition = execution.getActivity().findOutgoingTransition("nice");
    } else {
        transition = execution.getActivity().findOutgoingTransition("default");
    }
    execution.leaveActivityViaTransition(transition);
}
Also used : PvmTransition(org.camunda.bpm.engine.impl.pvm.PvmTransition)

Example 10 with PvmTransition

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

the class WaitState method signal.

public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0);
    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