Search in sources :

Example 6 with PlanItem

use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testActivityTreeWithOneHumanTask.

/**
 *   +-----------------+                    +-----------------+
 *   | Case1            \                   | aCaseDefinition |
 *   +-------------------+---+              +-----------------+
 *   |                       |                      |
 *   |     +-------+         |   ==>        +-----------------+
 *   |     |   A   |         |              |  aCasePlanModel |
 *   |     +-------+         |              +-----------------+
 *   |                       |                      |
 *   +-----------------------+              +-----------------+
 *                                          |       A         |
 *                                          +-----------------+
 */
@Test
public void testActivityTreeWithOneHumanTask() {
    // given
    HumanTask humanTask = createElement(casePlanModel, "A", HumanTask.class);
    PlanItem planItem = createElement(casePlanModel, "PI_A", PlanItem.class);
    planItem.setDefinition(humanTask);
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseDefinition.getActivities();
    CmmnActivity casePlanModelActivity = activities.get(0);
    List<CmmnActivity> planItemActivities = casePlanModelActivity.getActivities();
    assertEquals(1, planItemActivities.size());
    CmmnActivity child = planItemActivities.get(0);
    assertEquals(planItem.getId(), child.getId());
    assertTrue(child.getActivities().isEmpty());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 7 with PlanItem

use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.

the class ItemHandler method getName.

protected String getName(CmmnElement element) {
    String name = null;
    if (isPlanItem(element)) {
        PlanItem planItem = (PlanItem) element;
        name = planItem.getName();
    }
    if (name == null || name.isEmpty()) {
        PlanItemDefinition definition = getDefinition(element);
        if (definition != null) {
            name = definition.getName();
        }
    }
    return name;
}
Also used : PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)

Example 8 with PlanItem

use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testNestedStages.

/**
 *   +-----------------+                                                    +-----------------+
 *   | Case1            \                                                   | aCaseDefinition |
 *   +-------------------+-------------------+                              +-----------------+
 *   |                                       |                                       |
 *   |  +-------+                            |                              +-----------------+
 *   |  |  A1   |                            |              +---------------|  aCasePlanModel |---------------+
 *   |  +-------+                            |              |               +-----------------+               |
 *   |                                       |              |                        |                        |
 *   |    +------------------------+         |      +-----------------+     +-----------------+      +-----------------+
 *   |   / X1                       \        |      |       A1        |     |        X1       |      |        Y        |-----------+
 *   |  +    +-------+  +-------+    +       |      +-----------------+     +-----------------+      +-----------------+           |
 *   |  |    |  A2   |  |   B   |    |       |                                      / \                                           / \
 *   |  +    +-------+  +-------+    +       |                                     /   \                                         /   \
 *   |   \                          /        |                    +---------------+     +---------------+     +-----------------+     +-----------------+
 *   |    +------------------------+         |                    |      A2       |     |      B        |     |        C        |     |       X2        |
 *   |                                       |                    +---------------+     +---------------+     +-----------------+     +-----------------+
 *   |    +-----------------------------+    |  ==>                                                                                          / \
 *   |   / Y                             \   |                                                                              +---------------+   +---------------+
 *   |  +    +-------+                    +  |                                                                              |      A1       |   |       B       |
 *   |  |    |   C   |                    |  |                                                                              +---------------+   +---------------+
 *   |  |    +-------+                    |  |
 *   |  |                                 |  |
 *   |  |   +------------------------+    |  |
 *   |  |  / X2                       \   |  |
 *   |  | +    +-------+  +-------+    +  |  |
 *   |  | |    |  A1   |  |   B   |    |  |  |
 *   |  | +    +-------+  +-------+    +  |  |
 *   |  |  \                          /   |  |
 *   |  +   +------------------------+    +  |
 *   |   \                               /   |
 *   |    +-----------------------------+    |
 *   |                                       |
 *   +---------------------------------------+
 */
