use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class DecisionTableGrid method addOutputClause.
void addOutputClause(final int index) {
expression.ifPresent(dtable -> {
final OutputClause clause = new OutputClause();
clause.setName("output");
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddOutputClauseCommand(dtable, clause, model, makeOutputClauseColumn(clause), index, uiModelMapper, () -> synchroniseViewWhenExpressionEditorChanged(this)));
});
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class DeleteOutputClauseCommandTest method setup.
@Before
public void setup() {
this.dtable = new DecisionTable();
this.outputClause = new OutputClause();
this.dtable.getOutput().add(outputClause);
this.uiModel = new DMNGridData();
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiOutputClauseColumn);
this.uiModel.appendColumn(uiDescriptionColumn);
this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
this.command = spy(new DeleteOutputClauseCommand(dtable, uiModel, DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT + dtable.getInput().size(), uiModelMapper, canvasOperation));
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiOutputClauseColumn).getIndex();
doReturn(2).when(uiDescriptionColumn).getIndex();
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause 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.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class OutputClausePropertyConverter method wbFromDMN.
public static OutputClause wbFromDMN(final org.kie.dmn.model.v1_1.OutputClause dmn) {
Id id = new Id(dmn.getId());
Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
UnaryTests outputValues = UnaryTestsPropertyConverter.wbFromDMN(dmn.getOutputValues());
LiteralExpression defaultOutputEntry = LiteralExpressionPropertyConverter.wbFromDMN(dmn.getDefaultOutputEntry());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
OutputClause result = new OutputClause();
result.setId(id);
result.setName(dmn.getName());
result.setDescription(description);
result.setOutputValues(outputValues);
result.setDefaultOutputEntry(defaultOutputEntry);
result.setTypeRef(typeRef);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause in project kie-wb-common by kiegroup.
the class AddOutputClauseCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler context) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
final int clauseIndex = uiColumnIndex - DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT - dtable.getInput().size();
dtable.getOutput().add(clauseIndex, outputClause);
dtable.getRule().forEach(rule -> {
final LiteralExpression le = new LiteralExpression();
le.setText(OUTPUT_CLAUSE_DEFAULT_VALUE);
rule.getOutputEntry().add(clauseIndex, le);
});
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
final int clauseIndex = dtable.getOutput().indexOf(outputClause);
dtable.getRule().forEach(rule -> rule.getOutputEntry().remove(clauseIndex));
dtable.getOutput().remove(outputClause);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
Aggregations