Search in sources :

Example 1 with InputClause

use of org.kie.workbench.common.dmn.api.definition.v1_1.InputClause in project kie-wb-common by kiegroup.

the class DecisionTablePropertyConverter method wbFromDMN.

public static DecisionTable wbFromDMN(final org.kie.dmn.model.v1_1.DecisionTable dmn) {
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    DecisionTable result = new DecisionTable();
    result.setId(id);
    result.setDescription(description);
    result.setTypeRef(typeRef);
    for (org.kie.dmn.model.v1_1.InputClause input : dmn.getInput()) {
        result.getInput().add(InputClausePropertyConverter.wbFromDMN(input));
    }
    for (org.kie.dmn.model.v1_1.OutputClause input : dmn.getOutput()) {
        result.getOutput().add(OutputClausePropertyConverter.wbFromDMN(input));
    }
    for (org.kie.dmn.model.v1_1.DecisionRule dr : dmn.getRule()) {
        result.getRule().add(DecisionRulePropertyConverter.wbFromDMN(dr));
    }
    if (dmn.getHitPolicy() != null) {
        result.setHitPolicy(HitPolicy.fromValue(dmn.getHitPolicy().value()));
    }
    if (dmn.getAggregation() != null) {
        result.setAggregation(BuiltinAggregator.fromValue(dmn.getAggregation().value()));
    }
    if (dmn.getPreferredOrientation() != null) {
        result.setPreferredOrientation(DecisionTableOrientation.fromValue(dmn.getPreferredOrientation().value()));
    }
    result.setOutputLabel(dmn.getOutputLabel());
    return result;
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 2 with InputClause

use of org.kie.workbench.common.dmn.api.definition.v1_1.InputClause 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 InputClause

use of org.kie.workbench.common.dmn.api.definition.v1_1.InputClause in project kie-wb-common by kiegroup.

the class DecisionTableGrid method makeInputClauseColumn.

private InputClauseColumn makeInputClauseColumn(final InputClause ic) {
    final LiteralExpression le = ic.getInputExpression();
    final InputClauseColumn column = new InputClauseColumn(new InputClauseColumnHeaderMetaData(le::getText, le::setText, headerTextAreaFactory), textAreaFactory, this);
    return column;
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)

Example 4 with InputClause

use of org.kie.workbench.common.dmn.api.definition.v1_1.InputClause 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 5 with InputClause

use of org.kie.workbench.common.dmn.api.definition.v1_1.InputClause in project kie-wb-common by kiegroup.

the class InputClausePropertyConverter method wbFromDMN.

public static InputClause wbFromDMN(final org.kie.dmn.model.v1_1.InputClause dmn) {
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    LiteralExpression inputExpression = LiteralExpressionPropertyConverter.wbFromDMN(dmn.getInputExpression());
    UnaryTests inputValues = UnaryTestsPropertyConverter.wbFromDMN(dmn.getInputValues());
    InputClause result = new InputClause(id, description, inputExpression, inputValues);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)

Aggregations

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