use of com.thoughtworks.go.domain.valuestreammap.DummyNode in project gocd by gocd.
the class DummyNodeCreation method addDummyNodesIfRequired.
private void addDummyNodesIfRequired(Node node, NodeLevelMap nodeLevelMap, Set<Node> visitedNodes) {
if (visitedNodes.contains(node)) {
return;
}
visitedNodes.add(node);
for (int i = 0; i < node.getChildren().size(); i++) {
Node currentChildNode = node.getChildren().get(i);
if (abs(currentChildNode.getLevel() - node.getLevel()) > 1) {
DummyNode dummyNode = insertDummyNode(node, currentChildNode, nodeLevelMap);
addDummyNodesIfRequired(dummyNode, nodeLevelMap, visitedNodes);
} else {
addDummyNodesIfRequired(currentChildNode, nodeLevelMap, visitedNodes);
}
}
}
use of com.thoughtworks.go.domain.valuestreammap.DummyNode in project gocd by gocd.
the class DummyNodeCreation method insertDummyNode.
private DummyNode insertDummyNode(Node node, Node currentChildNode, NodeLevelMap nodeLevelMap) {
String dummyNodeId = UUID.randomUUID().toString();
DummyNode dummyNode = new DummyNode(dummyNodeId, "dummy-" + dummyNodeId);
dummyNode.setLevel(node.getLevel() + 1);
nodeLevelMap.add(dummyNode);
dummyNode.addParentIfAbsent(node);
dummyNode.addChildIfAbsent(currentChildNode);
node.replaceChildWith(currentChildNode, dummyNode);
currentChildNode.replaceParentWith(node, dummyNode);
return dummyNode;
}