use of org.camunda.bpm.engine.impl.pvm.PvmTransition in project camunda-bpm-platform by camunda.
the class BpmnActivityBehavior method performOutgoingBehavior.
/**
* 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.
* @param throwExceptionIfExecutionStuck
* If true, an {@link ProcessEngineException} will be thrown in case no
* transition could be found to leave the activity.
*/
protected void performOutgoingBehavior(ActivityExecution execution, boolean checkConditions, boolean throwExceptionIfExecutionStuck, List<ActivityExecution> reusableExecutions) {
LOG.leavingActivity(execution.getActivity().getId());
String defaultSequenceFlow = (String) execution.getActivity().getProperty("default");
List<PvmTransition> transitionsToTake = new ArrayList<PvmTransition>();
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);
if (throwExceptionIfExecutionStuck) {
throw LOG.stuckExecutionException(execution.getActivity().getId());
}
}
}
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmTransition in project camunda-bpm-platform by camunda.
the class MigratingAsyncJobInstance method updateAsyncAfterTargetConfiguration.
protected void updateAsyncAfterTargetConfiguration(AsyncContinuationConfiguration currentConfiguration) {
ActivityImpl targetActivity = (ActivityImpl) targetScope;
List<PvmTransition> outgoingTransitions = targetActivity.getOutgoingTransitions();
AsyncContinuationConfiguration targetConfiguration = new AsyncContinuationConfiguration();
if (outgoingTransitions.isEmpty()) {
targetConfiguration.setAtomicOperation(PvmAtomicOperation.ACTIVITY_END.getCanonicalName());
} else {
targetConfiguration.setAtomicOperation(PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE.getCanonicalName());
if (outgoingTransitions.size() == 1) {
targetConfiguration.setTransitionId(outgoingTransitions.get(0).getId());
} else {
TransitionImpl matchingTargetTransition = null;
String currentTransitionId = currentConfiguration.getTransitionId();
if (currentTransitionId != null) {
matchingTargetTransition = targetActivity.findOutgoingTransition(currentTransitionId);
}
if (matchingTargetTransition != null) {
targetConfiguration.setTransitionId(matchingTargetTransition.getId());
} else {
// should not happen since it is avoided by validation
throw new ProcessEngineException("Cannot determine matching outgoing sequence flow");
}
}
}
jobEntity.setJobHandlerConfiguration(targetConfiguration);
}
use of org.camunda.bpm.engine.impl.pvm.PvmTransition in project camunda-bpm-platform by camunda.
the class BpmnParseTest method testParseNamespaceInConditionExpressionType.
@Deployment
public void testParseNamespaceInConditionExpressionType() {
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
@Override
public ProcessDefinitionEntity execute(CommandContext commandContext) {
return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("resolvableNamespacesProcess");
}
});
// Test that the process definition has been deployed
assertNotNull(processDefinitionEntity);
PvmActivity activity = processDefinitionEntity.findActivity("ExclusiveGateway_1");
assertNotNull(activity);
// Test that the conditions has been resolved
for (PvmTransition transition : activity.getOutgoingTransitions()) {
if (transition.getDestination().getId().equals("Task_2")) {
assertTrue(transition.getProperty("conditionText").equals("#{approved}"));
} else if (transition.getDestination().getId().equals("Task_3")) {
assertTrue(transition.getProperty("conditionText").equals("#{!approved}"));
} else {
fail("Something went wrong");
}
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmTransition in project camunda-bpm-platform by camunda.
the class BpmnParseTest method testParseDiagramInterchangeElements.
@Deployment
public void testParseDiagramInterchangeElements() {
// Graphical information is not yet exposed publicly, so we need to do some
// plumbing
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
@Override
public ProcessDefinitionEntity execute(CommandContext commandContext) {
return Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedLatestProcessDefinitionByKey("myProcess");
}
});
assertNotNull(processDefinitionEntity);
assertEquals(7, processDefinitionEntity.getActivities().size());
// Check if diagram has been created based on Diagram Interchange when it's
// not a headless instance
List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
if (processEngineConfiguration.isCreateDiagramOnDeploy()) {
assertEquals(2, resourceNames.size());
} else {
assertEquals(1, resourceNames.size());
}
for (ActivityImpl activity : processDefinitionEntity.getActivities()) {
if (activity.getId().equals("theStart")) {
assertActivityBounds(activity, 70, 255, 30, 30);
} else if (activity.getId().equals("task1")) {
assertActivityBounds(activity, 176, 230, 100, 80);
} else if (activity.getId().equals("gateway1")) {
assertActivityBounds(activity, 340, 250, 40, 40);
} else if (activity.getId().equals("task2")) {
assertActivityBounds(activity, 445, 138, 100, 80);
} else if (activity.getId().equals("gateway2")) {
assertActivityBounds(activity, 620, 250, 40, 40);
} else if (activity.getId().equals("task3")) {
assertActivityBounds(activity, 453, 304, 100, 80);
} else if (activity.getId().equals("theEnd")) {
assertActivityBounds(activity, 713, 256, 28, 28);
}
for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
assertTrue(((TransitionImpl) sequenceFlow).getWaypoints().size() >= 4);
TransitionImpl transitionImpl = (TransitionImpl) sequenceFlow;
if (transitionImpl.getId().equals("flowStartToTask1")) {
assertSequenceFlowWayPoints(transitionImpl, 100, 270, 176, 270);
} else if (transitionImpl.getId().equals("flowTask1ToGateway1")) {
assertSequenceFlowWayPoints(transitionImpl, 276, 270, 340, 270);
} else if (transitionImpl.getId().equals("flowGateway1ToTask2")) {
assertSequenceFlowWayPoints(transitionImpl, 360, 250, 360, 178, 445, 178);
} else if (transitionImpl.getId().equals("flowGateway1ToTask3")) {
assertSequenceFlowWayPoints(transitionImpl, 360, 290, 360, 344, 453, 344);
} else if (transitionImpl.getId().equals("flowTask2ToGateway2")) {
assertSequenceFlowWayPoints(transitionImpl, 545, 178, 640, 178, 640, 250);
} else if (transitionImpl.getId().equals("flowTask3ToGateway2")) {
assertSequenceFlowWayPoints(transitionImpl, 553, 344, 640, 344, 640, 290);
} else if (transitionImpl.getId().equals("flowGateway2ToEnd")) {
assertSequenceFlowWayPoints(transitionImpl, 660, 270, 713, 270);
}
}
}
}
use of org.camunda.bpm.engine.impl.pvm.PvmTransition 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);
}
}
Aggregations