private String determineFutureNodeName( RouteNode node, MovePoint movePoint, int currentStep, Set nodesProcessed) throws InvalidActionTakenException { if (nodesProcessed.contains(node.getRouteNodeId())) { throw new InvalidActionTakenException( "Detected a cycle at node " + node.getRouteNodeName() + " when attempting to move document."); } nodesProcessed.add(node.getRouteNodeId()); if (currentStep == movePoint.getStepsToMove()) { return node.getRouteNodeName(); } List nextNodes = node.getNextNodes(); if (nextNodes.size() == 0) { throw new InvalidActionTakenException( "Could not proceed forward, there are no more nodes in the route. Halted on step " + currentStep); } if (nextNodes.size() != 1) { throw new InvalidActionTakenException( "Cannot move forward in a multi-branch path. Located " + nextNodes.size() + " branches. Halted on step " + currentStep); } return determineFutureNodeName( (RouteNode) nextNodes.get(0), movePoint, currentStep + 1, nodesProcessed); }
@Override public List<String> getNextNodeIds() { List<String> nextNodeIds = new ArrayList<String>(); if (nextNodeIds != null) { for (RouteNode nextNode : nextNodes) { nextNodeIds.add(nextNode.getRouteNodeId().toString()); } } return nextNodeIds; }
@Override public List<String> getPreviousNodeIds() { List<String> previousNodeIds = new ArrayList<String>(); if (previousNodes != null) { for (RouteNode previousNode : previousNodes) { previousNodeIds.add(previousNode.getRouteNodeId().toString()); } } return previousNodeIds; }