@Test public void testModelEnrichmentWhenHasExpressionIsHasVariable() { decision.setVariable(new InformationItemPrimary(new Id(), new Name(), OUTPUT_DATA_QNAME)); final Optional<DecisionTable> oModel = definition.getModelClass(); definition.enrich(Optional.empty(), decision, oModel); final DecisionTable model = oModel.get(); assertBasicEnrichment(model); assertStandardInputClauseEnrichment(model); final List<OutputClause> output = model.getOutput(); assertThat(output.size()).isEqualTo(1); assertThat(output.get(0).getName()).isEqualTo(DEFAULT_OUTPUT_NAME); assertThat(output.get(0).getTypeRef()).isEqualTo(OUTPUT_DATA_QNAME); assertStandardDecisionRuleEnrichment(model); assertParentHierarchyEnrichment(model); }
@Override public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<DecisionTable> expression) { expression.ifPresent(dtable -> { dtable.setHitPolicy(HitPolicy.UNIQUE); dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); final InputClause inputClause = new InputClause(); final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression(); literalExpression.getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable)); inputClause.setInputExpression(literalExpression); dtable.getInput().add(inputClause); final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable)); dtable.getAnnotations().add(ruleAnnotationClause); final DecisionRule decisionRule = new DecisionRule(); final UnaryTests decisionRuleUnaryTest = new UnaryTests(); decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); decisionRule.getInputEntry().add(decisionRuleUnaryTest); buildOutputClausesByDataType(hasExpression, dtable, decisionRule); final RuleAnnotationClauseText ruleAnnotationEntry = new RuleAnnotationClauseText(); ruleAnnotationEntry.getText().setValue(DecisionTableDefaultValueUtilities.RULE_DESCRIPTION); decisionRule.getAnnotationEntry().add(ruleAnnotationEntry); dtable.getRule().add(decisionRule); inputClause.setParent(dtable); decisionRule.setParent(dtable); literalExpression.setParent(inputClause); decisionRuleUnaryTest.setParent(decisionRule); ruleAnnotationEntry.setParent(dtable); if (nodeUUID.isPresent()) { enrichInputClauses(nodeUUID.get(), dtable); } else { enrichOutputClauses(dtable); } }); }
DecisionTableEditorDefinitionEnricher implements ExpressionEditorModelEnricher<DecisionTable> { @Override public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<DecisionTable> expression) { expression.ifPresent(dtable -> { dtable.setHitPolicy(HitPolicy.UNIQUE); dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); final InputClause inputClause = new InputClause(); final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression(); literalExpression.getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable)); inputClause.setInputExpression(literalExpression); dtable.getInput().add(inputClause); final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable)); dtable.getAnnotations().add(ruleAnnotationClause); final DecisionRule decisionRule = new DecisionRule(); final UnaryTests decisionRuleUnaryTest = new UnaryTests(); decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); decisionRule.getInputEntry().add(decisionRuleUnaryTest); buildOutputClausesByDataType(hasExpression, dtable, decisionRule); final RuleAnnotationClauseText ruleAnnotationEntry = new RuleAnnotationClauseText(); ruleAnnotationEntry.getText().setValue(DecisionTableDefaultValueUtilities.RULE_DESCRIPTION); decisionRule.getAnnotationEntry().add(ruleAnnotationEntry); dtable.getRule().add(decisionRule); inputClause.setParent(dtable); decisionRule.setParent(dtable); literalExpression.setParent(inputClause); decisionRuleUnaryTest.setParent(decisionRule); ruleAnnotationEntry.setParent(dtable); if (nodeUUID.isPresent()) { enrichInputClauses(nodeUUID.get(), dtable); } else { enrichOutputClauses(dtable); } }); } }
DecisionTableEditorDefinitionEnricher implements ExpressionEditorModelEnricher<DecisionTable> { @Override public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<DecisionTable> expression) { expression.ifPresent(dtable -> { dtable.setHitPolicy(HitPolicy.UNIQUE); dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); final InputClause inputClause = new InputClause(); final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression(); literalExpression.getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable)); inputClause.setInputExpression(literalExpression); dtable.getInput().add(inputClause); final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable)); dtable.getAnnotations().add(ruleAnnotationClause); final DecisionRule decisionRule = new DecisionRule(); final UnaryTests decisionRuleUnaryTest = new UnaryTests(); decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); decisionRule.getInputEntry().add(decisionRuleUnaryTest); buildOutputClausesByDataType(hasExpression, dtable, decisionRule); final RuleAnnotationClauseText ruleAnnotationEntry = new RuleAnnotationClauseText(); ruleAnnotationEntry.getText().setValue(DecisionTableDefaultValueUtilities.RULE_DESCRIPTION); decisionRule.getAnnotationEntry().add(ruleAnnotationEntry); dtable.getRule().add(decisionRule); inputClause.setParent(dtable); decisionRule.setParent(dtable); literalExpression.setParent(inputClause); decisionRuleUnaryTest.setParent(decisionRule); ruleAnnotationEntry.setParent(dtable); if (nodeUUID.isPresent()) { enrichInputClauses(nodeUUID.get(), dtable); } else { enrichOutputClauses(dtable); } }); } DecisionTableEditorDefinitionEnricher(); @Inject  DecisionTableEditorDefinitionEnricher(final SessionManager sessionManager,
                                                 final DMNGraphUtils dmnGraphUtils,
                                                 final ItemDefinitionUtils itemDefinitionUtils); }
