Search in sources :

Example 1 with PlanItem

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();
}
Also used : CmmnElement(org.camunda.bpm.model.cmmn.instance.CmmnElement) SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Example 2 with PlanItem

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);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) 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 3 with PlanItem

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);
}
Also used : CasePlanModel(org.camunda.bpm.model.cmmn.instance.CasePlanModel) PlanItemDefinition(org.camunda.bpm.model.cmmn.instance.PlanItemDefinition) ModelElementInstance(org.camunda.bpm.model.xml.instance.ModelElementInstance) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) Case(org.camunda.bpm.model.cmmn.instance.Case) CmmnModelResource(org.camunda.bpm.model.cmmn.util.CmmnModelResource) Test(org.junit.Test)

Example 4 with PlanItem

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);
    }
}
Also used : CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnOnPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration) Sentry(org.camunda.bpm.model.cmmn.instance.Sentry) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) PlanItemTransition(org.camunda.bpm.model.cmmn.PlanItemTransition)

Example 5 with PlanItem

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

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