@Test public void testGraphCommandExecute() { final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler); assertEquals(GraphCommandResultBuilder.SUCCESS, graphCommand.execute(graphCommandExecutionContext)); assertEquals(0, dtable.getOutput().size()); }
@Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = getOutputClauseIndex(); dtable.getRule().forEach(row -> row.getOutputEntry().remove(clauseIndex)); dtable.getOutput().remove(clauseIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int clauseIndex = getOutputClauseIndex(); dtable.getOutput().add(clauseIndex, oldOutputClause); IntStream.range(0, dtable.getRule().size()) .forEach(rowIndex -> { final LiteralExpression value = oldColumnData.get(rowIndex); dtable.getRule().get(rowIndex).getOutputEntry().add(clauseIndex, value); }); return GraphCommandResultBuilder.SUCCESS; } }; }
DeleteOutputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                     VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = getOutputClauseIndex(); dtable.getRule().forEach(row -> row.getOutputEntry().remove(clauseIndex)); dtable.getOutput().remove(clauseIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int clauseIndex = getOutputClauseIndex(); dtable.getOutput().add(clauseIndex, oldOutputClause); IntStream.range(0, dtable.getRule().size()) .forEach(rowIndex -> { final LiteralExpression value = oldColumnData.get(rowIndex); dtable.getRule().get(rowIndex).getOutputEntry().add(clauseIndex, value); }); return GraphCommandResultBuilder.SUCCESS; } }; } }
DeleteOutputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                     VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = getOutputClauseIndex(); dtable.getRule().forEach(row -> row.getOutputEntry().remove(clauseIndex)); dtable.getOutput().remove(clauseIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int clauseIndex = getOutputClauseIndex(); dtable.getOutput().add(clauseIndex, oldOutputClause); IntStream.range(0, dtable.getRule().size()) .forEach(rowIndex -> { final LiteralExpression value = oldColumnData.get(rowIndex); dtable.getRule().get(rowIndex).getOutputEntry().add(clauseIndex, value); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteOutputClauseCommand(final DecisionTable dtable,
                                     final GridData uiModel,
                                     final int uiColumnIndex,
                                     final DecisionTableUIModelMapper uiModelMapper,
                                     final org.uberfire.mvp.Command executeCanvasOperation,
                                     final org.uberfire.mvp.Command undoCanvasOperation); }
DeleteOutputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                     VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = getOutputClauseIndex(); dtable.getRule().forEach(row -> row.getOutputEntry().remove(clauseIndex)); dtable.getOutput().remove(clauseIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int clauseIndex = getOutputClauseIndex(); dtable.getOutput().add(clauseIndex, oldOutputClause); IntStream.range(0, dtable.getRule().size()) .forEach(rowIndex -> { final LiteralExpression value = oldColumnData.get(rowIndex); dtable.getRule().get(rowIndex).getOutputEntry().add(clauseIndex, value); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteOutputClauseCommand(final DecisionTable dtable,
                                     final GridData uiModel,
                                     final int uiColumnIndex,
                                     final DecisionTableUIModelMapper uiModelMapper,
                                     final org.uberfire.mvp.Command executeCanvasOperation,
                                     final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation(); }
DeleteOutputClauseCommand extends AbstractCanvasGraphCommand implements VetoExecutionCommand,
                                                                                     VetoUndoCommand { @Override protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) { return new AbstractGraphCommand() { @Override protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) { return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().remove(uiColumnIndex); final int clauseIndex = getOutputClauseIndex(); dtable.getRule().forEach(row -> row.getOutputEntry().remove(clauseIndex)); dtable.getOutput().remove(clauseIndex); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { dtable.getComponentWidths().add(uiColumnIndex, oldUiModelColumn.getWidth()); final int clauseIndex = getOutputClauseIndex(); dtable.getOutput().add(clauseIndex, oldOutputClause); IntStream.range(0, dtable.getRule().size()) .forEach(rowIndex -> { final LiteralExpression value = oldColumnData.get(rowIndex); dtable.getRule().get(rowIndex).getOutputEntry().add(clauseIndex, value); }); return GraphCommandResultBuilder.SUCCESS; } }; } DeleteOutputClauseCommand(final DecisionTable dtable,
                                     final GridData uiModel,
                                     final int uiColumnIndex,
                                     final DecisionTableUIModelMapper uiModelMapper,
                                     final org.uberfire.mvp.Command executeCanvasOperation,
                                     final org.uberfire.mvp.Command undoCanvasOperation); void updateParentInformation();  }