Search in sources :

Example 1 with DummyNode

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);
        }
    }
}
Also used : DummyNode(com.thoughtworks.go.domain.valuestreammap.DummyNode) DummyNode(com.thoughtworks.go.domain.valuestreammap.DummyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 2 with DummyNode

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;
}
Also used : DummyNode(com.thoughtworks.go.domain.valuestreammap.DummyNode)

Aggregations

DummyNode (com.thoughtworks.go.domain.valuestreammap.DummyNode)2 Node (com.thoughtworks.go.domain.valuestreammap.Node)1