DecisionTableEditorDefinitionEnricher implements ExpressionEditorModelEnricher<DecisionTable> { @Override public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<DecisionTable> expression) { expression.ifPresent(dtable -> { dtable.setHitPolicy(HitPolicy.UNIQUE); dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); final InputClause inputClause = new InputClause(); final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression(); literalExpression.getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable)); inputClause.setInputExpression(literalExpression); dtable.getInput().add(inputClause); final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable)); dtable.getAnnotations().add(ruleAnnotationClause); final DecisionRule decisionRule = new DecisionRule(); final UnaryTests decisionRuleUnaryTest = new UnaryTests(); decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); decisionRule.getInputEntry().add(decisionRuleUnaryTest); buildOutputClausesByDataType(hasExpression, dtable, decisionRule); final RuleAnnotationClauseText ruleAnnotationEntry = new RuleAnnotationClauseText(); ruleAnnotationEntry.getText().setValue(DecisionTableDefaultValueUtilities.RULE_DESCRIPTION); decisionRule.getAnnotationEntry().add(ruleAnnotationEntry); dtable.getRule().add(decisionRule); inputClause.setParent(dtable); decisionRule.setParent(dtable); literalExpression.setParent(inputClause); decisionRuleUnaryTest.setParent(decisionRule); ruleAnnotationEntry.setParent(dtable); if (nodeUUID.isPresent()) { enrichInputClauses(nodeUUID.get(), dtable); } else { enrichOutputClauses(dtable); } }); } DecisionTableEditorDefinitionEnricher(); @Inject  DecisionTableEditorDefinitionEnricher(final SessionManager sessionManager,
                                                 final DMNGraphUtils dmnGraphUtils,
                                                 final ItemDefinitionUtils itemDefinitionUtils); @Override void enrich(final Optional<String> nodeUUID,
                       final HasExpression hasExpression,
                       final Optional<DecisionTable> expression); }
DecisionTableEditorDefinitionEnricher implements ExpressionEditorModelEnricher<DecisionTable> { @Override public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<DecisionTable> expression) { expression.ifPresent(dtable -> { dtable.setHitPolicy(HitPolicy.UNIQUE); dtable.setPreferredOrientation(DecisionTableOrientation.RULE_AS_ROW); final InputClause inputClause = new InputClause(); final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression(); literalExpression.getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable)); inputClause.setInputExpression(literalExpression); dtable.getInput().add(inputClause); final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause(); ruleAnnotationClause.getName().setValue(DecisionTableDefaultValueUtilities.getNewRuleAnnotationClauseName(dtable)); dtable.getAnnotations().add(ruleAnnotationClause); final DecisionRule decisionRule = new DecisionRule(); final UnaryTests decisionRuleUnaryTest = new UnaryTests(); decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT); decisionRule.getInputEntry().add(decisionRuleUnaryTest); buildOutputClausesByDataType(hasExpression, dtable, decisionRule); final RuleAnnotationClauseText ruleAnnotationEntry = new RuleAnnotationClauseText(); ruleAnnotationEntry.getText().setValue(DecisionTableDefaultValueUtilities.RULE_DESCRIPTION); decisionRule.getAnnotationEntry().add(ruleAnnotationEntry); dtable.getRule().add(decisionRule); inputClause.setParent(dtable); decisionRule.setParent(dtable); literalExpression.setParent(inputClause); decisionRuleUnaryTest.setParent(decisionRule); ruleAnnotationEntry.setParent(dtable); if (nodeUUID.isPresent()) { enrichInputClauses(nodeUUID.get(), dtable); } else { enrichOutputClauses(dtable); } }); } DecisionTableEditorDefinitionEnricher(); @Inject  DecisionTableEditorDefinitionEnricher(final SessionManager sessionManager,
                                                 final DMNGraphUtils dmnGraphUtils,
                                                 final ItemDefinitionUtils itemDefinitionUtils); @Override void enrich(final Optional<String> nodeUUID,
                       final HasExpression hasExpression,
                       final Optional<DecisionTable> expression);  }