Search in sources :

Example 1 with AddDecisionRuleCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand in project kie-wb-common by kiegroup.

the class DecisionTableGrid method addDecisionRule.

void addDecisionRule(final int index) {
    getExpression().get().ifPresent(dtable -> {
        final GridRow decisionTableRow = new LiteralExpressionGridRow();
        final DecisionRule decisionRule = DecisionRuleFactory.makeDecisionRule(dtable);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddDecisionRuleCommand(dtable, decisionRule, model, decisionTableRow, index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
    });
}
Also used : AddDecisionRuleCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand) LiteralExpressionGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow) LiteralExpressionGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 2 with AddDecisionRuleCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand in project kie-wb-common by kiegroup.

the class DecisionTableGrid method duplicateDecisionRule.

void duplicateDecisionRule(final int index) {
    getExpression().get().ifPresent(dtable -> {
        final GridRow decisionTableRow = new LiteralExpressionGridRow();
        final DecisionRule decisionRule = DecisionRuleFactory.duplicateDecisionRule(index, dtable);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddDecisionRuleCommand(dtable, decisionRule, model, decisionTableRow, index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
    });
}
Also used : AddDecisionRuleCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand) LiteralExpressionGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow) LiteralExpressionGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule)

Example 3 with AddDecisionRuleCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand in project kie-wb-common by kiegroup.

the class DecisionTableGridTest method addDecisionRule.

private void addDecisionRule(final int index) {
    grid.addDecisionRule(index);
    verify(sessionCommandManager).execute(eq(canvasHandler), addDecisionRuleCommandCaptor.capture());
    final AddDecisionRuleCommand addDecisionRuleCommand = addDecisionRuleCommandCaptor.getValue();
    addDecisionRuleCommand.execute(canvasHandler);
}
Also used : AddDecisionRuleCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand)

Example 4 with AddDecisionRuleCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand in project kie-wb-common by kiegroup.

the class DecisionTableGridTest method testDuplicateDecisionRule.

@Test
@SuppressWarnings("unchecked")
public void testDuplicateDecisionRule() {
    setupGrid(makeHasNameForDecision(), 0);
    final DecisionTable dtable = grid.getExpression().get().get();
    assertThat(dtable.getRule().size()).isEqualTo(1);
    final DecisionRule rule0 = dtable.getRule().get(0);
    assertThat(rule0.getInputEntry().size()).isEqualTo(1);
    assertThat(rule0.getOutputEntry().size()).isEqualTo(1);
    rule0.getInputEntry().get(0).getText().setValue("input");
    rule0.getOutputEntry().get(0).getText().setValue("output");
    rule0.getDescription().setValue("description");
    grid.duplicateDecisionRule(0);
    verify(sessionCommandManager).execute(eq(canvasHandler), addDecisionRuleCommandCaptor.capture());
    final AddDecisionRuleCommand addDecisionRuleCommand = addDecisionRuleCommandCaptor.getValue();
    addDecisionRuleCommand.execute(canvasHandler);
    assertThat(dtable.getRule().size()).isEqualTo(2);
    final DecisionRule rule1 = dtable.getRule().get(1);
    assertThat(rule1.getInputEntry().size()).isEqualTo(1);
    assertThat(rule1.getOutputEntry().size()).isEqualTo(1);
    assertThat(rule0.getInputEntry().get(0).getText().getValue()).isEqualTo("input");
    assertThat(rule0.getOutputEntry().get(0).getText().getValue()).isEqualTo("output");
    assertThat(rule0.getDescription().getValue()).isEqualTo("description");
    assertThat(rule1.getInputEntry().get(0).getText().getValue()).isEqualTo("input");
    assertThat(rule1.getOutputEntry().get(0).getText().getValue()).isEqualTo("output");
    assertThat(rule1.getDescription().getValue()).isEqualTo("description");
    verifyCommandExecuteOperation(BaseExpressionGrid.RESIZE_EXISTING);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) AddDecisionRuleCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Test(org.junit.Test)

Aggregations

AddDecisionRuleCommand (org.kie.workbench.common.dmn.client.commands.expressions.types.dtable.AddDecisionRuleCommand)4 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)3 LiteralExpressionGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.LiteralExpressionGridRow)2 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)2 Test (org.junit.Test)1 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)1