Search in sources :

Example 16 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask 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 17 with HumanTask

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

the class CmmnTransform method transformPlanItem.

protected void transformPlanItem(PlanItem planItem, CmmnActivity parent) {
    PlanItemDefinition definition = planItem.getDefinition();
    ItemHandler planItemTransformer = null;
    if (definition instanceof HumanTask) {
        planItemTransformer = getPlanItemHandler(HumanTask.class);
    } else if (definition instanceof ProcessTask) {
        planItemTransformer = getPlanItemHandler(ProcessTask.class);
    } else if (definition instanceof CaseTask) {
        planItemTransformer = getPlanItemHandler(CaseTask.class);
    } else if (definition instanceof DecisionTask) {
        planItemTransformer = getPlanItemHandler(DecisionTask.class);
    } else if (definition instanceof Task) {
        planItemTransformer = getPlanItemHandler(Task.class);
    } else if (definition instanceof Stage) {
        planItemTransformer = getPlanItemHandler(Stage.class);
    } else if (definition instanceof Milestone) {
        planItemTransformer = getPlanItemHandler(Milestone.class);
    } else if (definition instanceof EventListener) {
        planItemTransformer = getPlanItemHandler(EventListener.class);
    }
    if (planItemTransformer != null) {
        CmmnActivity newActivity = planItemTransformer.handleElement(planItem, context);
        if (definition instanceof Stage) {
            Stage stage = (Stage) definition;
            transformStage(stage, newActivity);
            context.setParent(parent);
        } else if (definition instanceof HumanTask) {
            HumanTask humanTask = (HumanTask) definition;
            // According to the specification: A HumanTask can only contain
            // one planningTable, the XSD allows multiple planningTables!
            Collection<PlanningTable> planningTables = humanTask.getPlanningTables();
            for (PlanningTable planningTable : planningTables) {
                transformPlanningTable(planningTable, parent);
            }
        }
        for (CmmnTransformListener transformListener : transformListeners) {
            if (definition instanceof HumanTask) {
                transformListener.transformHumanTask(planItem, (HumanTask) definition, newActivity);
            } else if (definition instanceof ProcessTask) {
                transformListener.transformProcessTask(planItem, (ProcessTask) definition, newActivity);
            } else if (definition instanceof CaseTask) {
                transformListener.transformCaseTask(planItem, (CaseTask) definition, newActivity);
            } else if (definition instanceof DecisionTask) {
                transformListener.transformDecisionTask(planItem, (DecisionTask) definition, newActivity);
            } else if (definition instanceof Task) {
                transformListener.transformTask(planItem, (Task) definition, newActivity);
            } else if (definition instanceof Stage) {
                transformListener.transformStage(planItem, (Stage) definition, newActivity);
            } else if (definition instanceof Milestone) {
                transformListener.transformMilestone(planItem, (Milestone) definition, newActivity);
            } else if (definition instanceof EventListener) {
                transformListener.transformEventListener(planItem, (EventListener) definition, newActivity);
            }
        }
    }
}
Also used : HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) CaseTask(org.camunda.bpm.model.cmmn.instance.CaseTask) Task(org.camunda.bpm.model.cmmn.instance.Task) ProcessTask(org.camunda.bpm.model.cmmn.instance.ProcessTask) DecisionTask(org.camunda.bpm.model.cmmn.instance.DecisionTask) Milestone(org.camunda.bpm.model.cmmn.instance.Milestone) CaseTask(org.camunda.bpm.model.cmmn.instance.CaseTask) PlanningTable(org.camunda.bpm.model.cmmn.instance.PlanningTable) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ProcessTask(org.camunda.bpm.model.cmmn.instance.ProcessTask) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) ItemHandler(org.camunda.bpm.engine.impl.cmmn.handler.ItemHandler) DecisionTask(org.camunda.bpm.model.cmmn.instance.DecisionTask) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) Stage(org.camunda.bpm.model.cmmn.instance.Stage) Collection(java.util.Collection) EventListener(org.camunda.bpm.model.cmmn.instance.EventListener)

Example 18 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask 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 19 with HumanTask

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

the class GenerateIdTest method shouldGenerateIdsOnCreate.

@Test
public void shouldGenerateIdsOnCreate() {
    CmmnModelInstance modelInstance = Cmmn.createEmptyModel();
    Definitions definitions = modelInstance.newInstance(Definitions.class);
    assertThat(definitions.getId()).isNotNull();
    Case caseElement = modelInstance.newInstance(Case.class);
    assertThat(caseElement.getId()).isNotNull();
    CasePlanModel casePlanModel = modelInstance.newInstance(CasePlanModel.class);
    assertThat(casePlanModel.getId()).isNotNull();
    HumanTask humanTask = modelInstance.newInstance(HumanTask.class);
    assertThat(humanTask.getId()).isNotNull();
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) Definitions(org.camunda.bpm.model.cmmn.instance.Definitions) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) Case(org.camunda.bpm.model.cmmn.instance.Case) Test(org.junit.Test)

Example 20 with HumanTask

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

the class Cmmn10Test method shouldNotAbleToAddNewElement.

@Test
public void shouldNotAbleToAddNewElement() {
    CmmnModelInstance modelInstance = getCmmnModelInstance();
    CasePlanModel casePlanModel = modelInstance.getModelElementsByType(CasePlanModel.class).iterator().next();
    HumanTask humanTask = modelInstance.newInstance(HumanTask.class);
    casePlanModel.getPlanItemDefinitions().add(humanTask);
    try {
        Cmmn.writeModelToStream(System.out, modelInstance);
        fail("cannot save cmmn 1.0 model");
    } catch (Exception e) {
    // expected exception
    }
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) CmmnModelInstance(org.camunda.bpm.model.cmmn.CmmnModelInstance) Test(org.junit.Test)

Aggregations

HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)20 Test (org.junit.Test)9 Expression (org.camunda.bpm.engine.delegate.Expression)8 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)8 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)5 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)5 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)4 Case (org.camunda.bpm.model.cmmn.instance.Case)4 Stage (org.camunda.bpm.model.cmmn.instance.Stage)4 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)3 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)2 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)2 Task (org.camunda.bpm.model.cmmn.instance.Task)2 Collection (java.util.Collection)1 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 ItemHandler (org.camunda.bpm.engine.impl.cmmn.handler.ItemHandler)1 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)1 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)1 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)1 ScriptTaskListener (org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)1