@Test public void testExecute() { cloneNodeCommand.execute(graphCommandExecutionContext); Function<Object, Boolean> cloneNodeInstanceFunction = command -> command instanceof CloneNodeCommand; assertTrue(checkCloneChildrenElement(cloneNodeInstanceFunction, getCheckChildrenNodeFunction(graphInstance.startNode))); assertTrue(checkCloneChildrenElement(cloneNodeInstanceFunction, getCheckChildrenNodeFunction(graphInstance.intermNode))); assertTrue(checkCloneChildrenElement(cloneNodeInstanceFunction, getCheckChildrenNodeFunction(graphInstance.endNode))); Function<Object, Boolean> cloneConnectorInstanceFunction = command -> command instanceof CloneConnectorCommand; assertTrue(checkCloneChildrenElement(cloneConnectorInstanceFunction, getCheckChildrenEdgeFunction(graphInstance.edge1))); assertTrue(checkCloneChildrenElement(cloneConnectorInstanceFunction, getCheckChildrenEdgeFunction(graphInstance.edge2))); }
@Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { CommandResult<RuleViolation> result = super.execute(context); if (CommandUtils.isError(result)) { return result; } List<CommandResult<RuleViolation>> commandResults = new ArrayList<>(); commandResults.add(result); childrenCommands = new LinkedList<>(); if (GraphUtils.hasChildren(candidate)) { commandResults.addAll(processChildrenNodes(context)); } if (GraphUtils.hasDockedNodes(candidate)) { commandResults.addAll(processDockedNodes(context)); } CommandResult<RuleViolation> finalResult = buildResult(commandResults); if (CommandUtils.isError(finalResult)) { processMultipleFunctions(childrenCommands, c -> doUndo(context, c), reverted -> { }); processMultipleFunctions(getCommands(), c -> doUndo(context, c), reverted -> { }); return finalResult; } callbackOptional.ifPresent(callback -> callback.accept(clone)); LOGGER.info("Node " + candidate.getUUID() + "was cloned successfully to " + clone.getUUID()); return finalResult; }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { CommandResult<RuleViolation> result = super.execute(context); if (CommandUtils.isError(result)) { return result; } List<CommandResult<RuleViolation>> commandResults = new ArrayList<>(); commandResults.add(result); childrenCommands = new LinkedList<>(); if (GraphUtils.hasChildren(candidate)) { commandResults.addAll(processChildrenNodes(context)); } if (GraphUtils.hasDockedNodes(candidate)) { commandResults.addAll(processDockedNodes(context)); } CommandResult<RuleViolation> finalResult = buildResult(commandResults); if (CommandUtils.isError(finalResult)) { processMultipleFunctions(childrenCommands, c -> doUndo(context, c), reverted -> { }); processMultipleFunctions(getCommands(), c -> doUndo(context, c), reverted -> { }); return finalResult; } callbackOptional.ifPresent(callback -> callback.accept(clone)); LOGGER.info("Node " + candidate.getUUID() + "was cloned successfully to " + clone.getUUID()); return finalResult; } }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { CommandResult<RuleViolation> result = super.execute(context); if (CommandUtils.isError(result)) { return result; } List<CommandResult<RuleViolation>> commandResults = new ArrayList<>(); commandResults.add(result); childrenCommands = new LinkedList<>(); if (GraphUtils.hasChildren(candidate)) { commandResults.addAll(processChildrenNodes(context)); } if (GraphUtils.hasDockedNodes(candidate)) { commandResults.addAll(processDockedNodes(context)); } CommandResult<RuleViolation> finalResult = buildResult(commandResults); if (CommandUtils.isError(finalResult)) { processMultipleFunctions(childrenCommands, c -> doUndo(context, c), reverted -> { }); processMultipleFunctions(getCommands(), c -> doUndo(context, c), reverted -> { }); return finalResult; } callbackOptional.ifPresent(callback -> callback.accept(clone)); LOGGER.info("Node " + candidate.getUUID() + "was cloned successfully to " + clone.getUUID()); return finalResult; } protected  CloneNodeCommand();  CloneNodeCommand(final @MapsTo("candidate") Node candidate, final @MapsTo("parentUuid") String parentUuid);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback); }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { CommandResult<RuleViolation> result = super.execute(context); if (CommandUtils.isError(result)) { return result; } List<CommandResult<RuleViolation>> commandResults = new ArrayList<>(); commandResults.add(result); childrenCommands = new LinkedList<>(); if (GraphUtils.hasChildren(candidate)) { commandResults.addAll(processChildrenNodes(context)); } if (GraphUtils.hasDockedNodes(candidate)) { commandResults.addAll(processDockedNodes(context)); } CommandResult<RuleViolation> finalResult = buildResult(commandResults); if (CommandUtils.isError(finalResult)) { processMultipleFunctions(childrenCommands, c -> doUndo(context, c), reverted -> { }); processMultipleFunctions(getCommands(), c -> doUndo(context, c), reverted -> { }); return finalResult; } callbackOptional.ifPresent(callback -> callback.accept(clone)); LOGGER.info("Node " + candidate.getUUID() + "was cloned successfully to " + clone.getUUID()); return finalResult; } protected  CloneNodeCommand();  CloneNodeCommand(final @MapsTo("candidate") Node candidate, final @MapsTo("parentUuid") String parentUuid);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); List<CommandResult<RuleViolation>> processChildrenNodes(GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); Node<View, Edge> getClone(); Node<Definition, Edge> getCandidate(); List<Command<GraphCommandExecutionContext, RuleViolation>> getChildrenCommands(); }
CloneNodeCommand extends AbstractGraphCompositeCommand { @Override public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) { CommandResult<RuleViolation> result = super.execute(context); if (CommandUtils.isError(result)) { return result; } List<CommandResult<RuleViolation>> commandResults = new ArrayList<>(); commandResults.add(result); childrenCommands = new LinkedList<>(); if (GraphUtils.hasChildren(candidate)) { commandResults.addAll(processChildrenNodes(context)); } if (GraphUtils.hasDockedNodes(candidate)) { commandResults.addAll(processDockedNodes(context)); } CommandResult<RuleViolation> finalResult = buildResult(commandResults); if (CommandUtils.isError(finalResult)) { processMultipleFunctions(childrenCommands, c -> doUndo(context, c), reverted -> { }); processMultipleFunctions(getCommands(), c -> doUndo(context, c), reverted -> { }); return finalResult; } callbackOptional.ifPresent(callback -> callback.accept(clone)); LOGGER.info("Node " + candidate.getUUID() + "was cloned successfully to " + clone.getUUID()); return finalResult; } protected  CloneNodeCommand();  CloneNodeCommand(final @MapsTo("candidate") Node candidate, final @MapsTo("parentUuid") String parentUuid);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback, final ManagedInstance<ChildrenTraverseProcessor> childrenTraverseProcessor);  CloneNodeCommand(final Node candidate, final String parentUuid, final Point2D position, final Consumer<Node> callback); @Override CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context); List<CommandResult<RuleViolation>> processChildrenNodes(GraphCommandExecutionContext context); @Override CommandResult<RuleViolation> undo(GraphCommandExecutionContext context); Node<View, Edge> getClone(); Node<Definition, Edge> getCandidate(); List<Command<GraphCommandExecutionContext, RuleViolation>> getChildrenCommands();  }