Search in sources :

Example 6 with OutputClause

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)));
    });
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) AddOutputClauseCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddOutputClauseCommand)

Example 7 with OutputClause

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();
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 8 with OutputClause

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");
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Before(org.junit.Before)

Example 9 with OutputClause

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;
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) UnaryTests(org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)

Example 10 with OutputClause

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;
        }
    };
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) AbstractGraphCommand(org.kie.workbench.common.stunner.core.graph.command.impl.AbstractGraphCommand) GraphCommandExecutionContext(org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation)

Aggregations

OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)13 DecisionTable (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)8 Test (org.junit.Test)6 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)6 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)6 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)6 OutputClause (org.kie.dmn.model.v1_1.OutputClause)5 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)5 Before (org.junit.Before)4 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)4 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)3 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)3 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)3 Optional (java.util.Optional)2 QName (javax.xml.namespace.QName)2 DMNType (org.kie.dmn.api.core.DMNType)2 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)2 ArrayList (java.util.ArrayList)1