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;
}
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;
}
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();
}
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;
}
Aggregations