Search in sources :

Example 1 with ConanGraphNode

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);
    }
}
Also used : ConanGraphNode(com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 2 with ConanGraphNode

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);
}
Also used : ConanGraphNode(com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode) ConanNode(com.synopsys.integration.detectable.detectables.conan.graph.ConanNode) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ConanGraphNode

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);
    }
}
Also used : ConanGraphNode(com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode) ArrayList(java.util.ArrayList) DetectableException(com.synopsys.integration.detectable.detectable.exception.DetectableException) HashSet(java.util.HashSet)

Example 4 with ConanGraphNode

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);
    }
}
Also used : ConanGraphNode(com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

ConanGraphNode (com.synopsys.integration.detectable.detectables.conan.graph.ConanGraphNode)4 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)2 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)2 BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 ConanNode (com.synopsys.integration.detectable.detectables.conan.graph.ConanNode)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 NotNull (org.jetbrains.annotations.NotNull)1