@Test
public void testNestedStages() {
    // given
    Stage stageX = createElement(casePlanModel, "X", Stage.class);
    Stage stageY = createElement(casePlanModel, "Y", Stage.class);
    HumanTask humanTaskA = createElement(casePlanModel, "A", HumanTask.class);
    HumanTask humanTaskB = createElement(casePlanModel, "B", HumanTask.class);
    HumanTask humanTaskC = createElement(casePlanModel, "C", HumanTask.class);
    PlanItem planItemA1 = createElement(casePlanModel, "PI_A1", PlanItem.class);
    planItemA1.setDefinition(humanTaskA);
    PlanItem planItemX1 = createElement(casePlanModel, "PI_X1", PlanItem.class);
    planItemX1.setDefinition(stageX);
    PlanItem planItemA2 = createElement(stageX, "PI_A2", PlanItem.class);
    planItemA2.setDefinition(humanTaskA);
    PlanItem planItemB = createElement(stageX, "PI_B", PlanItem.class);
    planItemB.setDefinition(humanTaskB);
    PlanItem planItemY = createElement(casePlanModel, "PI_Y", PlanItem.class);
    planItemY.setDefinition(stageY);
    PlanItem planItemC = createElement(stageY, "PI_C", PlanItem.class);
    planItemC.setDefinition(humanTaskC);
    PlanItem planItemX2 = createElement(stageY, "PI_X2", PlanItem.class);
    planItemX2.setDefinition(stageX);
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseDefinition.getActivities();
    CmmnActivity casePlanModelActivity = activities.get(0);
    List<CmmnActivity> children = casePlanModelActivity.getActivities();
    assertEquals(3, children.size());
    CmmnActivity childPlanItem = children.get(0);
    assertEquals(planItemA1.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
    childPlanItem = children.get(1);
    assertEquals(planItemX1.getId(), childPlanItem.getId());
    List<CmmnActivity> childrenOfX1 = childPlanItem.getActivities();
    assertFalse(childrenOfX1.isEmpty());
    assertEquals(2, childrenOfX1.size());
    childPlanItem = childrenOfX1.get(0);
    assertEquals(planItemA2.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
    childPlanItem = childrenOfX1.get(1);
    assertEquals(planItemB.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
    childPlanItem = children.get(2);
    assertEquals(planItemY.getId(), childPlanItem.getId());
    List<CmmnActivity> childrenOfY = childPlanItem.getActivities();
    assertFalse(childrenOfY.isEmpty());
    assertEquals(2, childrenOfY.size());
    childPlanItem = childrenOfY.get(0);
    assertEquals(planItemC.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
    childPlanItem = childrenOfY.get(1);
    assertEquals(planItemX2.getId(), childPlanItem.getId());
    List<CmmnActivity> childrenOfX2 = childPlanItem.getActivities();
    assertFalse(childrenOfX2.isEmpty());
    assertEquals(2, childrenOfX2.size());
    childPlanItem = childrenOfX2.get(0);
    assertEquals(planItemA2.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
    childPlanItem = childrenOfX2.get(1);
    assertEquals(planItemB.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) Stage(org.camunda.bpm.model.cmmn.instance.Stage) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 9 with PlanItem

use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.

the class CreateModelTest method createCaseWithOneStageAndNestedHumanTask.

@Test
public void createCaseWithOneStageAndNestedHumanTask() {
    // create process
    Case caseInstance = createElement(definitions, "case-with-one-human-task", Case.class);
    // create case plan model
    CasePlanModel casePlanModel = createElement(caseInstance, "casePlanModel_1", CasePlanModel.class);
    // create a stage
    Stage stage = createElement(casePlanModel, "Stage_1", Stage.class);
    // create elements
    HumanTask humanTask = createElement(stage, "HumanTask_1", HumanTask.class);
    // create a plan item
    PlanItem planItem = createElement(stage, "PlanItem_1", PlanItem.class);
    // set definition to human task
    planItem.setDefinition(humanTask);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Stage(org.camunda.bpm.model.cmmn.instance.Stage) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Case(org.camunda.bpm.model.cmmn.instance.Case) Test(org.junit.Test)

Example 10 with PlanItem

use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.

the class Cmmn10Test method shouldGetPlanItemExitCriterion.

@Test
public void shouldGetPlanItemExitCriterion() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    PlanItem planItem = modelInstance.getModelElementsByType(PlanItem.class).iterator().next();
    Collection<Sentry> exitCriterias = planItem.getExitCriterias();
    assertThat(exitCriterias).hasSize(1);
    Collection<Sentry> exitCriteria = planItem.getExitCriteria();
    assertThat(exitCriteria).hasSize(1);
    Collection<ExitCriterion> exitCriterions = planItem.getExitCriterions();
    assertThat(exitCriterions).isEmpty();
}
Also used : PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) ExitCriterion(org.camunda.bpm.model.cmmn.instance.ExitCriterion) Test(org.junit.Test)

Aggregations

PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)11 Test (org.junit.Test)8 HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)5 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)4 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)3 Case (org.camunda.bpm.model.cmmn.instance.Case)3 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)3 Sentry (org.camunda.bpm.model.cmmn.instance.Sentry)3 Stage (org.camunda.bpm.model.cmmn.instance.Stage)3 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)2 PlanItemDefinition (org.camunda.bpm.model.cmmn.instance.PlanItemDefinition)2 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)1 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)1 PlanItemTransition (org.camunda.bpm.model.cmmn.PlanItemTransition)1 CmmnElement (org.camunda.bpm.model.cmmn.instance.CmmnElement)1 EntryCriterion (org.camunda.bpm.model.cmmn.instance.EntryCriterion)1 ExitCriterion (org.camunda.bpm.model.cmmn.instance.ExitCriterion)1 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1 CmmnModelResource (org.camunda.bpm.model.cmmn.util.CmmnModelResource)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1