Search in sources :

Example 1 with DecisionRefExpression

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

the class DecisionTaskPlanItemHandlerTest method testConstantDecisionRefExpression.

@Test
public void testConstantDecisionRefExpression() {
    // given:
    String decision = "aDecisionToCall";
    DecisionRefExpression decisionRefExpression = createElement(decisionTask, DecisionRefExpression.class);
    decisionRefExpression.setText(decision);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
    BaseCallableElement callableElement = behavior.getCallableElement();
    ParameterValueProvider decisionRefValueProvider = callableElement.getDefinitionKeyValueProvider();
    assertNotNull(decisionRefValueProvider);
    assertTrue(decisionRefValueProvider instanceof ConstantValueProvider);
    ConstantValueProvider valueProvider = (ConstantValueProvider) decisionRefValueProvider;
    assertEquals(decision, valueProvider.getValue(null));
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) DecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior) DmnDecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior) BaseCallableElement(org.camunda.bpm.engine.impl.core.model.BaseCallableElement) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) ConstantValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider) DecisionRefExpression(org.camunda.bpm.model.cmmn.instance.DecisionRefExpression) Test(org.junit.Test)

Example 2 with DecisionRefExpression

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

the class DecisionTaskPlanItemHandlerTest method testExpressionDecisionRefExpression.

@Test
public void testExpressionDecisionRefExpression() {
    // given:
    String decision = "${aDecisionToCall}";
    DecisionRefExpression decisionRefExpression = createElement(decisionTask, DecisionRefExpression.class);
    decisionRefExpression.setText(decision);
    // when
    CmmnActivity activity = handler.handleElement(planItem, context);
    // then
    DecisionTaskActivityBehavior behavior = (DecisionTaskActivityBehavior) activity.getActivityBehavior();
    BaseCallableElement callableElement = behavior.getCallableElement();
    ParameterValueProvider caseRefValueProvider = callableElement.getDefinitionKeyValueProvider();
    assertNotNull(caseRefValueProvider);
    assertTrue(caseRefValueProvider instanceof ElValueProvider);
    ElValueProvider valueProvider = (ElValueProvider) caseRefValueProvider;
    assertEquals(decision, valueProvider.getExpression().getExpressionText());
}
Also used : ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) DecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior) DmnDecisionTaskActivityBehavior(org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior) BaseCallableElement(org.camunda.bpm.engine.impl.core.model.BaseCallableElement) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) DecisionRefExpression(org.camunda.bpm.model.cmmn.instance.DecisionRefExpression) Test(org.junit.Test)

Example 3 with DecisionRefExpression

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

the class DecisionTaskItemHandler method getDefinitionKey.

protected String getDefinitionKey(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
    DecisionTask definition = getDefinition(element);
    String decision = definition.getDecision();
    if (decision == null) {
        DecisionRefExpression decisionExpression = definition.getDecisionExpression();
        if (decisionExpression != null) {
            decision = decisionExpression.getText();
        }
    }
    return decision;
}
Also used : DecisionTask(org.camunda.bpm.model.cmmn.instance.DecisionTask) DecisionRefExpression(org.camunda.bpm.model.cmmn.instance.DecisionRefExpression)

Example 4 with DecisionRefExpression

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

the class DecisionRefExpressionImpl method registerType.

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

        public DecisionRefExpression newInstance(ModelTypeInstanceContext instanceContext) {
            return new DecisionRefExpressionImpl(instanceContext);
        }
    });
    typeBuilder.build();
}
Also used : DecisionRefExpression(org.camunda.bpm.model.cmmn.instance.DecisionRefExpression) Expression(org.camunda.bpm.model.cmmn.instance.Expression) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext) DecisionRefExpression(org.camunda.bpm.model.cmmn.instance.DecisionRefExpression)

Aggregations

DecisionRefExpression (org.camunda.bpm.model.cmmn.instance.DecisionRefExpression)4 DecisionTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.DecisionTaskActivityBehavior)2 DmnDecisionTaskActivityBehavior (org.camunda.bpm.engine.impl.cmmn.behavior.DmnDecisionTaskActivityBehavior)2 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)2 BaseCallableElement (org.camunda.bpm.engine.impl.core.model.BaseCallableElement)2 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)2 Test (org.junit.Test)2 ConstantValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider)1 ElValueProvider (org.camunda.bpm.engine.impl.el.ElValueProvider)1 DecisionTask (org.camunda.bpm.model.cmmn.instance.DecisionTask)1 Expression (org.camunda.bpm.model.cmmn.instance.Expression)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1