@Test public void testGraphCommandExecuteInsertMiddleWithColumns() { relation.getRow().add(new List()); relation.getRow().add(new List()); relation.getColumn().add(new InformationItem()); makeCommand(1); final Command<GraphCommandExecutionContext, RuleViolation> c = command.newGraphCommand(handler); assertEquals(GraphCommandResultBuilder.SUCCESS, c.execute(gce)); assertEquals(3, relation.getRow().size()); assertEquals(row, relation.getRow().get(1)); assertEquals(1, relation.getColumn().size()); assertEquals(1, relation.getRow().get(1).getExpression().size()); assertTrue(relation.getRow().get(1).getExpression().get(0).getExpression() instanceof LiteralExpression); assertEquals(relation, row.getParent()); assertEquals(relation.getRow().get(1), relation.getRow().get(1).getExpression().get(0).getExpression().getParent()); }
@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) { relation.getRow().add(uiRowIndex, row); relation.getColumn().forEach(ii -> { final LiteralExpression le = new LiteralExpression(); final HasExpression hasExpression = HasExpression.wrap(ii, le); row.getExpression().add(hasExpression); le.setParent(row); }); row.setParent(relation); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().remove(row); return GraphCommandResultBuilder.SUCCESS; } }; }
AddRelationRowCommand 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) { relation.getRow().add(uiRowIndex, row); relation.getColumn().forEach(ii -> { final LiteralExpression le = new LiteralExpression(); final HasExpression hasExpression = HasExpression.wrap(ii, le); row.getExpression().add(hasExpression); le.setParent(row); }); row.setParent(relation); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().remove(row); return GraphCommandResultBuilder.SUCCESS; } }; } }
AddRelationRowCommand 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) { relation.getRow().add(uiRowIndex, row); relation.getColumn().forEach(ii -> { final LiteralExpression le = new LiteralExpression(); final HasExpression hasExpression = HasExpression.wrap(ii, le); row.getExpression().add(hasExpression); le.setParent(row); }); row.setParent(relation); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().remove(row); return GraphCommandResultBuilder.SUCCESS; } }; } AddRelationRowCommand(final Relation relation,
                                 final List row,
                                 final GridData uiModel,
                                 final GridRow uiModelRow,
                                 final int uiRowIndex,
                                 final RelationUIModelMapper uiModelMapper,
                                 final org.uberfire.mvp.Command canvasOperation); }
AddRelationRowCommand 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) { relation.getRow().add(uiRowIndex, row); relation.getColumn().forEach(ii -> { final LiteralExpression le = new LiteralExpression(); final HasExpression hasExpression = HasExpression.wrap(ii, le); row.getExpression().add(hasExpression); le.setParent(row); }); row.setParent(relation); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().remove(row); return GraphCommandResultBuilder.SUCCESS; } }; } AddRelationRowCommand(final Relation relation,
                                 final List row,
                                 final GridData uiModel,
                                 final GridRow uiModelRow,
                                 final int uiRowIndex,
                                 final RelationUIModelMapper uiModelMapper,
                                 final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation(); }
AddRelationRowCommand 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) { relation.getRow().add(uiRowIndex, row); relation.getColumn().forEach(ii -> { final LiteralExpression le = new LiteralExpression(); final HasExpression hasExpression = HasExpression.wrap(ii, le); row.getExpression().add(hasExpression); le.setParent(row); }); row.setParent(relation); return GraphCommandResultBuilder.SUCCESS; } @Override public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) { relation.getRow().remove(row); return GraphCommandResultBuilder.SUCCESS; } }; } AddRelationRowCommand(final Relation relation,
                                 final List row,
                                 final GridData uiModel,
                                 final GridRow uiModelRow,
                                 final int uiRowIndex,
                                 final RelationUIModelMapper uiModelMapper,
                                 final org.uberfire.mvp.Command canvasOperation); void updateRowNumbers(); void updateParentInformation();  }