use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.
the class PlanItemImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(PlanItem.class, CMMN_ELEMENT_PLAN_ITEM).namespaceUri(CMMN11_NS).extendsType(CmmnElement.class).instanceProvider(new ModelTypeInstanceProvider<PlanItem>() {
public PlanItem newInstance(ModelTypeInstanceContext instanceContext) {
return new PlanItemImpl(instanceContext);
}
});
nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME).build();
planItemDefinitionRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_DEFINITION_REF).idAttributeReference(PlanItemDefinition.class).build();
entryCriteriaRefCollection = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_ENTRY_CRITERIA_REFS).namespace(CMMN10_NS).idAttributeReferenceCollection(Sentry.class, CmmnAttributeElementReferenceCollection.class).build();
exitCriteriaRefCollection = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_EXIT_CRITERIA_REFS).namespace(CMMN10_NS).idAttributeReferenceCollection(Sentry.class, CmmnAttributeElementReferenceCollection.class).build();
SequenceBuilder sequenceBuilder = typeBuilder.sequence();
itemControlChild = sequenceBuilder.element(ItemControl.class).build();
entryCriterionCollection = sequenceBuilder.elementCollection(EntryCriterion.class).build();
exitCriterionCollection = sequenceBuilder.elementCollection(ExitCriterion.class).build();
typeBuilder.build();
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.
the class CreateModelTest method createCaseWithOneHumanTask.
@Test
public void createCaseWithOneHumanTask() {
// 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 elements
HumanTask humanTask = createElement(casePlanModel, "HumanTask_1", HumanTask.class);
// create a plan item
PlanItem planItem = createElement(casePlanModel, "PlanItem_1", PlanItem.class);
// set definition to human task
planItem.setDefinition(humanTask);
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-cmmn-model by camunda.
the class SimpleTest method shouldGetElements.
@Test
@CmmnModelResource
public void shouldGetElements() {
ModelElementInstance modelElementById = cmmnModelInstance.getModelElementById("Case_1");
assertThat(modelElementById).isNotNull();
Collection<Case> caseElements = cmmnModelInstance.getDefinitions().getCases();
assertThat(caseElements).hasSize(1);
Case caseElement = caseElements.iterator().next();
assertThat(caseElement.getId()).isEqualTo("Case_1");
assertThat(caseElement.getName()).isNull();
CasePlanModel casePlanModel = caseElement.getCasePlanModel();
assertThat(casePlanModel).isNotNull();
assertThat(casePlanModel.getId()).isEqualTo("CasePlanModel_1");
Collection<PlanItemDefinition> planItemDefinitions = casePlanModel.getPlanItemDefinitions();
assertThat(planItemDefinitions).hasSize(1);
PlanItemDefinition planItemDefinition = planItemDefinitions.iterator().next();
assertThat(planItemDefinition).isInstanceOf(HumanTask.class);
assertThat(planItemDefinition.getId()).isEqualTo("HumanTask_1");
assertThat(planItemDefinition.getName()).isEqualTo("A HumanTask");
Collection<PlanItem> planItems = casePlanModel.getPlanItems();
PlanItem planItem = planItems.iterator().next();
assertThat(planItem.getId()).isEqualTo("PI_HumanTask_1");
assertThat(planItem.getDefinition()).isEqualTo(planItemDefinition);
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.
the class SentryHandler method initializeOnPart.
protected void initializeOnPart(PlanItemOnPart onPart, Sentry sentry, CmmnHandlerContext context) {
CmmnActivity parent = context.getParent();
String sentryId = sentry.getId();
CmmnSentryDeclaration sentryDeclaration = parent.getSentry(sentryId);
PlanItem source = onPart.getSource();
PlanItemTransition standardEvent = onPart.getStandardEvent();
if (source != null && standardEvent != null) {
CmmnOnPartDeclaration onPartDeclaration = new CmmnOnPartDeclaration();
// initialize standardEvent
String standardEventName = standardEvent.name();
onPartDeclaration.setStandardEvent(standardEventName);
// initialize sourceRef
String sourceId = source.getId();
CmmnActivity sourceActivity = parent.findActivity(sourceId);
if (sourceActivity != null) {
onPartDeclaration.setSource(sourceActivity);
}
// initialize sentryRef
Sentry sentryRef = onPart.getSentry();
if (sentryRef != null) {
String sentryRefId = sentryRef.getId();
CmmnSentryDeclaration sentryRefDeclaration = parent.getSentry(sentryRefId);
onPartDeclaration.setSentry(sentryRefDeclaration);
}
// add onPartDeclaration to sentryDeclaration
sentryDeclaration.addOnPart(onPartDeclaration);
}
}
use of org.camunda.bpm.model.cmmn.instance.PlanItem in project camunda-bpm-platform by camunda.
the class CmmnTransformerTest method testActivityTreeWithOneStageAndNestedHumanTasks.
/**
* +-----------------+ +-----------------+
* | Case1 \ | aCaseDefinition |
* +-------------------+-----------------+ +-----------------+
* | | |
* | +------------------------+ | +-----------------+
* | / X \ | | aCasePlanModel |
* | + +-------+ +-------+ + | +-----------------+
* | | | A | | B | | | ==> |
* | + +-------+ +-------+ + | +-----------------+
* | \ / | | X |
* | +------------------------+ | +-----------------+
* | | / \
* +-------------------------------------+ / \
* +-----------------+ +-----------------+
* | A | | B |
* +-----------------+ +-----------------+
*/
@Test
public void testActivityTreeWithOneStageAndNestedHumanTasks() {
// given
Stage stage = createElement(casePlanModel, "X", Stage.class);
HumanTask humanTaskA = createElement(casePlanModel, "A", HumanTask.class);
HumanTask humanTaskB = createElement(casePlanModel, "B", HumanTask.class);
PlanItem planItemX = createElement(casePlanModel, "PI_X", PlanItem.class);
PlanItem planItemA = createElement(stage, "PI_A", PlanItem.class);
PlanItem planItemB = createElement(stage, "PI_B", PlanItem.class);
planItemX.setDefinition(stage);
planItemA.setDefinition(humanTaskA);
planItemB.setDefinition(humanTaskB);
// 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(1, children.size());
CmmnActivity planItemStage = children.get(0);
assertEquals(planItemX.getId(), planItemStage.getId());
children = planItemStage.getActivities();
assertEquals(2, children.size());
CmmnActivity childPlanItem = children.get(0);
assertEquals(planItemA.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
childPlanItem = children.get(1);
assertEquals(planItemB.getId(), childPlanItem.getId());
assertTrue(childPlanItem.getActivities().isEmpty());
}
Aggregations