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