Search in sources :

Example 1 with TransitionInstance

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;
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ArrayList(java.util.ArrayList)

Example 2 with TransitionInstance

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;
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ProcessDefinitionImpl(org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ArrayList(java.util.ArrayList) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 3 with TransitionInstance

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;
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) NotValidException(org.camunda.bpm.engine.exception.NotValidException)

Example 4 with TransitionInstance

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());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with TransitionInstance

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());
}
Also used : TransitionInstance(org.camunda.bpm.engine.runtime.TransitionInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

TransitionInstance (org.camunda.bpm.engine.runtime.TransitionInstance)34 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)31 Deployment (org.camunda.bpm.engine.test.Deployment)27 Test (org.junit.Test)21 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)20 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)19 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 ExecutionAssert.describeExecutionTree (org.camunda.bpm.engine.test.util.ExecutionAssert.describeExecutionTree)5 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)5 Task (org.camunda.bpm.engine.task.Task)4 NotValidException (org.camunda.bpm.engine.exception.NotValidException)3 Job (org.camunda.bpm.engine.runtime.Job)3 ArrayList (java.util.ArrayList)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1