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());
}
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);
}
}
}
}
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);
}
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();
}
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
}
}
Aggregations