Search in sources :

Example 6 with DmnDecisionTableImpl

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;
}
Also used : DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)

Example 7 with DmnDecisionTableImpl

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;
}
Also used : DecisionTable(org.camunda.bpm.model.dmn.instance.DecisionTable) DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) LiteralExpression(org.camunda.bpm.model.dmn.instance.LiteralExpression) InputExpression(org.camunda.bpm.model.dmn.instance.InputExpression) Expression(org.camunda.bpm.model.dmn.instance.Expression) DmnDecisionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl) LiteralExpression(org.camunda.bpm.model.dmn.instance.LiteralExpression) DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Decision(org.camunda.bpm.model.dmn.instance.Decision)

Example 8 with DmnDecisionTableImpl

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);
}
Also used : DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) DmnHitPolicyHandler(org.camunda.bpm.dmn.engine.impl.spi.hitpolicy.DmnHitPolicyHandler)

Example 9 with DmnDecisionTableImpl

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());
}
Also used : DmnDecisionTableInputImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl) DefaultTypeDefinition(org.camunda.bpm.dmn.engine.impl.type.DefaultTypeDefinition) DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) DmnExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl) DmnDecisionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Example 10 with DmnDecisionTableImpl

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);
}
Also used : DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Test(org.junit.Test) DmnEngineTest(org.camunda.bpm.dmn.engine.test.DmnEngineTest)

Aggregations

DmnDecisionTableImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)10 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)5 Test (org.junit.Test)5 DmnDecisionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl)4 DmnDecisionTableInputImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableInputImpl)3 DmnDecisionTableRuleImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableRuleImpl)3 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)3 DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)2 DmnDecisionTableOutputImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableOutputImpl)2 DefaultTypeDefinition (org.camunda.bpm.dmn.engine.impl.type.DefaultTypeDefinition)2 DecisionTable (org.camunda.bpm.model.dmn.instance.DecisionTable)2 HashSet (java.util.HashSet)1 DmnDecisionTableEvaluationListener (org.camunda.bpm.dmn.engine.delegate.DmnDecisionTableEvaluationListener)1 DmnDecisionLiteralExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)1 DmnDecisionTableEvaluationEventImpl (org.camunda.bpm.dmn.engine.impl.delegate.DmnDecisionTableEvaluationEventImpl)1 DmnHitPolicyHandler (org.camunda.bpm.dmn.engine.impl.spi.hitpolicy.DmnHitPolicyHandler)1 DecisionResource (org.camunda.bpm.dmn.engine.test.DecisionResource)1 Decision (org.camunda.bpm.model.dmn.instance.Decision)1 Expression (org.camunda.bpm.model.dmn.instance.Expression)1 Input (org.camunda.bpm.model.dmn.instance.Input)1