Search in sources :

Example 6 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class StageActivityBehavior method performStart.

// start /////////////////////////////////////////////////////////////////////
protected void performStart(CmmnActivityExecution execution) {
    CmmnActivity activity = execution.getActivity();
    List<CmmnActivity> childActivities = activity.getActivities();
    if (childActivities != null && !childActivities.isEmpty()) {
        List<CmmnExecution> children = execution.createChildExecutions(childActivities);
        execution.createSentryParts();
        execution.triggerChildExecutionsLifecycle(children);
        if (execution.isActive()) {
            execution.fireIfOnlySentryParts();
            // then the stage will be completed.
            if (execution.isActive()) {
                checkAndCompleteCaseExecution(execution);
            }
        }
    } else {
        execution.complete();
    }
}
Also used : CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Example 7 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class AtomicOperationCaseExecutionDisable method preTransitionNotification.

protected void preTransitionNotification(CmmnExecution execution) {
    CmmnExecution parent = execution.getParent();
    if (parent != null) {
        CmmnActivityBehavior behavior = getActivityBehavior(parent);
        if (behavior instanceof CmmnCompositeActivityBehavior) {
            CmmnCompositeActivityBehavior compositeBehavior = (CmmnCompositeActivityBehavior) behavior;
            compositeBehavior.handleChildDisabled(parent, execution);
        }
    }
}
Also used : CmmnCompositeActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CmmnCompositeActivityBehavior) CmmnActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)

Example 8 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class CaseTaskTest method testTerminateSubCaseInstance.

/**
 * removed manual start as it is handled by default behaviour
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testTerminateSubCaseInstance() {
    // given
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE).getId();
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK).getId();
    String subCaseInstanceId = queryOneTaskCaseInstance().getId();
    // when
    terminate(subCaseInstanceId);
    // then
    CmmnExecution subCaseInstance = (CmmnExecution) queryOneTaskCaseInstance();
    assertNotNull(subCaseInstance);
    assertTrue(subCaseInstance.isTerminated());
    CaseExecution caseTask = queryCaseExecutionByActivityId(CASE_TASK);
    assertNotNull(caseTask);
    assertTrue(caseTask.isActive());
    // complete ////////////////////////////////////////////////////////
    close(subCaseInstanceId);
    assertCaseEnded(subCaseInstanceId);
    terminate(caseTaskId);
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class CaseExecutionStateTransitionCollector method notify.

public void notify(DelegateCaseExecution planItem) throws Exception {
    CmmnExecution execution = (CmmnExecution) planItem;
    String activityId = execution.getEventSource().getId();
    CaseExecutionState previousState = execution.getPreviousState();
    String previousStateName = "()";
    if (!previousState.equals(CaseExecutionState.NEW)) {
        previousStateName = previousState.toString();
    }
    CaseExecutionState newState = execution.getCurrentState();
    String stateTransition = previousStateName + " --" + execution.getEventName() + "(" + activityId + ")--> " + newState;
    LOG.debug("collecting state transition: " + stateTransition);
    stateTransitions.add(stateTransition);
}
Also used : CaseExecutionState(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)

Example 10 with CmmnExecution

use of org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution in project camunda-bpm-platform by camunda.

the class CaseInstanceTest method testCaseInstanceWithOneStateWithoutManualStartOfChildren.

@Test
public void testCaseInstanceWithOneStateWithoutManualStartOfChildren() {
    CaseExecutionStateTransitionCollector stateTransitionCollector = new CaseExecutionStateTransitionCollector();
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").listener("create", stateTransitionCollector).createActivity("X").listener("create", stateTransitionCollector).listener("enable", stateTransitionCollector).listener("manualStart", stateTransitionCollector).property(ItemHandler.PROPERTY_MANUAL_ACTIVATION_RULE, defaultManualActivation()).behavior(new StageActivityBehavior()).createActivity("A").listener("create", stateTransitionCollector).listener("start", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().createActivity("B").listener("create", stateTransitionCollector).listener("start", stateTransitionCollector).behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    List<String> expectedStateTransitions = initAndAssertExpectedTransitions(stateTransitionCollector);
    emptyCollector(stateTransitionCollector, expectedStateTransitions);
    // clear lists
    CaseExecutionImpl planItemX = assertCaseXState(caseInstance);
    // manual start of x
    planItemX.manualStart();
    // X should be active
    assertTrue(planItemX.isActive());
    // expected state transitions after a manual start of X:
    expectedStateTransitions.add("enabled --manualStart(X)--> active");
    expectedStateTransitions.add("() --create(A)--> available");
    expectedStateTransitions.add("available --start(A)--> active");
    expectedStateTransitions.add("() --create(B)--> available");
    expectedStateTransitions.add("available --start(B)--> active");
    assertEquals(expectedStateTransitions, stateTransitionCollector.stateTransitions);
    // clear lists
    emptyCollector(stateTransitionCollector, expectedStateTransitions);
    // X should have two chil plan items
    List<CaseExecutionImpl> childPlanItems;
    childPlanItems = planItemX.getCaseExecutions();
    assertEquals(2, childPlanItems.size());
    for (CmmnExecution childPlanItem : childPlanItems) {
        // both children should be active
        assertTrue(childPlanItem.isActive());
        // X should be the parent of both children
        assertEquals(planItemX, childPlanItem.getParent());
    }
}
Also used : CaseExecutionImpl(org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl) StageActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior) CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance) CmmnExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder) Test(org.junit.Test)

Aggregations

CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)16 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)4 Deployment (org.camunda.bpm.engine.test.Deployment)4 CmmnActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior)2 CmmnCompositeActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnCompositeActivityBehavior)2 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)2 CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)2 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)2 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)2 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)2 CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)2 Execution (org.camunda.bpm.engine.runtime.Execution)2 Test (org.junit.Test)2 TransferVariablesActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.TransferVariablesActivityBehavior)1 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)1 CaseExecutionState (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState)1 CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)1 HistoricCaseInstanceEventEntity (org.camunda.bpm.engine.impl.history.event.HistoricCaseInstanceEventEntity)1 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)1 SubProcessActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior)1