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