Search in sources :

Example 11 with MutableDependencyGraph

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

the class CodeLocationAssembler method generateCodeLocation.

public DetectCodeLocation generateCodeLocation(final Forge defaultForge, final File rootDir, final List<Dependency> bdioComponents) {
    final MutableDependencyGraph dependencyGraph = populateGraph(bdioComponents);
    final ExternalId externalId = externalIdFactory.createPathExternalId(defaultForge, rootDir.toString());
    return new DetectCodeLocation.Builder(DetectCodeLocationType.CLANG, rootDir.toString(), externalId, dependencyGraph).build();
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId)

Example 12 with MutableDependencyGraph

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

the class Rebar3TreeParser method parseRebarTreeOutput.

public RebarParseResult parseRebarTreeOutput(final List<String> dependencyTreeOutput, final String sourcePath) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    final DependencyHistory history = new DependencyHistory();
    Dependency project = null;
    for (final String line : dependencyTreeOutput) {
        if (!line.contains(HORIZONTAL_SEPARATOR_CHARACTER)) {
            continue;
        }
        final Dependency currentDependency = createDependencyFromLine(line);
        final int lineLevel = getDependencyLevelFromLine(line);
        try {
            history.clearDependenciesDeeperThan(lineLevel);
        } catch (final IllegalStateException e) {
            logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage()));
        }
        if (history.isEmpty() && isProject(line)) {
            project = currentDependency;
        } else if (history.getLastDependency().equals(project)) {
            graph.addChildToRoot(currentDependency);
        } else if (history.isEmpty()) {
            graph.addChildToRoot(currentDependency);
        } else {
            graph.addChildWithParents(currentDependency, history.getLastDependency());
        }
        history.add(currentDependency);
    }
    if (project == null) {
        final ExternalId projectExternalId = externalIdFactory.createPathExternalId(Forge.HEX, sourcePath);
        project = new Dependency("", "", projectExternalId);
    }
    final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.HEX, project.name, project.version);
    final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.HEX, sourcePath, externalId, graph).build();
    return new RebarParseResult(project.name, project.version, codeLocation);
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) DependencyHistory(com.blackducksoftware.integration.hub.detect.util.DependencyHistory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 13 with MutableDependencyGraph

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

the class VndrParser method parseVendorConf.

public DependencyGraph parseVendorConf(final List<String> vendorConfContents) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    // TODO test against moby
    vendorConfContents.forEach(line -> {
        if (StringUtils.isNotBlank(line) && !line.startsWith("#")) {
            final String[] parts = line.split(" ");
            final ExternalId dependencyExternalId = externalIdFactory.createNameVersionExternalId(Forge.GOLANG, parts[0], parts[1]);
            final Dependency dependency = new Dependency(parts[0], parts[1], dependencyExternalId);
            graph.addChildToRoot(dependency);
        }
    });
    return graph;
}
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)

Example 14 with MutableDependencyGraph

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

the class CpanListParser method parse.

public DependencyGraph parse(final List<String> cpanListText, final List<String> directDependenciesText) {
    final Map<String, String> nameVersionMap = createNameVersionMap(cpanListText);
    final List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    for (final String moduleName : directModuleNames) {
        final String version = nameVersionMap.get(moduleName);
        if (null != version) {
            final String name = moduleName.replace("::", "-");
            final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.CPAN, name, version);
            final Dependency dependency = new Dependency(name, version, externalId);
            graph.addChildToRoot(dependency);
        } else {
            logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
        }
    }
    return graph;
}
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)

Example 15 with MutableDependencyGraph

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

the class AggregateBdioCreator method createAggregateDependencyGraph.

private DependencyGraph createAggregateDependencyGraph(File sourcePath, final List<DetectCodeLocation> codeLocations) {
    final MutableDependencyGraph aggregateDependencyGraph = simpleBdioFactory.createMutableDependencyGraph();
    for (final DetectCodeLocation detectCodeLocation : codeLocations) {
        final Dependency codeLocationDependency = createAggregateDependency(sourcePath, detectCodeLocation);
        aggregateDependencyGraph.addChildrenToRoot(codeLocationDependency);
        aggregateDependencyGraph.addGraphAsChildrenToParent(codeLocationDependency, detectCodeLocation.getDependencyGraph());
    }
    return aggregateDependencyGraph;
}
Also used : MutableDependencyGraph(com.synopsys.integration.bdio.graph.MutableDependencyGraph) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)19 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)16 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)11 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)8 DependencyHistory (com.blackducksoftware.integration.hub.detect.util.DependencyHistory)4 DependencyGraphCombiner (com.synopsys.integration.bdio.graph.DependencyGraphCombiner)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 DetectConfiguration (com.blackducksoftware.integration.hub.detect.configuration.DetectConfiguration)2 DetectProperty (com.blackducksoftware.integration.hub.detect.configuration.DetectProperty)2 PropertyAuthority (com.blackducksoftware.integration.hub.detect.configuration.PropertyAuthority)2 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)2 NameVersion (com.synopsys.integration.util.NameVersion)2 File (java.io.File)2 Arrays (java.util.Arrays)2