use of org.codice.ddf.admin.query.dev.system.graph.DependencyEdge in project admin-console-beta by connexta.
the class CreateFeatureDependencyGraph method createFeatureDependenciesGraph.
private DirectedGraph<Field, DependencyEdge> createFeatureDependenciesGraph(List<FeatureField> features) {
DirectedGraph<Field, DependencyEdge> graph = new DirectedPseudograph<>(DependencyEdge.class);
FEATURE_BUNDLE_VERTEX_PROV.getAttributes().forEach(attri -> exporter.registerAttribute(attri.getAttriName(), attri.getCategory(), attri.getType()));
features.forEach(graph::addVertex);
Map<String, FeatureField> featuresById = features.stream().collect(Collectors.toMap(FeatureField::id, f -> f));
for (FeatureField feature : features) {
for (String featId : feature.featDeps()) {
try {
Feature feat = featureUtils.getFeature(featId);
if (feat != null && featuresById.containsKey(feat.getId())) {
graph.addEdge(feature, featuresById.get(feat.getId()), DependencyEdge.create(null));
} else {
LOGGER.error("Failed to find feature {} while creating feature dependency graph.", featId);
}
} catch (Exception e) {
LOGGER.error("Failed to find feature {} while creating feature dependency graph.", featId, e);
}
}
feature.bundleDeps().forEach(dep -> {
graph.addVertex(dep);
graph.addEdge(feature, dep, DependencyEdge.create(null));
});
}
return graph;
}
Aggregations