use of org.camunda.bpm.model.cmmn.instance.PlanItemControl 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);
}
}
use of org.camunda.bpm.model.cmmn.instance.PlanItemControl 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);
}
}
use of org.camunda.bpm.model.cmmn.instance.PlanItemControl 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);
}
use of org.camunda.bpm.model.cmmn.instance.PlanItemControl in project camunda-bpm-platform by camunda.
the class HumanTaskDicretionaryItemHandlerTest method testManualActivationRuleByDefaultPlanItemControl.
@Test
public void testManualActivationRuleByDefaultPlanItemControl() {
// given
PlanItemControl defaultControl = createElement(humanTask, "ItemControl_1", DefaultControl.class);
ManualActivationRule manualActivationRule = createElement(defaultControl, "ManualActivationRule_1", ManualActivationRule.class);
ConditionExpression expression = createElement(manualActivationRule, "Expression_1", ConditionExpression.class);
expression.setText("${true}");
Cmmn.validateModel(modelInstance);
// when
CmmnActivity newActivity = handler.handleElement(discretionaryItem, context);
// then
Object rule = newActivity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE);
assertNotNull(rule);
assertTrue(rule instanceof CaseControlRule);
}
use of org.camunda.bpm.model.cmmn.instance.PlanItemControl 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));
}
Aggregations