use of org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl in project camunda-engine-dmn by camunda.
the class DmnDecisionTableTransformHandler method createFromDecisionTable.
protected DmnDecisionTableImpl createFromDecisionTable(DmnElementTransformContext context, DecisionTable decisionTable) {
DmnDecisionTableImpl dmnDecisionTable = createDmnElement(context, decisionTable);
dmnDecisionTable.setHitPolicyHandler(getHitPolicyHandler(context, decisionTable, dmnDecisionTable));
return dmnDecisionTable;
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method transformDecision.
protected DmnDecisionImpl transformDecision(Decision decision) {
DmnElementTransformHandler<Decision, DmnDecisionImpl> handler = handlerRegistry.getHandler(Decision.class);
DmnDecisionImpl dmnDecision = handler.handleElement(this, decision);
this.decision = dmnDecision;
// validate decision id
if (dmnDecision.getKey() == null) {
throw LOG.decisionIdIsMissing(dmnDecision);
}
Expression expression = decision.getExpression();
if (expression == null) {
LOG.decisionWithoutExpression(decision);
return null;
}
if (expression instanceof DecisionTable) {
DmnDecisionTableImpl dmnDecisionTable = transformDecisionTable((DecisionTable) expression);
dmnDecision.setDecisionLogic(dmnDecisionTable);
} else if (expression instanceof LiteralExpression) {
DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = transformDecisionLiteralExpression(decision, (LiteralExpression) expression);
dmnDecision.setDecisionLogic(dmnDecisionLiteralExpression);
} else {
LOG.decisionTypeNotSupported(expression, decision);
return null;
}
return dmnDecision;
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl in project camunda-engine-dmn by camunda.
the class DmnDecisionTableEvaluationListenerTest method setDecisionTableHitPolicy.
// helper
public void setDecisionTableHitPolicy(HitPolicy hitPolicy, BuiltinAggregator aggregator) {
DmnHitPolicyHandler handler = hitPolicyHandlerRegistry.getHandler(hitPolicy, aggregator);
assertThat(handler).isNotNull();
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) this.decision.getDecisionLogic();
decisionTable.setHitPolicyHandler(handler);
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldTransformInputs.
@Test
public void shouldTransformInputs() {
DmnDecisionImpl decisionEntity = (DmnDecisionImpl) parseDecisionFromFile("decision1", TRANSFORM_DMN);
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decisionEntity.getDecisionLogic();
List<DmnDecisionTableInputImpl> inputs = decisionTable.getInputs();
assertThat(inputs).hasSize(2);
DmnDecisionTableInputImpl input = inputs.get(0);
assertThat(input.getId()).isEqualTo("input1");
assertThat(input.getName()).isEqualTo("camunda");
assertThat(input.getInputVariable()).isEqualTo("camunda");
DmnExpressionImpl inputExpression = input.getExpression();
assertThat(inputExpression).isNotNull();
assertThat(inputExpression.getId()).isEqualTo("inputExpression");
assertThat(inputExpression.getName()).isNull();
assertThat(inputExpression.getExpressionLanguage()).isEqualTo("camunda");
assertThat(inputExpression.getExpression()).isEqualTo("camunda");
assertThat(inputExpression.getTypeDefinition()).isNotNull();
assertThat(inputExpression.getTypeDefinition().getTypeName()).isEqualTo("string");
input = inputs.get(1);
assertThat(input.getId()).isEqualTo("input2");
assertThat(input.getName()).isNull();
assertThat(input.getInputVariable()).isEqualTo(DmnDecisionTableInputImpl.DEFAULT_INPUT_VARIABLE_NAME);
inputExpression = input.getExpression();
assertThat(inputExpression).isNotNull();
assertThat(inputExpression.getId()).isNull();
assertThat(inputExpression.getName()).isNull();
assertThat(inputExpression.getExpressionLanguage()).isNull();
assertThat(inputExpression.getExpression()).isNull();
assertThat(inputExpression.getTypeDefinition()).isNotNull();
assertThat(inputExpression.getTypeDefinition()).isEqualTo(new DefaultTypeDefinition());
}
use of org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl in project camunda-engine-dmn by camunda.
the class DmnTransformTest method shouldTransformDecisionTables.
@Test
public void shouldTransformDecisionTables() {
List<DmnDecision> decisions = parseDecisionsFromFile(TRANSFORM_DMN);
DmnDecision decision = decisions.get(0);
assertThat(decision.isDecisionTable()).isTrue();
assertThat(decision).isInstanceOf(DmnDecisionImpl.class);
DmnDecisionTableImpl decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
assertThat(decisionTable.getHitPolicyHandler()).isInstanceOf(UniqueHitPolicyHandler.class);
decision = decisions.get(1);
assertThat(decision.isDecisionTable()).isTrue();
assertThat(decision).isInstanceOf(DmnDecisionImpl.class);
decisionTable = (DmnDecisionTableImpl) decision.getDecisionLogic();
assertThat(decisionTable.getHitPolicyHandler()).isInstanceOf(FirstHitPolicyHandler.class);
}
Aggregations