Search in sources :

Example 36 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class StageDiscretionaryItemHandlerTest method testWithParent.

@Test
public void testWithParent() {
    // given:
    // a new activity as parent
    CmmnCaseDefinition parent = new CmmnCaseDefinition("aParentActivity");
    context.setParent(parent);
    // when
    CmmnActivity activity = handler.handleElement(discretionaryItem, context);
    // then
    assertEquals(parent, activity.getParent());
    assertTrue(parent.getActivities().contains(activity));
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 37 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class ItemHandler method createActivity.

protected CmmnActivity createActivity(CmmnElement element, CmmnHandlerContext context) {
    String id = element.getId();
    CmmnActivity parent = context.getParent();
    CmmnActivity newActivity = null;
    if (parent != null) {
        newActivity = parent.createActivity(id);
    } else {
        CmmnCaseDefinition caseDefinition = context.getCaseDefinition();
        newActivity = new CmmnActivity(id, caseDefinition);
    }
    newActivity.setCmmnElement(element);
    CmmnActivityBehavior behavior = getActivityBehavior();
    newActivity.setActivityBehavior(behavior);
    return newActivity;
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)

Example 38 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CaseTaskActivityBehavior method triggerCallableElement.

protected void triggerCallableElement(CmmnActivityExecution execution, Map<String, Object> variables, String businessKey) {
    CmmnCaseDefinition definition = getCaseDefinitionToCall(execution, getCallableElement());
    CmmnCaseInstance caseInstance = execution.createSubCaseInstance(definition, businessKey);
    caseInstance.create(variables);
}
Also used : CmmnCaseDefinition(org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition) CmmnCaseInstance(org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)

Example 39 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CaseExecutionTerminationTest method testTerminateCaseInstance.

@Test
public void testTerminateCaseInstance() {
    // given ///////////////////////////////////////////////////////////////
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
    // an active case instance
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    // a case execution associated with Stage X
    CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
    // a case execution associated with Task A
    CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    // when
    caseInstance.terminate();
    // then
    assertTrue(caseInstance.isTerminated());
    assertTrue(stageX.isTerminated());
    assertTrue(taskA.isTerminated());
    assertTrue(taskB.isTerminated());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) 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) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder) Test(org.junit.Test)

Example 40 with CmmnCaseDefinition

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition in project camunda-bpm-platform by camunda.

the class CaseExecutionTerminationTest method testTerminateStage.

@Test
public void testTerminateStage() {
    // given ///////////////////////////////////////////////////////////////
    // a case definition
    CmmnCaseDefinition caseDefinition = new CaseDefinitionBuilder("Case1").createActivity("X").behavior(new StageActivityBehavior()).createActivity("A").behavior(new TaskWaitState()).endActivity().createActivity("B").behavior(new TaskWaitState()).endActivity().endActivity().buildCaseDefinition();
    // an active case instance
    CmmnCaseInstance caseInstance = caseDefinition.createCaseInstance();
    caseInstance.create();
    // a case execution associated with Stage X
    CmmnActivityExecution stageX = caseInstance.findCaseExecution("X");
    // a case execution associated with Task A
    CmmnActivityExecution taskA = caseInstance.findCaseExecution("A");
    // a case execution associated with Task B
    CmmnActivityExecution taskB = caseInstance.findCaseExecution("B");
    // when
    stageX.terminate();
    // then
    assertTrue(caseInstance.isCompleted());
    assertTrue(stageX.isTerminated());
    assertTrue(taskA.isTerminated());
    assertTrue(taskB.isTerminated());
}
Also used : CmmnActivityExecution(org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution) 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) CaseDefinitionBuilder(org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder) Test(org.junit.Test)

Aggregations

CmmnCaseDefinition (org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition)64 CmmnCaseInstance (org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance)48 CaseDefinitionBuilder (org.camunda.bpm.engine.impl.cmmn.model.CaseDefinitionBuilder)46 CmmnActivityExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnActivityExecution)38 Test (org.junit.Test)32 StageActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.StageActivityBehavior)22 ArrayList (java.util.ArrayList)18 CaseExecutionImpl (org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionImpl)17 CaseIllegalStateTransitionException (org.camunda.bpm.engine.exception.cmmn.CaseIllegalStateTransitionException)14 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)14 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)2 CmmnExecution (org.camunda.bpm.engine.impl.cmmn.execution.CmmnExecution)2 CmmnActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.CmmnActivityBehavior)1 MilestoneActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.MilestoneActivityBehavior)1 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)1 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)1 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)1 Case (org.camunda.bpm.model.cmmn.instance.Case)1 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)1 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1