use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class BpmnParseTest method testParseEscalationIntermediateThrowingEvent.
@Deployment
public void testParseEscalationIntermediateThrowingEvent() {
ActivityImpl escalationThrowingEvent = findActivityInDeployedProcessDefinition("escalationThrowingEvent");
assertEquals(ActivityTypes.INTERMEDIATE_EVENT_ESCALATION_THROW, escalationThrowingEvent.getProperties().get(BpmnProperties.TYPE));
assertEquals(ThrowEscalationEventActivityBehavior.class, escalationThrowingEvent.getActivityBehavior().getClass());
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class BpmnParseTest method testParseEscalationEndEvent.
@Deployment
public void testParseEscalationEndEvent() {
ActivityImpl escalationEndEvent = findActivityInDeployedProcessDefinition("escalationEndEvent");
assertEquals(ActivityTypes.END_EVENT_ESCALATION, escalationEndEvent.getProperties().get(BpmnProperties.TYPE));
assertEquals(ThrowEscalationEventActivityBehavior.class, escalationEndEvent.getActivityBehavior().getClass());
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl 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.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class LegacyBehavior method createActivityExecutionMapping.
/**
* Creates an activity execution mapping, when the scope hierarchy and the execution hierarchy are out of sync.
*
* @param scopeExecutions
* @param scopes
* @return
*/
public static Map<ScopeImpl, PvmExecutionImpl> createActivityExecutionMapping(List<PvmExecutionImpl> scopeExecutions, List<ScopeImpl> scopes) {
PvmExecutionImpl deepestExecution = scopeExecutions.get(0);
if (isLegacyAsyncAtMultiInstance(deepestExecution)) {
// in case the deepest execution is in fact async at multi-instance, the multi instance body is part
// of the list of scopes, however it is not instantiated yet or has already ended. Thus it must be removed.
scopes.remove(0);
}
// The trees are out of sync.
// We are missing executions:
int numOfMissingExecutions = scopes.size() - scopeExecutions.size();
// We need to find out which executions are missing.
// Consider: elements which did not use to be scopes are now scopes.
// But, this does not mean that all instances of elements which became scopes
// are missing their executions. We could have created new instances in the
// lower part of the tree after legacy behavior was turned off while instances of these elements
// further up the hierarchy miss scopes. So we need to iterate from the top down and skip all scopes which
// were not scopes before:
Collections.reverse(scopeExecutions);
Collections.reverse(scopes);
Map<ScopeImpl, PvmExecutionImpl> mapping = new HashMap<ScopeImpl, PvmExecutionImpl>();
// process definition / process instance.
mapping.put(scopes.get(0), scopeExecutions.get(0));
// nested activities
int executionCounter = 0;
for (int i = 1; i < scopes.size(); i++) {
ActivityImpl scope = (ActivityImpl) scopes.get(i);
PvmExecutionImpl scopeExecutionCandidate = null;
if (executionCounter + 1 < scopeExecutions.size()) {
scopeExecutionCandidate = scopeExecutions.get(executionCounter + 1);
}
if (numOfMissingExecutions > 0 && wasNoScope(scope, scopeExecutionCandidate)) {
// found a missing scope
numOfMissingExecutions--;
} else {
executionCounter++;
}
if (executionCounter >= scopeExecutions.size()) {
throw new ProcessEngineException("Cannot construct activity-execution mapping: there are " + "more scope executions missing than explained by the flow scope hierarchy.");
}
PvmExecutionImpl execution = scopeExecutions.get(executionCounter);
mapping.put(scope, execution);
}
return mapping;
}
use of org.camunda.bpm.engine.impl.pvm.process.ActivityImpl in project camunda-bpm-platform by camunda.
the class LegacyBehavior method isLegacyAsyncAtMultiInstance.
/**
* This returns true only if the provided execution has reached its wait state in a legacy engine version, because
* only in that case, it can be async and waiting at the inner activity wrapped by the miBody. In versions >= 7.3,
* the execution would reference the multi-instance body instead.
*/
protected static boolean isLegacyAsyncAtMultiInstance(PvmExecutionImpl execution) {
ActivityImpl activity = execution.getActivity();
if (activity != null) {
boolean isAsync = execution.getActivityInstanceId() == null;
boolean isAtMultiInstance = activity.getParentFlowScopeActivity() != null && activity.getParentFlowScopeActivity().getActivityBehavior() instanceof MultiInstanceActivityBehavior;
return isAsync && isAtMultiInstance;
} else {
return false;
}
}
Aggregations