Java Code Examples for org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#leaveActivityViaTransition()
The following examples show how to use
org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution#leaveActivityViaTransition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: While.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
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); } } }
Example 2
Source File: ExclusiveGatewayActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * The default behaviour of BPMN, taking every outgoing sequence flow * (where the condition evaluates to true), is not valid for an exclusive * gateway. * * Hence, this behaviour is overriden and replaced by the correct behavior: * selecting the first sequence flow which condition evaluates to true * (or which hasn't got a condition) and leaving the activity through that * sequence flow. * * If no sequence flow is selected (ie all conditions evaluate to false), * then the default sequence flow is taken (if defined). */ @Override public void doLeave(ActivityExecution execution) { LOG.leavingActivity(execution.getActivity().getId()); PvmTransition outgoingSeqFlow = null; String defaultSequenceFlow = (String) execution.getActivity().getProperty("default"); Iterator<PvmTransition> transitionIterator = execution.getActivity().getOutgoingTransitions().iterator(); while (outgoingSeqFlow == null && transitionIterator.hasNext()) { PvmTransition seqFlow = transitionIterator.next(); Condition condition = (Condition) seqFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION); if ( (condition == null && (defaultSequenceFlow == null || !defaultSequenceFlow.equals(seqFlow.getId())) ) || (condition != null && condition.evaluate(execution)) ) { LOG.outgoingSequenceFlowSelected(seqFlow.getId()); outgoingSeqFlow = seqFlow; } } if (outgoingSeqFlow != null) { execution.leaveActivityViaTransition(outgoingSeqFlow); } else { if (defaultSequenceFlow != null) { PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow); if (defaultTransition != null) { execution.leaveActivityViaTransition(defaultTransition); } else { throw LOG.missingDefaultFlowException(execution.getActivity().getId(), defaultSequenceFlow); } } else { //No sequence flow could be found, not even a default one throw LOG.stuckExecutionException(execution.getActivity().getId()); } } }
Example 3
Source File: Decision.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); }
Example 4
Source File: Automatic.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void execute(ActivityExecution execution) throws Exception { List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions(); if(outgoingTransitions.isEmpty()) { execution.end(true); } else { execution.leaveActivityViaTransition(outgoingTransitions.get(0)); } }
Example 5
Source File: ThrowsExceptionBehavior.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
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); }
Example 6
Source File: BpmnActivityBehavior.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
/** * Actual implementation of leaving an activity. * * @param execution * The current execution context * @param checkConditions * Whether or not to check conditions before determining whether or * not to take a transition. */ protected void performOutgoingBehavior(ActivityExecution execution, boolean checkConditions, List<ActivityExecution> reusableExecutions) { LOG.leavingActivity(execution.getActivity().getId()); String defaultSequenceFlow = (String) execution.getActivity().getProperty("default"); List<PvmTransition> transitionsToTake = new ArrayList<>(); List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions(); for (PvmTransition outgoingTransition : outgoingTransitions) { if (defaultSequenceFlow == null || !outgoingTransition.getId().equals(defaultSequenceFlow)) { Condition condition = (Condition) outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION); if (condition == null || !checkConditions || condition.evaluate(execution)) { transitionsToTake.add(outgoingTransition); } } } if (transitionsToTake.size() == 1) { execution.leaveActivityViaTransition(transitionsToTake.get(0)); } else if (transitionsToTake.size() >= 1) { if (reusableExecutions == null || reusableExecutions.isEmpty()) { execution.leaveActivityViaTransitions(transitionsToTake, Arrays.asList(execution)); } else { execution.leaveActivityViaTransitions(transitionsToTake, reusableExecutions); } } else { if (defaultSequenceFlow != null) { PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow); if (defaultTransition != null) { execution.leaveActivityViaTransition(defaultTransition); } else { throw LOG.missingDefaultFlowException(execution.getActivity().getId(), defaultSequenceFlow); } } else if (!outgoingTransitions.isEmpty()) { throw LOG.missingConditionalFlowException(execution.getActivity().getId()); } else { if (((ActivityImpl) execution.getActivity()).isCompensationHandler() && isAncestorCompensationThrowing(execution)) { execution.endCompensation(); } else { LOG.missingOutgoingSequenceFlow(execution.getActivity().getId()); execution.end(true); } } } }
Example 7
Source File: MigrationSignallableServiceTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void signal(ActivityExecution execution, String signalEvent, Object signalData) throws Exception { PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0); execution.leaveActivityViaTransition(transition); }
Example 8
Source File: WaitState.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0); execution.leaveActivityViaTransition(transition); }
Example 9
Source File: Noop.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void execute(ActivityExecution execution) throws Exception { PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0); execution.leaveActivityViaTransition(transition); }