Search in sources :

Example 26 with RepetitionRule

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

the class StagePlanItemHandlerTest method testRepetitionRule.

@Test
public void testRepetitionRule() {
    // given
    ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
    RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
    ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    Object rule = newActivity.getProperty(PROPERTY_REPETITION_RULE);
    assertNotNull(rule);
    assertTrue(rule instanceof CaseControlRule);
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) ItemControl(org.camunda.bpm.model.cmmn.instance.ItemControl) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule) Test(org.junit.Test)

Example 27 with RepetitionRule

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

the class StagePlanItemHandlerTest method testRepetitionRuleCustomStandardEvents.

@Test
public void testRepetitionRuleCustomStandardEvents() {
    // given
    ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
    RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
    ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
    assertNotNull(events);
    assertEquals(1, events.size());
    assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) ItemControl(org.camunda.bpm.model.cmmn.instance.ItemControl) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 28 with RepetitionRule

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

the class DecisionTaskPlanItemHandlerTest method testRepetitionRuleCustomStandardEvents.

@Test
public void testRepetitionRuleCustomStandardEvents() {
    // given
    ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
    RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
    ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
    assertNotNull(events);
    assertEquals(1, events.size());
    assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) ItemControl(org.camunda.bpm.model.cmmn.instance.ItemControl) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 29 with RepetitionRule

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

the class DecisionTaskPlanItemHandlerTest method testRepetitionRuleStandardEvents.

@Test
public void testRepetitionRuleStandardEvents() {
    // given
    ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
    RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
    ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
    assertNotNull(events);
    assertEquals(2, events.size());
    assertTrue(events.contains(CaseExecutionListener.COMPLETE));
    assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) ItemControl(org.camunda.bpm.model.cmmn.instance.ItemControl) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 30 with RepetitionRule

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

the class RepetitionRuleImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(RepetitionRule.class, CMMN_ELEMENT_REPETITION_RULE).namespaceUri(CMMN11_NS).extendsType(CmmnElement.class).instanceProvider(new ModelTypeInstanceProvider<RepetitionRule>() {

        public RepetitionRule newInstance(ModelTypeInstanceContext instanceContext) {
            return new RepetitionRuleImpl(instanceContext);
        }
    });
    nameAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_NAME).build();
    contextRefAttribute = typeBuilder.stringAttribute(CMMN_ATTRIBUTE_CONTEXT_REF).idAttributeReference(CaseFileItem.class).build();
    /**
     * Camunda extensions
     */
    camundaRepeatOnStandardEventAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_REPEAT_ON_STANDARD_EVENT).namespace(CAMUNDA_NS).build();
    SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    conditionChild = sequenceBuilder.element(ConditionExpression.class).build();
    typeBuilder.build();
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) 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) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Aggregations

RepetitionRule (org.camunda.bpm.model.cmmn.instance.RepetitionRule)30 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)29 PlanItemControl (org.camunda.bpm.model.cmmn.instance.PlanItemControl)29 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)28 Test (org.junit.Test)28 ItemControl (org.camunda.bpm.model.cmmn.instance.ItemControl)14 CaseControlRule (org.camunda.bpm.engine.impl.cmmn.CaseControlRule)9 CmmnElement (org.camunda.bpm.model.cmmn.instance.CmmnElement)1 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1