Search in sources :

Example 1 with DmnVariableImpl

use of org.camunda.bpm.dmn.engine.impl.DmnVariableImpl in project camunda-engine-dmn by camunda.

the class DmnVariableTransformHandler method createFromVariable.

protected DmnVariableImpl createFromVariable(DmnElementTransformContext context, Variable variable) {
    DmnVariableImpl dmnVariable = createDmnElement(context, variable);
    dmnVariable.setId(variable.getId());
    dmnVariable.setName(variable.getName());
    DmnTypeDefinition typeDefinition = createTypeDefinition(context, variable);
    dmnVariable.setTypeDefinition(typeDefinition);
    return dmnVariable;
}
Also used : DmnVariableImpl(org.camunda.bpm.dmn.engine.impl.DmnVariableImpl) DmnTypeDefinition(org.camunda.bpm.dmn.engine.impl.spi.type.DmnTypeDefinition)

Example 2 with DmnVariableImpl

use of org.camunda.bpm.dmn.engine.impl.DmnVariableImpl in project camunda-engine-dmn by camunda.

the class DecisionLiteralExpressionEvaluationHandler method evaluate.

@Override
public DmnDecisionLogicEvaluationEvent evaluate(DmnDecision decision, VariableContext variableContext) {
    DmnDecisionLiteralExpressionEvaluationEventImpl evaluationResult = new DmnDecisionLiteralExpressionEvaluationEventImpl();
    evaluationResult.setDecision(decision);
    evaluationResult.setExecutedDecisionElements(1);
    DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = (DmnDecisionLiteralExpressionImpl) decision.getDecisionLogic();
    DmnVariableImpl variable = dmnDecisionLiteralExpression.getVariable();
    DmnExpressionImpl expression = dmnDecisionLiteralExpression.getExpression();
    Object evaluateExpression = evaluateLiteralExpression(expression, variableContext);
    TypedValue typedValue = variable.getTypeDefinition().transform(evaluateExpression);
    evaluationResult.setOutputValue(typedValue);
    evaluationResult.setOutputName(variable.getName());
    return evaluationResult;
}
Also used : DmnVariableImpl(org.camunda.bpm.dmn.engine.impl.DmnVariableImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) DmnDecisionLiteralExpressionEvaluationEventImpl(org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionLiteralExpressionEvaluationEventImpl) DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

Example 3 with DmnVariableImpl

use of org.camunda.bpm.dmn.engine.impl.DmnVariableImpl in project camunda-engine-dmn by camunda.

the class DmnTransformTest method shouldTransformDecisionWithLiteralExpression.

@Test
public void shouldTransformDecisionWithLiteralExpression() {
    List<DmnDecision> decisions = parseDecisionsFromFile(DECISION_WITH_LITERAL_EXPRESSION_DMN);
    assertThat(decisions).hasSize(1);
    DmnDecision decision = decisions.get(0);
    assertThat(decision).isNotNull();
    assertThat(decision.getKey()).isEqualTo("decision");
    assertThat(decision.getName()).isEqualTo("Decision");
    assertThat(decision.getDecisionLogic()).isNotNull().isInstanceOf(DmnDecisionLiteralExpressionImpl.class);
    DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = (DmnDecisionLiteralExpressionImpl) decision.getDecisionLogic();
    DmnVariableImpl variable = dmnDecisionLiteralExpression.getVariable();
    assertThat(variable).isNotNull();
    assertThat(variable.getId()).isEqualTo("v1");
    assertThat(variable.getName()).isEqualTo("c");
    assertThat(variable.getTypeDefinition()).isNotNull();
    assertThat(variable.getTypeDefinition().getTypeName()).isEqualTo("integer");
    DmnExpressionImpl dmnExpression = dmnDecisionLiteralExpression.getExpression();
    assertThat(dmnExpression).isNotNull();
    assertThat(dmnExpression.getId()).isEqualTo("e1");
    assertThat(dmnExpression.getExpressionLanguage()).isEqualTo("groovy");
    assertThat(dmnExpression.getExpression()).isEqualTo("a + b");
    assertThat(dmnExpression.getTypeDefinition()).isNull();
}
Also used : DmnVariableImpl(org.camunda.bpm.dmn.engine.impl.DmnVariableImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 4 with DmnVariableImpl

use of org.camunda.bpm.dmn.engine.impl.DmnVariableImpl in project camunda-engine-dmn by camunda.

the class DefaultDmnTransform method transformDecisionLiteralExpression.

protected DmnDecisionLiteralExpressionImpl transformDecisionLiteralExpression(Decision decision, LiteralExpression literalExpression) {
    DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = new DmnDecisionLiteralExpressionImpl();
    Variable variable = decision.getVariable();
    if (variable == null) {
        throw LOG.decisionVariableIsMissing(decision.getId());
    }
    DmnVariableImpl dmnVariable = transformVariable(variable);
    dmnDecisionLiteralExpression.setVariable(dmnVariable);
    DmnExpressionImpl dmnLiteralExpression = transformLiteralExpression(literalExpression);
    dmnDecisionLiteralExpression.setExpression(dmnLiteralExpression);
    return dmnDecisionLiteralExpression;
}
Also used : DmnVariableImpl(org.camunda.bpm.dmn.engine.impl.DmnVariableImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) Variable(org.camunda.bpm.model.dmn.instance.Variable) DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)

Aggregations

DmnVariableImpl (org.camunda.bpm.dmn.engine.impl.DmnVariableImpl)4 DmnDecisionLiteralExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)3 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)3 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)1 DmnDecisionLiteralExpressionEvaluationEventImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionLiteralExpressionEvaluationEventImpl)1 DmnTypeDefinition (org.camunda.bpm.dmn.engine.impl.spi.type.DmnTypeDefinition)1 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)1 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)1 Variable (org.camunda.bpm.model.dmn.instance.Variable)1 Test (org.junit.Test)1