Search in sources :

Example 21 with MutableMapDependencyGraph

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

the class SbtDependencyResolver method resolveReport.

public SbtDependencyModule resolveReport(final SbtReport report) {
    final ExternalId rootId = externalIdFactory.createMavenExternalId(report.getOrganisation(), report.getModule(), report.getRevision());
    logger.debug("Created external id: " + rootId.toString());
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    logger.debug("Dependencies found: " + report.getDependencies().size());
    report.getDependencies().forEach(module -> {
        logger.debug("Revisions found: " + module.getRevisions().size());
        module.getRevisions().forEach(revision -> {
            logger.debug("Callers found: " + revision.getCallers().size());
            final ExternalId id = externalIdFactory.createMavenExternalId(module.getOrganisation(), module.getName(), revision.getName());
            final Dependency child = new Dependency(module.getName(), revision.getName(), id);
            revision.getCallers().forEach(caller -> {
                final ExternalId parentId = externalIdFactory.createMavenExternalId(caller.getOrganisation(), caller.getName(), caller.getRevision());
                final Dependency parent = new Dependency(caller.getName(), caller.getRevision(), parentId);
                logger.debug("Caller id: " + parentId.toString());
                if (rootId.equals(parentId)) {
                    graph.addChildToRoot(child);
                } else {
                    graph.addParentWithChild(parent, child);
                }
            });
        });
    });
    final SbtDependencyModule module = new SbtDependencyModule();
    module.name = report.getModule();
    module.version = report.getRevision();
    module.org = report.getOrganisation();
    module.graph = graph;
    module.configuration = report.getConfiguration();
    return module;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)21 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)17 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)12 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)11 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)8 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 DependencyHistory (com.blackducksoftware.integration.hub.detect.util.DependencyHistory)4 List (java.util.List)4 ArrayList (java.util.ArrayList)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 DependencyGraphCombiner (com.synopsys.integration.bdio.graph.DependencyGraphCombiner)2 Forge (com.synopsys.integration.bdio.model.Forge)2 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)2 NameVersion (com.synopsys.integration.util.NameVersion)2 Map (java.util.Map)2 Optional (java.util.Optional)2 Set (java.util.Set)2