use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method enrich.
@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);
// Setup parent relationships
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);
}
});
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class RuleAnnotationClauseConverterTest method testWbFromDMNWhenIsNull.
@Test
public void testWbFromDMNWhenIsNull() {
final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(null);
assertNull(converted);
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class RuleAnnotationClauseConverterTest method testWbFromDMN.
@Test
public void testWbFromDMN() {
final String name = "name";
when(ruleAnnotationClause.getName()).thenReturn(name);
final RuleAnnotationClause converted = RuleAnnotationClauseConverter.wbFromDMN(ruleAnnotationClause);
assertEquals(name, converted.getName().getValue());
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class DecisionTableGrid method addRuleAnnotationClause.
void addRuleAnnotationClause(final int index) {
getExpression().get().ifPresent(dtable -> {
final RuleAnnotationClause clause = new RuleAnnotationClause();
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddRuleAnnotationClauseCommand(dtable, clause, model, () -> makeRuleAnnotationClauseColumn(index, clause), index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING), () -> resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM)));
});
}
use of org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause in project kie-wb-common by kiegroup.
the class RuleAnnotationClauseConverter method wbFromDMN.
public static RuleAnnotationClause wbFromDMN(final org.kie.dmn.model.api.RuleAnnotationClause ruleAnnotationClause) {
if (ruleAnnotationClause == null) {
return null;
}
final RuleAnnotationClause rule = new RuleAnnotationClause();
rule.setName(new Name(ruleAnnotationClause.getName()));
return rule;
}
Aggregations