Search in sources :

Example 16 with Node

use of com.thoughtworks.go.domain.valuestreammap.Node in project gocd by gocd.

the class LevelAssignment method levelToNodesMap.

private NodeLevelMap levelToNodesMap(ValueStreamMap valueStreamMap) {
    NodeLevelMap nodeLevelMap = new NodeLevelMap();
    Collection<Node> nodes = valueStreamMap.allNodes();
    for (Node node : nodes) {
        nodeLevelMap.add(node);
    }
    return nodeLevelMap;
}
Also used : Node(com.thoughtworks.go.domain.valuestreammap.Node) NodeLevelMap(com.thoughtworks.go.domain.valuestreammap.NodeLevelMap)

Example 17 with Node

use of com.thoughtworks.go.domain.valuestreammap.Node in project gocd by gocd.

the class RunStagesPopulator method apply.

public void apply(ValueStreamMap graph) {
    for (Node node : graph.allNodes()) {
        for (Revision revision : node.revisions()) {
            if (revision instanceof PipelineRevision) {
                PipelineRevision pipelineRevision = (PipelineRevision) revision;
                Stages latestStages = latestRunStagesForRevsion(pipelineRevision);
                pipelineRevision.addStages(latestStages);
            }
        }
    }
}
Also used : Revision(com.thoughtworks.go.domain.valuestreammap.Revision) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) Node(com.thoughtworks.go.domain.valuestreammap.Node) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) Stages(com.thoughtworks.go.domain.Stages)

Example 18 with Node

use of com.thoughtworks.go.domain.valuestreammap.Node in project gocd by gocd.

the class CrossingMinimization method initializeDepthsFor.

private void initializeDepthsFor(Node node, HashMap<Integer, Integer> levelToDepthMap, TraversalDirection traversalDirection, Set<Node> visited) {
    if (visited.contains(node)) {
        return;
    }
    visited.add(node);
    int depth = 1;
    if (levelToDepthMap.containsKey(node.getLevel())) {
        depth = levelToDepthMap.get(node.getLevel()) + 1;
    }
    if (node.getDepth() == 0) {
        node.setDepth(depth);
        levelToDepthMap.put(node.getLevel(), depth);
    }
    for (Node relatedNode : traversalDirection.getRelatedNodesAtNextLevel(node)) {
        initializeDepthsFor(relatedNode, levelToDepthMap, traversalDirection, visited);
    }
}
Also used : Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 19 with Node

use of com.thoughtworks.go.domain.valuestreammap.Node in project gocd by gocd.

the class CrossingMinimization method reorderByMinDepth.

private void reorderByMinDepth(TraversalDirection traversalDirection) {
    while (traversalDirection.hasNext()) {
        List<Node> nodesAtLevel = traversalDirection.next();
        int depth = 1;
        for (int i = 0; i < nodesAtLevel.size(); i++) {
            Node currentNode = nodesAtLevel.get(i);
            List<Node> relatedNodesAtPreviousLevel = traversalDirection.getRelatedNodesAtPreviousLevel(currentNode);
            int leastDepth = minDepth(relatedNodesAtPreviousLevel);
            if (depth < leastDepth) {
                List<Node> nodesRemaining = nodesAtLevel.subList(i, nodesAtLevel.size());
                int initialSlope = calculateSlope(depth - currentNode.getDepth(), nodesRemaining, traversalDirection);
                int newSlope = calculateSlope(leastDepth - depth, nodesRemaining, traversalDirection);
                if (newSlope < initialSlope) {
                    depth = leastDepth;
                }
            }
            currentNode.setDepth(depth++);
        }
    }
}
Also used : Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 20 with Node

use of com.thoughtworks.go.domain.valuestreammap.Node in project gocd by gocd.

the class DownstreamInstancePopulator method populateRevisionsFor.

private void populateRevisionsFor(Node currentMaterial, MaterialInstance currentMaterialInstance, HashSet<Revision> visitedRevisions) {
    String revision = currentMaterial.revisions().get(0).getRevisionString();
    List<Node> downstreamPipelines = currentMaterial.getChildren();
    for (Node downstreamPipeline : downstreamPipelines) {
        List<PipelineIdentifier> pipelineIdentifiers = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial(downstreamPipeline.getName(), currentMaterialInstance, revision);
        addRevisionsToNode(downstreamPipeline, pipelineIdentifiers);
        populateRevisionsForAllChildrenOf(downstreamPipeline, visitedRevisions);
    }
}
Also used : PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Node(com.thoughtworks.go.domain.valuestreammap.Node)

Aggregations

Node (com.thoughtworks.go.domain.valuestreammap.Node)26 PipelineDependencyNode (com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode)11 SCMDependencyNode (com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode)11 ValueStreamMap (com.thoughtworks.go.domain.valuestreammap.ValueStreamMap)11 Test (org.junit.Test)11 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 PipelineRevision (com.thoughtworks.go.domain.valuestreammap.PipelineRevision)8 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)7 NodeLevelMap (com.thoughtworks.go.domain.valuestreammap.NodeLevelMap)7 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)5 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)4 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)2 PipelineIdentifier (com.thoughtworks.go.domain.PipelineIdentifier)2 Stages (com.thoughtworks.go.domain.Stages)2 Modification (com.thoughtworks.go.domain.materials.Modification)2 DummyNode (com.thoughtworks.go.domain.valuestreammap.DummyNode)2 Revision (com.thoughtworks.go.domain.valuestreammap.Revision)2 Stage (com.thoughtworks.go.domain.Stage)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1