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