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;
}
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);
}
}
}
}
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);
}
}
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++);
}
}
}
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);
}
}
Aggregations