Search in sources :

Example 1 with RequiredRule

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

the class ItemHandler method initializeRequiredRule.

protected void initializeRequiredRule(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    PlanItemControl itemControl = getItemControl(element);
    PlanItemControl defaultControl = getDefaultControl(element);
    RequiredRule requiredRule = null;
    if (itemControl != null) {
        requiredRule = itemControl.getRequiredRule();
    }
    if (requiredRule == null && defaultControl != null) {
        requiredRule = defaultControl.getRequiredRule();
    }
    if (requiredRule != null) {
        CaseControlRule caseRule = initializeCaseControlRule(requiredRule.getCondition(), context);
        activity.setProperty(PROPERTY_REQUIRED_RULE, caseRule);
    }
}
Also used : PlanItemControl(org.camunda.bpm.model.cmmn.instance.PlanItemControl) RequiredRule(org.camunda.bpm.model.cmmn.instance.RequiredRule) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule)

Example 2 with RequiredRule

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

the class HumanTaskDicretionaryItemHandlerTest method testRequiredRule.

@Test
public void testRequiredRule() {
    // given
    ItemControl itemControl = createElement(discretionaryItem, "ItemControl_1", ItemControl.class);
    RequiredRule requiredRule = createElement(itemControl, "RequiredRule_1", RequiredRule.class);
    ConditionExpression expression = createElement(requiredRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(discretionaryItem, context);
    // then
    Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);
    assertNotNull(rule);
    assertTrue(rule instanceof CaseControlRule);
}
Also used : 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) RequiredRule(org.camunda.bpm.model.cmmn.instance.RequiredRule) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule) Test(org.junit.Test)

Example 3 with RequiredRule

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

the class HumanTaskDicretionaryItemHandlerTest method testRequiredRuleByDefaultPlanItemControl.

@Test
public void testRequiredRuleByDefaultPlanItemControl() {
    // given
    PlanItemControl defaultControl = createElement(humanTask, "ItemControl_1", DefaultControl.class);
    RequiredRule requiredRule = createElement(defaultControl, "RequiredRule_1", RequiredRule.class);
    ConditionExpression expression = createElement(requiredRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(discretionaryItem, context);
    // then
    Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);
    assertNotNull(rule);
    assertTrue(rule instanceof CaseControlRule);
}
Also used : 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) RequiredRule(org.camunda.bpm.model.cmmn.instance.RequiredRule) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule) Test(org.junit.Test)

Example 4 with RequiredRule

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

the class MilestoneDiscretionaryItemHandlerTest method testRequiredRule.

@Test
public void testRequiredRule() {
    // given
    ItemControl itemControl = createElement(discretionaryItem, "ItemControl_1", ItemControl.class);
    RequiredRule requiredRule = createElement(itemControl, "RequiredRule_1", RequiredRule.class);
    ConditionExpression expression = createElement(requiredRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(discretionaryItem, context);
    // then
    Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);
    assertNotNull(rule);
    assertTrue(rule instanceof CaseControlRule);
}
Also used : 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) RequiredRule(org.camunda.bpm.model.cmmn.instance.RequiredRule) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule) Test(org.junit.Test)

Example 5 with RequiredRule

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

the class MilestonePlanItemHandlerTest method testRequiredRuleByDefaultPlanItemControl.

@Test
public void testRequiredRuleByDefaultPlanItemControl() {
    // given
    PlanItemControl defaultControl = createElement(milestone, "ItemControl_1", DefaultControl.class);
    RequiredRule requiredRule = createElement(defaultControl, "RequiredRule_1", RequiredRule.class);
    ConditionExpression expression = createElement(requiredRule, "Expression_1", ConditionExpression.class);
    expression.setText("${true}");
    Cmmn.validateModel(modelInstance);
    // when
    CmmnActivity newActivity = handler.handleElement(planItem, context);
    // then
    Object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);
    assertNotNull(rule);
    assertTrue(rule instanceof CaseControlRule);
}
Also used : 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) RequiredRule(org.camunda.bpm.model.cmmn.instance.RequiredRule) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule) Test(org.junit.Test)

Aggregations

RequiredRule (org.camunda.bpm.model.cmmn.instance.RequiredRule)22 CaseControlRule (org.camunda.bpm.engine.impl.cmmn.CaseControlRule)21 PlanItemControl (org.camunda.bpm.model.cmmn.instance.PlanItemControl)21 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)20 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)20 Test (org.junit.Test)20 ItemControl (org.camunda.bpm.model.cmmn.instance.ItemControl)10 CmmnElement (org.camunda.bpm.model.cmmn.instance.CmmnElement)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