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