Search in sources :

Example 1 with DecisionRule

use of org.kie.dmn.model.v1_1.DecisionRule in project drools by kiegroup.

the class DecisionTableConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DecisionTable dt = (DecisionTable) parent;
    for (InputClause i : dt.getInput()) {
        writeChildrenNode(writer, context, i, INPUT);
    }
    for (OutputClause o : dt.getOutput()) {
        writeChildrenNode(writer, context, o, OUTPUT);
    }
    for (DecisionRule r : dt.getRule()) {
        writeChildrenNode(writer, context, r, RULE);
    }
}
Also used : OutputClause(org.kie.dmn.model.api.OutputClause) DecisionTable(org.kie.dmn.model.api.DecisionTable) TDecisionTable(org.kie.dmn.model.v1_1.TDecisionTable) InputClause(org.kie.dmn.model.api.InputClause) DecisionRule(org.kie.dmn.model.api.DecisionRule)

Example 2 with DecisionRule

use of org.kie.dmn.model.v1_1.DecisionRule in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinition method getModelClass.

@Override
public Optional<DecisionTable> getModelClass() {
    final DecisionTable dtable = new DecisionTable();
    dtable.setHitPolicy(HitPolicy.ANY);
    dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW);
    final InputClause ic = new InputClause();
    final LiteralExpression le = new LiteralExpression();
    le.setText(INPUT_CLAUSE_EXPRESSION_TEXT);
    ic.setInputExpression(le);
    dtable.getInput().add(ic);
    final OutputClause oc = new OutputClause();
    oc.setName(OUTPUT_CLAUSE_NAME);
    dtable.getOutput().add(oc);
    final DecisionRule dr = new DecisionRule();
    final UnaryTests drut = new UnaryTests();
    drut.setText(INPUT_CLAUSE_UNARY_TEST_TEXT);
    dr.getInputEntry().add(drut);
    final LiteralExpression drle = new LiteralExpression();
    drle.setText(OUTPUT_CLAUSE_EXPRESSION_TEXT);
    dr.getOutputEntry().add(drle);
    final Description d = new Description();
    d.setValue(RULE_DESCRIPTION);
    dr.setDescription(d);
    dtable.getRule().add(dr);
    return Optional.of(dtable);
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)

Example 3 with DecisionRule

use of org.kie.dmn.model.v1_1.DecisionRule in project kie-wb-common by kiegroup.

the class DecisionTableEditorDefinitionTest method testModelDefinition.

@Test
public void testModelDefinition() {
    final Optional<DecisionTable> oModel = definition.getModelClass();
    assertThat(oModel).isPresent();
    final DecisionTable model = oModel.get();
    assertThat(model.getHitPolicy()).isEqualTo(HitPolicy.ANY);
    assertThat(model.getPreferredOrientation()).isEqualTo(DecisionTableOrientation.RULE_AS_ROW);
    final List<InputClause> input = model.getInput();
    assertThat(input.size()).isEqualTo(1);
    assertThat(input.get(0).getInputExpression()).isInstanceOf(LiteralExpression.class);
    final List<OutputClause> output = model.getOutput();
    assertThat(output.size()).isEqualTo(1);
    final List<DecisionRule> rules = model.getRule();
    assertThat(rules.size()).isEqualTo(1);
    final DecisionRule rule = rules.get(0);
    assertThat(rule.getInputEntry().size()).isEqualTo(1);
    assertThat(rule.getInputEntry().get(0)).isInstanceOf(UnaryTests.class);
    assertThat(rule.getOutputEntry().size()).isEqualTo(1);
    assertThat(rule.getOutputEntry().get(0)).isInstanceOf(LiteralExpression.class);
    assertThat(rule.getDescription()).isNotNull();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) Test(org.junit.Test)

Example 4 with DecisionRule

use of org.kie.dmn.model.v1_1.DecisionRule in project kie-wb-common by kiegroup.

the class DecisionRulePropertyConverter method wbFromDMN.

public static DecisionRule wbFromDMN(final org.kie.dmn.model.v1_1.DecisionRule dmn) {
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    DecisionRule result = new DecisionRule();
    result.setId(id);
    result.setDescription(description);
    for (org.kie.dmn.model.v1_1.UnaryTests ie : dmn.getInputEntry()) {
        result.getInputEntry().add(UnaryTestsPropertyConverter.wbFromDMN(ie));
    }
    for (org.kie.dmn.model.v1_1.LiteralExpression oe : dmn.getOutputEntry()) {
        result.getOutputEntry().add(LiteralExpressionPropertyConverter.wbFromDMN(oe));
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)

Example 5 with DecisionRule

use of org.kie.dmn.model.v1_1.DecisionRule in project drools by kiegroup.

the class DecisionRuleConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DecisionRule dr = (DecisionRule) parent;
    for (UnaryTests ie : dr.getInputEntry()) {
        writeChildrenNode(writer, context, ie, INPUT_ENTRY);
    }
    for (LiteralExpression oe : dr.getOutputEntry()) {
        writeChildrenNode(writer, context, oe, OUTPUT_ENTRY);
    }
}
Also used : LiteralExpression(org.kie.dmn.model.api.LiteralExpression) UnaryTests(org.kie.dmn.model.api.UnaryTests) DecisionRule(org.kie.dmn.model.api.DecisionRule) TDecisionRule(org.kie.dmn.model.v1_1.TDecisionRule)

Aggregations

DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)3 DecisionRule (org.kie.dmn.model.api.DecisionRule)2 DecisionTable (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)2 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)2 OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Test (org.junit.Test)1 DecisionTable (org.kie.dmn.model.api.DecisionTable)1 InputClause (org.kie.dmn.model.api.InputClause)1 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)1 OutputClause (org.kie.dmn.model.api.OutputClause)1 UnaryTests (org.kie.dmn.model.api.UnaryTests)1 TDecisionRule (org.kie.dmn.model.v1_1.TDecisionRule)1 TDecisionTable (org.kie.dmn.model.v1_1.TDecisionTable)1 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)1 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)1 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)1