Search in sources :

Example 1 with CaseControlRule

use of org.camunda.bpm.engine.impl.cmmn.CaseControlRule 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 CaseControlRule

use of org.camunda.bpm.engine.impl.cmmn.CaseControlRule 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 3 with CaseControlRule

use of org.camunda.bpm.engine.impl.cmmn.CaseControlRule in project camunda-bpm-platform by camunda.

the class PlanItemDefinitionActivityBehavior method evaluateRequiredRule.

// rules (required and repetition rule) /////////////////////////////////////////
protected void evaluateRequiredRule(CmmnActivityExecution execution) {
    CmmnActivity activity = execution.getActivity();
    Object requiredRule = activity.getProperty(PROPERTY_REQUIRED_RULE);
    if (requiredRule != null) {
        CaseControlRule rule = (CaseControlRule) requiredRule;
        boolean required = rule.evaluate(execution);
        execution.setRequired(required);
    }
}
Also used : CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule)

Example 4 with CaseControlRule

use of org.camunda.bpm.engine.impl.cmmn.CaseControlRule in project camunda-bpm-platform by camunda.

the class StageOrTaskActivityBehavior method evaluateManualActivationRule.

// manual activation rule //////////////////////////////////////////////
protected boolean evaluateManualActivationRule(CmmnActivityExecution execution) {
    boolean manualActivation = false;
    CmmnActivity activity = execution.getActivity();
    Object manualActivationRule = activity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE);
    if (manualActivationRule != null) {
        CaseControlRule rule = (CaseControlRule) manualActivationRule;
        manualActivation = rule.evaluate(execution);
    }
    return manualActivation;
}
Also used : CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) CaseControlRule(org.camunda.bpm.engine.impl.cmmn.CaseControlRule)

Example 5 with CaseControlRule

use of org.camunda.bpm.engine.impl.cmmn.CaseControlRule 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)

Aggregations

CaseControlRule (org.camunda.bpm.engine.impl.cmmn.CaseControlRule)50 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)47 PlanItemControl (org.camunda.bpm.model.cmmn.instance.PlanItemControl)47 ConditionExpression (org.camunda.bpm.model.cmmn.instance.ConditionExpression)45 Test (org.junit.Test)44 ItemControl (org.camunda.bpm.model.cmmn.instance.ItemControl)22 RequiredRule (org.camunda.bpm.model.cmmn.instance.RequiredRule)21 ManualActivationRule (org.camunda.bpm.model.cmmn.instance.ManualActivationRule)17 RepetitionRule (org.camunda.bpm.model.cmmn.instance.RepetitionRule)9 CamundaString (org.camunda.bpm.model.cmmn.instance.camunda.CamundaString)1