Search in sources :

Example 1 with RepetitionRule

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

the class ItemHandler method initializeRepetitionRule.

protected void initializeRepetitionRule(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemControl itemControl = getItemControl(element);
    PlanItemControl defaultControl = getDefaultControl(element);
    RepetitionRule repetitionRule = null;
    if (itemControl != null) {
        repetitionRule = itemControl.getRepetitionRule();
    }
    if (repetitionRule == null && defaultControl != null) {
        repetitionRule = defaultControl.getRepetitionRule();
    }
    if (repetitionRule != null) {
        ConditionExpression condition = repetitionRule.getCondition();
        CaseControlRule caseRule = initializeCaseControlRule(condition, context);
        activity.setProperty(PROPERTY_REPETITION_RULE, caseRule);
        List<String> events = Arrays.asList(TERMINATE, COMPLETE);
        String repeatOnStandardEvent = repetitionRule.getCamundaRepeatOnStandardEvent();
        if (repeatOnStandardEvent != null && !repeatOnStandardEvent.isEmpty()) {
            events = Arrays.asList(repeatOnStandardEvent);
        }
        activity.getProperties().set(CmmnProperties.REPEAT_ON_STANDARD_EVENTS, events);
    }
}
Also used : RepetitionRule(org.camunda.bpm.model.cmmn.instance.RepetitionRule) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) CamundaString(org.camunda.bpm.model.cmmn.instance.camunda.CamundaString) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule)

Example 2 with RepetitionRule

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

the class HumanTaskPlanItemHandlerTest 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 3 with RepetitionRule

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

the class HumanTaskPlanItemHandlerTest method testRepetitionRuleStandardEventsByDefaultPlanItemControl.

@Test
public void testRepetitionRuleStandardEventsByDefaultPlanItemControl() {
    // given
    PlanItemControl defaultControl = createElement(humanTask, "DefaultControl_1", DefaultControl.class);
    RepetitionRule repetitionRule = createElement(defaultControl, "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) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 4 with RepetitionRule

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

the class HumanTaskPlanItemHandlerTest 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 5 with RepetitionRule

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

the class MilestonePlanItemHandlerTest method testRepetitionRuleByDefaultPlanItemControl.

@Test
public void testRepetitionRuleByDefaultPlanItemControl() {
    // given
    PlanItemControl defaultControl = createElement(milestone, "DefaultControl_1", DefaultControl.class);
    RepetitionRule repetitionRule = createElement(defaultControl, "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) ConditionExpression(org.camunda.bpm.model.cmmn.instance.ConditionExpression) PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule) Test(org.junit.Test)

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