Search in sources :

Example 21 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class GoVendorJsonParser method parseVendorJson.

public DependencyGraph parseVendorJson(Gson gson, String vendorJsonContents) {
    DependencyGraph graph = new BasicDependencyGraph();
    VendorJson vendorJsonData = gson.fromJson(vendorJsonContents, VendorJson.class);
    logger.trace(String.format("vendorJsonData: %s", vendorJsonData));
    for (PackageData pkg : vendorJsonData.getPackages()) {
        if (StringUtils.isNotBlank(pkg.getPath()) && StringUtils.isNotBlank(pkg.getRevision())) {
            ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, pkg.getPath(), pkg.getRevision());
            Dependency dependency = new Dependency(pkg.getPath(), pkg.getRevision(), dependencyExternalId);
            logger.trace(String.format("dependency: %s", dependency.getExternalId().toString()));
            graph.addChildToRoot(dependency);
        } else {
            logger.debug(String.format("Omitting package path:'%s', revision:'%s' (one or both of path, revision is/are missing)", pkg.getPath(), pkg.getRevision()));
        }
    }
    return graph;
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) VendorJson(com.synopsys.integration.detectable.detectables.go.vendor.model.VendorJson) PackageData(com.synopsys.integration.detectable.detectables.go.vendor.model.PackageData)

Example 22 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class MavenCodeLocationPackager method initializeCurrentMavenProject.

private void initializeCurrentMavenProject(ExcludedIncludedWildcardFilter modulesFilter, String sourcePath, String line) {
    // this is the first line of a new code location, the following lines will be the tree of dependencies for this code location
    currentGraph = new BasicDependencyGraph();
    MavenParseResult mavenProject = createMavenParseResult(sourcePath, line, currentGraph);
    if (null != mavenProject && modulesFilter.shouldInclude(mavenProject.getProjectName())) {
        logger.trace(String.format("Project: %s", mavenProject.getProjectName()));
        this.currentMavenProject = mavenProject;
        codeLocations.add(mavenProject);
    } else {
        logger.trace("Project: unknown");
        currentMavenProject = null;
        dependencyParentStack.clear();
        parsingProjectSection = false;
        level = 0;
    }
}
Also used : BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 23 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class VndrParser method parseVendorConf.

public DependencyGraph parseVendorConf(List<String> vendorConfContents) {
    DependencyGraph graph = new BasicDependencyGraph();
    vendorConfContents.stream().filter(this::shouldIncludeLine).map(this::parseLineToDependency).filter(Optional::isPresent).map(Optional::get).forEach(graph::addChildToRoot);
    return graph;
}
Also used : Optional(java.util.Optional) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph)

Example 24 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class SbtGraphParserTransformer method transformDotToGraph.

public DependencyGraph transformDotToGraph(GraphParser graphParser, String projectNodeId) {
    DependencyGraph graph = new BasicDependencyGraph();
    for (GraphEdge graphEdge : graphParser.getEdges().values()) {
        Dependency parent = sbtDotGraphNodeParser.nodeToDependency(graphEdge.getNode1().getId());
        Dependency child = sbtDotGraphNodeParser.nodeToDependency(graphEdge.getNode2().getId());
        if (projectNodeId.equals(graphEdge.getNode1().getId())) {
            graph.addChildToRoot(child);
        } else {
            graph.addChildWithParent(child, parent);
        }
    }
    return graph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) GraphEdge(com.paypal.digraph.parser.GraphEdge)

Example 25 with BasicDependencyGraph

use of com.synopsys.integration.bdio.graph.BasicDependencyGraph in project synopsys-detect by blackducksoftware.

the class SbtGraphParserTransformer method transformDotToGraph.

public DependencyGraph transformDotToGraph(GraphParser graphParser, Set<String> projectNodeIds) {
    DependencyGraph graph = new BasicDependencyGraph();
    for (GraphEdge graphEdge : graphParser.getEdges().values()) {
        Dependency parent = sbtDotGraphNodeParser.nodeToDependency(graphEdge.getNode1().getId());
        Dependency child = sbtDotGraphNodeParser.nodeToDependency(graphEdge.getNode2().getId());
        if (projectNodeIds.contains(graphEdge.getNode1().getId())) {
            graph.addChildToRoot(parent);
        }
        graph.addChildWithParent(child, parent);
    }
    return graph;
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) GraphEdge(com.paypal.digraph.parser.GraphEdge)

Aggregations

BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)43 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)38 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)26 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)16 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 List (java.util.List)7 Forge (com.synopsys.integration.bdio.model.Forge)6 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)5 ArrayList (java.util.ArrayList)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 File (java.io.File)4 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 Gson (com.google.gson.Gson)3 NotNull (org.jetbrains.annotations.NotNull)3 GraphEdge (com.paypal.digraph.parser.GraphEdge)2 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)2 DependencyHistory (com.synopsys.integration.detectable.detectable.util.DependencyHistory)2 Extraction (com.synopsys.integration.detectable.extraction.Extraction)2