use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class ActivityCancellationCmd method getTransitionInstancesForActivity.
protected List<TransitionInstance> getTransitionInstancesForActivity(ActivityInstance tree, Set<String> parentScopeIds) {
// prune all search paths that are not in the scope hierarchy of the activity in question
if (!parentScopeIds.contains(tree.getActivityId())) {
return Collections.emptyList();
}
List<TransitionInstance> instances = new ArrayList<TransitionInstance>();
TransitionInstance[] transitionInstances = tree.getChildTransitionInstances();
for (TransitionInstance transitionInstance : transitionInstances) {
if (activityId.equals(transitionInstance.getActivityId())) {
instances.add(transitionInstance);
}
}
for (ActivityInstance child : tree.getChildActivityInstances()) {
instances.addAll(getTransitionInstancesForActivity(child, parentScopeIds));
}
return instances;
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class ActivityCancellationCmd method createActivityInstanceCancellations.
public List<AbstractInstanceCancellationCmd> createActivityInstanceCancellations(ActivityInstance activityInstanceTree, CommandContext commandContext) {
List<AbstractInstanceCancellationCmd> commands = new ArrayList<AbstractInstanceCancellationCmd>();
ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
ProcessDefinitionImpl processDefinition = processInstance.getProcessDefinition();
Set<String> parentScopeIds = collectParentScopeIdsForActivity(processDefinition, activityId);
List<ActivityInstance> childrenForActivity = getActivityInstancesForActivity(activityInstanceTree, parentScopeIds);
for (ActivityInstance instance : childrenForActivity) {
commands.add(new ActivityInstanceCancellationCmd(processInstanceId, instance.getId()));
}
List<TransitionInstance> transitionInstancesForActivity = getTransitionInstancesForActivity(activityInstanceTree, parentScopeIds);
for (TransitionInstance instance : transitionInstancesForActivity) {
commands.add(new TransitionInstanceCancellationCmd(processInstanceId, instance.getId()));
}
return commands;
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class TransitionInstanceCancellationCmd method determineSourceInstanceExecution.
protected ExecutionEntity determineSourceInstanceExecution(final CommandContext commandContext) {
ActivityInstance instance = commandContext.runWithoutAuthorization(new Callable<ActivityInstance>() {
public ActivityInstance call() throws Exception {
return new GetActivityInstanceCmd(processInstanceId).execute(commandContext);
}
});
TransitionInstance instanceToCancel = findTransitionInstance(instance, transitionInstanceId);
EnsureUtil.ensureNotNull(NotValidException.class, describeFailure("Transition instance '" + transitionInstanceId + "' does not exist"), "transitionInstance", instanceToCancel);
ExecutionEntity transitionExecution = commandContext.getExecutionManager().findExecutionById(instanceToCancel.getExecutionId());
return transitionExecution;
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testTransitionInstanceActivityTypePropertyAfterStartEvent.
@Deployment(resources = "org/camunda/bpm/engine/test/api/runtime/RuntimeServiceTest.testTransitionInstanceActivityNamePropertyAfterStartEvent.bpmn20.xml")
@Test
public void testTransitionInstanceActivityTypePropertyAfterStartEvent() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
// then
TransitionInstance[] instances = tree.getTransitionInstances("start");
TransitionInstance task = instances[0];
assertNotNull(task);
assertNotNull(task.getActivityType());
assertEquals("startEvent", task.getActivityType());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class RuntimeServiceTest method testActivityInstanceTreeForNestedAsyncBeforeTask.
@Deployment
@Test
public void testActivityInstanceTreeForNestedAsyncBeforeTask() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").transition("theTask").done());
TransitionInstance asyncBeforeTransitionInstance = tree.getChildActivityInstances()[0].getChildTransitionInstances()[0];
String asyncExecutionId = managementService.createJobQuery().singleResult().getExecutionId();
assertEquals(asyncExecutionId, asyncBeforeTransitionInstance.getExecutionId());
}
Aggregations