use of com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode in project synopsys-detect by blackducksoftware.
the class ConanCodeLocationGenerator method addNodeChildrenUnderNode.
private void addNodeChildrenUnderNode(ExternalIdFactory externalIdFactory, MutableMapDependencyGraph dependencyGraph, int depth, ConanGraphNode currentNode, Dependency currentDep) throws DetectableException {
Consumer<Dependency> childAdder;
if (depth == 0) {
childAdder = dependencyGraph::addChildToRoot;
} else {
childAdder = childDep -> dependencyGraph.addChildWithParent(childDep, currentDep);
}
for (ConanGraphNode childNode : currentNode.getChildren()) {
Dependency childDep = generateDependency(externalIdFactory, childNode);
childAdder.accept(childDep);
addNodeChildrenUnderNode(externalIdFactory, dependencyGraph, depth + 1, childNode, childDep);
}
}
use of com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode in project synopsys-detect by blackducksoftware.
the class ConanCodeLocationGenerator method generateCodeLocationFromNodeMap.
@NotNull
public ConanDetectableResult generateCodeLocationFromNodeMap(ExternalIdFactory externalIdFactory, Map<String, ConanNode<String>> nodes) throws DetectableException {
logger.debug("Generating code location from {} dependencies", nodes.keySet().size());
Optional<ConanNode<String>> rootNode = getRoot(nodes.values());
if (!rootNode.isPresent()) {
throw new DetectableException("No root node found");
}
ConanGraphNode rootGraphNode = new ConanGraphNode(rootNode.get());
populateGraphUnderNode(rootGraphNode, nodes);
DependencyGraph dependencyGraph = new BasicDependencyGraph();
CodeLocation codeLocation = generateCodeLocationFromConanGraph(externalIdFactory, dependencyGraph, rootGraphNode);
return new ConanDetectableResult(rootGraphNode.getConanNode().getName().orElse(null), rootGraphNode.getConanNode().getVersion().orElse(null), codeLocation);
}
use of com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode in project synopsys-detect by blackducksoftware.
the class ConanCodeLocationGenerator method populateGraphUnderNode.
private void populateGraphUnderNode(ConanGraphNode curGraphNode, Map<String, ConanNode<String>> graphNodes) throws DetectableException {
Set<String> dependencyRefs = new HashSet<>(curGraphNode.getConanNode().getRequiresRefs().orElse(new ArrayList<>(0)));
dependencyTypeFilter.ifShouldInclude(ConanDependencyType.BUILD, curGraphNode.getConanNode().getBuildRequiresRefs(), dependencyRefs::addAll);
for (String childRef : dependencyRefs) {
ConanNode<String> childNode = graphNodes.get(childRef);
if (childNode == null) {
throw new DetectableException(String.format("%s requires non-existent node %s", curGraphNode.getConanNode().getRef(), childRef));
}
ConanGraphNode childGraphNode = new ConanGraphNode(childNode);
populateGraphUnderNode(childGraphNode, graphNodes);
curGraphNode.addChild(childGraphNode);
}
}
use of com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode in project synopsys-detect by blackducksoftware.
the class ConanCodeLocationGenerator method addNodeChildrenUnderNode.
private void addNodeChildrenUnderNode(ExternalIdFactory externalIdFactory, DependencyGraph dependencyGraph, int depth, ConanGraphNode currentNode, Dependency currentDep) throws DetectableException {
Consumer<Dependency> childAdder;
if (depth == 0) {
childAdder = dependencyGraph::addChildToRoot;
} else {
childAdder = childDep -> dependencyGraph.addChildWithParent(childDep, currentDep);
}
for (ConanGraphNode childNode : currentNode.getChildren()) {
Dependency childDep = generateDependency(externalIdFactory, childNode);
childAdder.accept(childDep);
addNodeChildrenUnderNode(externalIdFactory, dependencyGraph, depth + 1, childNode, childDep);
}
}
Aggregations