use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method setUp.
@Before
public void setUp() {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
dtable.getInput().add(inputClauseOne);
dtable.getInput().add(inputClauseTwo);
dtable.getInput().add(inputClauseThree);
dtable.getOutput().add(outputClauseOne);
dtable.getOutput().add(outputClauseTwo);
dtable.getOutput().add(outputClauseThree);
dtable.getAnnotations().add(annotationClauseOne);
dtable.getAnnotations().add(annotationClauseTwo);
dtable.getAnnotations().add(annotationClauseThree);
dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getInputEntry().add(new UnaryTests());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getOutputEntry().add(new LiteralExpression());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
getAnnotationEntry().add(new RuleAnnotationClauseText());
}
});
uiModel.appendColumn(uiRowNumberColumn);
uiModel.appendColumn(uiInputClauseColumnOne);
uiModel.appendColumn(uiInputClauseColumnTwo);
uiModel.appendColumn(uiInputClauseColumnThree);
uiModel.appendColumn(uiOutputClauseColumnOne);
uiModel.appendColumn(uiOutputClauseColumnTwo);
uiModel.appendColumn(uiOutputClauseColumnThree);
uiModel.appendColumn(uiRuleAnnotationClauseColumnOne);
uiModel.appendColumn(uiRuleAnnotationClauseColumnTwo);
uiModel.appendColumn(uiRuleAnnotationClauseColumnThree);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumnOne).getIndex();
doReturn(2).when(uiInputClauseColumnTwo).getIndex();
doReturn(3).when(uiInputClauseColumnThree).getIndex();
doReturn(4).when(uiOutputClauseColumnOne).getIndex();
doReturn(5).when(uiOutputClauseColumnTwo).getIndex();
doReturn(6).when(uiOutputClauseColumnThree).getIndex();
doReturn(7).when(uiRuleAnnotationClauseColumnOne).getIndex();
doReturn(8).when(uiRuleAnnotationClauseColumnTwo).getIndex();
doReturn(9).when(uiRuleAnnotationClauseColumnThree).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method setUp.
@Before
public void setUp() throws Exception {
this.dtable = new DecisionTable();
this.uiModel = new DMNGridData();
dtable.getInput().add(inputClause);
dtable.getOutput().add(outputClause);
uiModel.appendColumn(uiRowNumberColumn);
uiModel.appendColumn(uiInputClauseColumn);
uiModel.appendColumn(uiOutputClauseColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
rowsUnderTest.clear();
appendRow(0, "a");
appendRow(1, "b");
appendRow(2, "c");
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class SetHitPolicyCommandTest method makeCommand.
private void makeCommand(final HitPolicy hitPolicy) {
this.dtable = new DecisionTable();
this.dtable.setHitPolicy(hitPolicy);
this.command = new SetHitPolicyCommand(dtable, NEW_HIT_POLICY, canvasOperation);
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method enrichInputClauses.
@SuppressWarnings("unchecked")
void enrichInputClauses(final String uuid, final DecisionTable dtable) {
final Graph<?, Node> graph = sessionManager.getCurrentSession().getCanvasHandler().getDiagram().getGraph();
final Node<?, Edge> node = graph.getNode(uuid);
if (Objects.isNull(node)) {
return;
}
// Get all Decision nodes feeding into this DecisionTable
final List<Decision> decisionSet = node.getInEdges().stream().map(Edge::getSourceNode).map(Node::getContent).filter(content -> content instanceof Definition).map(content -> (Definition) content).map(Definition::getDefinition).filter(definition -> definition instanceof Decision).map(definition -> (Decision) definition).collect(Collectors.toList());
// Get all InputData nodes feeding into this DecisionTable
final List<InputData> inputDataSet = node.getInEdges().stream().map(Edge::getSourceNode).map(Node::getContent).filter(content -> content instanceof Definition).map(content -> (Definition) content).map(Definition::getDefinition).filter(definition -> definition instanceof InputData).map(definition -> (InputData) definition).collect(Collectors.toList());
if (decisionSet.isEmpty() && inputDataSet.isEmpty()) {
return;
}
// Extract individual components of InputData TypeRefs
final Definitions definitions = dmnGraphUtils.getModelDefinitions();
final List<ClauseRequirement> inputClauseRequirements = new ArrayList<>();
decisionSet.forEach(decision -> addInputClauseRequirement(decision.getVariable().getTypeRef(), definitions, inputClauseRequirements, decision.getName().getValue()));
inputDataSet.forEach(inputData -> addInputClauseRequirement(inputData.getVariable().getTypeRef(), definitions, inputClauseRequirements, inputData.getName().getValue()));
// Add InputClause columns for each InputData TypeRef component, sorted alphabetically
dtable.getInput().clear();
dtable.getRule().stream().forEach(decisionRule -> decisionRule.getInputEntry().clear());
inputClauseRequirements.stream().sorted(Comparator.comparing(inputClauseRequirement -> inputClauseRequirement.text)).forEach(inputClauseRequirement -> {
final InputClause inputClause = new InputClause();
final InputClauseLiteralExpression literalExpression = new InputClauseLiteralExpression();
literalExpression.getText().setValue(inputClauseRequirement.text);
literalExpression.setTypeRef(inputClauseRequirement.typeRef);
inputClause.setInputExpression(literalExpression);
dtable.getInput().add(inputClause);
dtable.getRule().stream().forEach(decisionRule -> {
final UnaryTests decisionRuleUnaryTest = new UnaryTests();
decisionRuleUnaryTest.getText().setValue(DecisionTableDefaultValueUtilities.INPUT_CLAUSE_UNARY_TEST_TEXT);
decisionRule.getInputEntry().add(decisionRuleUnaryTest);
decisionRuleUnaryTest.setParent(decisionRule);
});
inputClause.setParent(dtable);
literalExpression.setParent(inputClause);
});
}
use of org.kie.workbench.common.dmn.api.definition.model.DecisionTable in project kie-wb-common by kiegroup.
the class DecisionTableGrid method doAfterHeaderSelectionChange.
@Override
public void doAfterHeaderSelectionChange(final int uiHeaderRowIndex, final int uiHeaderColumnIndex) {
if (getExpression().get().isPresent()) {
final DecisionTable dtable = getExpression().get().get();
final DecisionTableUIModelMapperHelper.DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, uiHeaderColumnIndex);
switch(section) {
case INPUT_CLAUSES:
doAfterHeaderInputClauseSelectionChange(dtable, uiHeaderColumnIndex);
return;
case OUTPUT_CLAUSES:
doAfterHeaderOutputClauseSelectionChange(dtable, uiHeaderRowIndex, uiHeaderColumnIndex);
return;
}
}
super.doAfterHeaderSelectionChange(uiHeaderRowIndex, uiHeaderColumnIndex);
}
Aggregations