Search in sources :

Example 1 with ProjectInspectorModule

use of com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorModule in project synopsys-detect by blackducksoftware.

the class ProjectInspectorParser method codeLocationFromModule.

public CodeLocation codeLocationFromModule(ProjectInspectorModule module) {
    Map<String, Dependency> lookup = new HashMap<>();
    // build the map of all external ids
    module.dependencies.forEach(dependency -> lookup.computeIfAbsent(dependency.id, (missingId) -> convertProjectInspectorDependency(dependency)));
    // and add them to the graph
    DependencyGraph mutableDependencyGraph = new BasicDependencyGraph();
    module.dependencies.forEach(moduleDependency -> {
        Dependency dependency = lookup.get(moduleDependency.id);
        moduleDependency.includedBy.forEach(parent -> {
            if ("DIRECT".equals(parent)) {
                mutableDependencyGraph.addChildToRoot(dependency);
            } else if (lookup.containsKey(parent)) {
                mutableDependencyGraph.addChildWithParent(dependency, lookup.get(parent));
            } else {
                // Theoretically should not happen according to PI devs. -jp
                throw new RuntimeException("An error occurred reading the project inspector output." + " An unknown parent dependency was encountered '" + parent + "' while including dependency '" + moduleDependency.name + "'.");
            }
        });
    });
    return new CodeLocation(mutableDependencyGraph, new File(module.moduleFile));
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Logger(org.slf4j.Logger) Forge(com.synopsys.integration.bdio.model.Forge) ProjectInspectorOutput(com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorOutput) LoggerFactory(org.slf4j.LoggerFactory) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) HashMap(java.util.HashMap) ProjectInspectorModule(com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorModule) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Gson(com.google.gson.Gson) Map(java.util.Map) ProjectInspectorDependency(com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorDependency) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) ProjectInspectorMavenCoordinate(com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorMavenCoordinate) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) HashMap(java.util.HashMap) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) ProjectInspectorDependency(com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorDependency) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) File(java.io.File)

Aggregations

Gson (com.google.gson.Gson)1 BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 Forge (com.synopsys.integration.bdio.model.Forge)1 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 ProjectInspectorDependency (com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorDependency)1 ProjectInspectorMavenCoordinate (com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorMavenCoordinate)1 ProjectInspectorModule (com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorModule)1 ProjectInspectorOutput (com.synopsys.integration.detectable.detectables.projectinspector.model.ProjectInspectorOutput)1 File (java.io.File)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1