Search in sources :

Example 1 with GraphNode

use of com.paypal.digraph.parser.GraphNode in project hub-detect by blackducksoftware.

the class GraphParserTransformer method transform.

public DependencyGraph transform(final GraphParser graphParser, final String targetArchitecture) {
    final Map<String, GraphNode> nodes = graphParser.getNodes();
    final Map<String, GraphEdge> edges = graphParser.getEdges();
    final LazyExternalIdDependencyGraphBuilder graphBuilder = new LazyExternalIdDependencyGraphBuilder();
    for (final GraphNode graphNode : nodes.values()) {
        final String name = getNameFromNode(graphNode);
        final DependencyId dependencyId = new NameDependencyId(name);
        final Optional<String> version = getVersionFromNode(graphNode);
        if (version.isPresent()) {
            final ExternalId externalId = new ExternalId(Forge.YOCTO);
            externalId.name = name;
            externalId.version = version.get();
            externalId.architecture = targetArchitecture;
            graphBuilder.setDependencyInfo(dependencyId, name, version.get(), externalId);
        }
        graphBuilder.addChildToRoot(dependencyId);
    }
    for (final GraphEdge graphEdge : edges.values()) {
        final DependencyId node1 = new NameDependencyId(getNameFromNode(graphEdge.getNode1()));
        final DependencyId node2 = new NameDependencyId(getNameFromNode(graphEdge.getNode2()));
        graphBuilder.addParentWithChild(node1, node2);
    }
    return graphBuilder.build();
}
Also used : DependencyId(com.synopsys.integration.bdio.model.dependencyid.DependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) NameDependencyId(com.synopsys.integration.bdio.model.dependencyid.NameDependencyId) LazyExternalIdDependencyGraphBuilder(com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) GraphNode(com.paypal.digraph.parser.GraphNode) GraphEdge(com.paypal.digraph.parser.GraphEdge)

Aggregations

GraphEdge (com.paypal.digraph.parser.GraphEdge)1 GraphNode (com.paypal.digraph.parser.GraphNode)1 LazyExternalIdDependencyGraphBuilder (com.synopsys.integration.bdio.graph.builder.LazyExternalIdDependencyGraphBuilder)1 DependencyId (com.synopsys.integration.bdio.model.dependencyid.DependencyId)1 NameDependencyId (com.synopsys.integration.bdio.model.dependencyid.NameDependencyId)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1