Search in sources :

Example 11 with Node

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

the class CrossingMinimization method getNodeBaryCentre.

private NodeBaryCentre getNodeBaryCentre(Node node, List<Node> relatedNodes) {
    if (relatedNodes.isEmpty()) {
        return new NodeBaryCentre(node, Float.valueOf(node.getDepth()));
    }
    float sum = 0f;
    for (Node relatedNode : relatedNodes) {
        int depth = relatedNode.getDepth();
        sum += depth;
    }
    float averageDepth = sum / relatedNodes.size();
    return new NodeBaryCentre(node, averageDepth);
}
Also used : Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 12 with Node

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

the class DownstreamInstancePopulator method populateRevisionsForAllChildrenOf.

private void populateRevisionsForAllChildrenOf(Node node, Set<Revision> visitedRevisions) {
    for (Revision revision : node.revisions()) {
        if (visitedRevisions.contains(revision)) {
            continue;
        }
        visitedRevisions.add(revision);
        for (Node child : node.getChildren()) {
            List<PipelineIdentifier> pipelineIdentifiers = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial(child.getName(), ((PipelineRevision) revision).getPipelineIdentifier());
            addRevisionsToNode(child, pipelineIdentifiers);
            populateRevisionsForAllChildrenOf(child, visitedRevisions);
        }
    }
}
Also used : Revision(com.thoughtworks.go.domain.valuestreammap.Revision) PipelineRevision(com.thoughtworks.go.domain.valuestreammap.PipelineRevision) PipelineIdentifier(com.thoughtworks.go.domain.PipelineIdentifier) Node(com.thoughtworks.go.domain.valuestreammap.Node)

Example 13 with Node

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

the class DownstreamInstancePopulator method apply.

public void apply(ValueStreamMap valueStreamMap) {
    if (valueStreamMap.getCurrentPipeline() != null) {
        Node currentPipeline = valueStreamMap.getCurrentPipeline();
        populateRevisionsForAllChildrenOf(currentPipeline, new HashSet<>());
    } else {
        Node currentMaterial = valueStreamMap.getCurrentMaterial();
        MaterialInstance currentMaterialInstance = valueStreamMap.getCurrentMaterialInstance();
        populateRevisionsFor(currentMaterial, currentMaterialInstance, new HashSet<>());
    }
}
Also used : Node(com.thoughtworks.go.domain.valuestreammap.Node) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance)

Example 14 with Node

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

the class DummyNodeCreation method apply.

public void apply(ValueStreamMap graph, NodeLevelMap nodeLevelMap) {
    List<Node> nodesWithNoParents = graph.getRootNodes();
    Set<Node> visitedNodes = new HashSet<>();
    for (Node current : nodesWithNoParents) {
        addDummyNodesIfRequired(current, nodeLevelMap, visitedNodes);
    }
}
Also used : DummyNode(com.thoughtworks.go.domain.valuestreammap.DummyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) HashSet(java.util.HashSet)

Example 15 with Node

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

the class LevelAssignment method apply.

public NodeLevelMap apply(ValueStreamMap valueStreamMap) {
    Node rootNode = valueStreamMap.getCurrentPipeline() != null ? valueStreamMap.getCurrentPipeline() : valueStreamMap.getCurrentMaterial();
    rootNode.setLevel(0);
    if (!rootNode.getParents().isEmpty()) {
        assignLevelsToDependencies(rootNode, new Upstream());
    }
    if (!rootNode.getChildren().isEmpty()) {
        assignLevelsToDependencies(rootNode, new Downstream());
    }
    return levelToNodesMap(valueStreamMap);
}
Also used : 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