use of org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression 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.InputClauseLiteralExpression in project kie-wb-common by kiegroup.
the class InputClausePropertyConverter method wbFromDMN.
public static InputClause wbFromDMN(final org.kie.dmn.model.api.InputClause dmn) {
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final InputClauseLiteralExpression inputExpression = InputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getInputExpression());
final InputClauseUnaryTests inputValues = InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getInputValues());
final InputClause result = new InputClause(id, description, inputExpression, inputValues);
if (inputExpression != null) {
inputExpression.setParent(result);
}
if (inputValues != null) {
inputValues.setParent(result);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression in project kie-wb-common by kiegroup.
the class InputClauseLiteralExpressionPropertyConverter method wbFromDMN.
public static InputClauseLiteralExpression wbFromDMN(final org.kie.dmn.model.api.LiteralExpression dmn) {
if (dmn == null) {
return null;
}
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
final Text text = new Text(dmn.getText());
final ImportedValues importedValues = ImportedValuesConverter.wbFromDMN(dmn.getImportedValues());
final InputClauseLiteralExpression result = new InputClauseLiteralExpression(id, description, typeRef, text, importedValues);
if (importedValues != null) {
importedValues.setParent(result);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression in project kie-wb-common by kiegroup.
the class InputClausePropertyConverter method wbFromDMN.
public static InputClause wbFromDMN(final JSITInputClause dmn) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final InputClauseLiteralExpression inputExpression = InputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getInputExpression());
final InputClauseUnaryTests inputValues = Optional.ofNullable(InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getInputValues())).orElse(new InputClauseUnaryTests());
final InputClause result = new InputClause(id, description, inputExpression, inputValues);
if (Objects.nonNull(inputExpression)) {
inputExpression.setParent(result);
}
inputValues.setParent(result);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InputClauseLiteralExpression in project kie-wb-common by kiegroup.
the class DecisionTableDefaultValueUtilitiesTest method testGetNewInputClauseNameWithDeletion.
@Test
public void testGetNewInputClauseNameWithDeletion() {
final InputClause inputClause1 = new InputClause() {
{
setInputExpression(new InputClauseLiteralExpression());
}
};
dtable.getInput().add(inputClause1);
inputClause1.getInputExpression().getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
assertThat(inputClause1.getInputExpression().getText().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "1");
final InputClause inputClause2 = new InputClause() {
{
setInputExpression(new InputClauseLiteralExpression());
}
};
dtable.getInput().add(inputClause2);
inputClause2.getInputExpression().getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
assertThat(inputClause2.getInputExpression().getText().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "2");
dtable.getInput().remove(inputClause1);
final InputClause inputClause3 = new InputClause() {
{
setInputExpression(new InputClauseLiteralExpression());
}
};
dtable.getInput().add(inputClause3);
inputClause3.getInputExpression().getText().setValue(DecisionTableDefaultValueUtilities.getNewInputClauseName(dtable));
assertThat(inputClause3.getInputExpression().getText().getValue()).isEqualTo(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "3");
}
Aggregations