Search in sources :

Example 1 with MutableMapDependencyGraph

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

the class CondaListParser method parse.

public DependencyGraph parse(String listJsonText, String infoJsonText) {
    final Type listType = new TypeToken<ArrayList<CondaListElement>>() {
    }.getType();
    final List<CondaListElement> condaList = gson.fromJson(listJsonText, listType);
    final CondaInfo condaInfo = gson.fromJson(infoJsonText, CondaInfo.class);
    final String platform = condaInfo.getPlatform();
    MutableDependencyGraph graph = new MutableMapDependencyGraph();
    for (CondaListElement condaListElement : condaList) {
        graph.addChildToRoot(condaListElementToDependency(platform, condaListElement));
    }
    return graph;
}
Also used : MutableDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) MutableMapDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph)

Example 2 with MutableMapDependencyGraph

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

the class CpanPackager method makeDependencyGraph.

public DependencyGraph makeDependencyGraph(List<String> cpanListText, List<String> directDependenciesText) {
    Map<String, NameVersionNode> allModules = cpanListParser.parse(cpanListText);
    List<String> directModuleNames = getDirectModuleNames(directDependenciesText);
    MutableDependencyGraph graph = new MutableMapDependencyGraph();
    for (String moduleName : directModuleNames) {
        NameVersionNode nameVersionNode = allModules.get(moduleName);
        if (null != nameVersionNode) {
            nameVersionNode.setName(nameVersionNode.getName().replace("::", "-"));
            Dependency module = nameVersionNodeTransformer.addNameVersionNodeToDependencyGraph(graph, Forge.CPAN, nameVersionNode);
            graph.addChildToRoot(module);
        } else {
            logger.warn(String.format("Could node find resolved version for module: %s", moduleName));
        }
    }
    return graph;
}
Also used : MutableDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph) NameVersionNode(com.blackducksoftware.integration.hub.detect.nameversion.NameVersionNode) MutableMapDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph) Dependency(com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)

Example 3 with MutableMapDependencyGraph

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

the class NameVersionNodeTransformer method createDependencyGraph.

public DependencyGraph createDependencyGraph(final Forge defaultForge, final NameVersionNode nameVersionNode, final Boolean rootIsRealRoot) {
    final MutableDependencyGraph graph = new MutableMapDependencyGraph();
    final Dependency root = addNameVersionNodeToDependencyGraph(graph, defaultForge, nameVersionNode);
    if (rootIsRealRoot) {
        graph.addChildToRoot(root);
    } else {
        graph.addChildrenToRoot(graph.getChildrenForParent(root));
    }
    return graph;
}
Also used : MutableDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph) MutableMapDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph) Dependency(com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)

Example 4 with MutableMapDependencyGraph

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

the class GradleReportParser method clearState.

private void clearState() {
    rootProjectName = "";
    rootProjectVersionName = "";
    projectSourcePath = "";
    projectGroup = "";
    projectName = "";
    projectVersionName = "";
    processingMetaData = false;
    graph = new MutableMapDependencyGraph();
    nodeStack = new Stack<>();
    previousNode = null;
    clearConfigurationState();
}
Also used : MutableMapDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph)

Example 5 with MutableMapDependencyGraph

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

the class CocoapodsPackager method extractDependencyGraph.

public DependencyGraph extractDependencyGraph(final String podLockText) throws IOException {
    YAMLMapper mapper = new YAMLMapper();
    PodfileLock podfileLock = mapper.readValue(podLockText, PodfileLock.class);
    NameVersionNode root = new NameVersionNode();
    root.setName(String.format("detectRootNode - %s", UUID.randomUUID()));
    final SubcomponentNodeBuilder builder = new SubcomponentNodeBuilder(root);
    for (Pod pod : podfileLock.getPods()) {
        buildNameVersionNode(builder, pod);
    }
    ;
    for (Pod dependency : podfileLock.getDependencies()) {
        NameVersionNode child = new NameVersionNode();
        child.setName(cleanPodName(dependency.getName()));
        builder.addChildNodeToParent(child, root);
    }
    ;
    if (null != podfileLock.getExternalSources() && !podfileLock.getExternalSources().getSources().isEmpty()) {
        for (PodSource podSource : podfileLock.getExternalSources().getSources()) {
            NodeMetadata nodeMetadata = createMetadata(builder, podSource.getName());
            if (null != podSource.getGit() && podSource.getGit().contains("github")) {
                // Change the forge to GitHub when there is better KB support
                nodeMetadata.setForge(Forge.COCOAPODS);
            } else if (null != podSource.getPath() && podSource.getPath().contains("node_modules")) {
                nodeMetadata.setForge(Forge.NPM);
            }
        }
    }
    MutableDependencyGraph graph = new MutableMapDependencyGraph();
    for (NameVersionNode nameVersionNode : builder.build().getChildren()) {
        Dependency childDependency = nameVersionNodeTransformer.addNameVersionNodeToDependencyGraph(graph, Forge.COCOAPODS, nameVersionNode);
        graph.addChildToRoot(childDependency);
    }
    return graph;
}
Also used : NodeMetadata(com.blackducksoftware.integration.hub.detect.nameversion.NodeMetadata) MutableDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph) SubcomponentNodeBuilder(com.blackducksoftware.integration.hub.detect.nameversion.builder.SubcomponentNodeBuilder) NameVersionNode(com.blackducksoftware.integration.hub.detect.nameversion.NameVersionNode) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) MutableMapDependencyGraph(com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph) Dependency(com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)

Aggregations

MutableMapDependencyGraph (com.blackducksoftware.integration.hub.bdio.graph.MutableMapDependencyGraph)5 MutableDependencyGraph (com.blackducksoftware.integration.hub.bdio.graph.MutableDependencyGraph)4 Dependency (com.blackducksoftware.integration.hub.bdio.model.dependency.Dependency)3 NameVersionNode (com.blackducksoftware.integration.hub.detect.nameversion.NameVersionNode)2 NodeMetadata (com.blackducksoftware.integration.hub.detect.nameversion.NodeMetadata)1 SubcomponentNodeBuilder (com.blackducksoftware.integration.hub.detect.nameversion.builder.SubcomponentNodeBuilder)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1