use of org.kie.workbench.common.dmn.api.definition.model.InputClause in project kie-wb-common by kiegroup.
the class DecisionTablePropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.DecisionTable dmnFromWB(final DecisionTable wb) {
final org.kie.dmn.model.api.DecisionTable result = new org.kie.dmn.model.v1_2.TDecisionTable();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (final RuleAnnotationClause annotation : wb.getAnnotations()) {
final org.kie.dmn.model.api.RuleAnnotationClause converted = RuleAnnotationClauseConverter.dmnFromWB(annotation);
if (converted != null) {
converted.setParent(result);
}
result.getAnnotation().add(converted);
}
for (InputClause input : wb.getInput()) {
final org.kie.dmn.model.api.InputClause c = InputClausePropertyConverter.dmnFromWB(input);
if (c != null) {
c.setParent(result);
}
result.getInput().add(c);
}
for (OutputClause input : wb.getOutput()) {
final org.kie.dmn.model.api.OutputClause c = OutputClausePropertyConverter.dmnFromWB(input);
if (c != null) {
c.setParent(result);
}
result.getOutput().add(c);
}
if (result.getOutput().size() == 1) {
final org.kie.dmn.model.api.OutputClause outputClause = result.getOutput().get(0);
// DROOLS-3281
outputClause.setName(null);
// DROOLS-5178
outputClause.setTypeRef(null);
}
for (DecisionRule dr : wb.getRule()) {
final org.kie.dmn.model.api.DecisionRule c = DecisionRulePropertyConverter.dmnFromWB(dr);
if (c != null) {
c.setParent(result);
}
result.getRule().add(c);
}
if (wb.getHitPolicy() != null) {
result.setHitPolicy(org.kie.dmn.model.api.HitPolicy.fromValue(wb.getHitPolicy().value()));
}
if (wb.getAggregation() != null) {
result.setAggregation(org.kie.dmn.model.api.BuiltinAggregator.fromValue(wb.getAggregation().value()));
}
if (wb.getPreferredOrientation() != null) {
result.setPreferredOrientation(org.kie.dmn.model.api.DecisionTableOrientation.fromValue(wb.getPreferredOrientation().value()));
}
result.setOutputLabel(wb.getOutputLabel());
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InputClause 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.InputClause in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method testGraphCommandExecuteInsertMiddle.
@Test
public void testGraphCommandExecuteInsertMiddle() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + 1);
final String ruleInputOne = "rule in 1";
final String ruleInputTwo = "rule in 2";
dtable.getInput().add(new InputClause());
dtable.getInput().add(new InputClause());
addRuleWithInputClauseValues(ruleInputOne, ruleInputTwo);
assertEquals(2, dtable.getInput().size());
// Graph command will insert new InputClause at index 1 of the InputEntries
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext));
assertEquals(3, dtable.getInput().size());
assertNotNull(dtable.getInput().get(0).getInputExpression());
assertEquals(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_PREFIX + "1", dtable.getInput().get(1).getInputExpression().getText().getValue());
assertNotNull(dtable.getInput().get(2).getInputExpression());
final List<UnaryTests> ruleInputs = dtable.getRule().get(0).getInputEntry();
// first rule
assertEquals(3, ruleInputs.size());
assertEquals(ruleInputOne, ruleInputs.get(0).getText().getValue());
assertEquals(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT, ruleInputs.get(1).getText().getValue());
assertEquals(dtable.getRule().get(0), ruleInputs.get(1).getParent());
assertEquals(ruleInputTwo, ruleInputs.get(2).getText().getValue());
assertEquals(dtable, inputClause.getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.InputClause in project kie-wb-common by kiegroup.
the class AddInputClauseCommandTest method setUp.
@Before
public void setUp() throws Exception {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.inputClause = new InputClause();
this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.InputClause in project kie-wb-common by kiegroup.
the class DeleteInputClauseCommandTest method setup.
@Before
public void setup() {
this.dtable = new DecisionTable();
this.inputClause = new InputClause();
this.dtable.getInput().add(inputClause);
this.uiModel = new DMNGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiInputClauseColumn);
this.uiModel.appendColumn(uiAnnotationClauseColumn);
this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiAnnotationClauseColumn).getIndex();
}
Aggregations