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