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