Search in sources :

Example 1 with DependencyEdge

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;
}
Also used : DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph) LoggerFactory(org.slf4j.LoggerFactory) DIRECTORY_DOES_NOT_EXIST(org.codice.ddf.admin.common.report.message.DefaultMessages.DIRECTORY_DOES_NOT_EXIST) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) DefaultMessages.failedPersistError(org.codice.ddf.admin.common.report.message.DefaultMessages.failedPersistError) ImmutableList(com.google.common.collect.ImmutableList) FAILED_PERSIST(org.codice.ddf.admin.common.report.message.DefaultMessages.FAILED_PERSIST) Map(java.util.Map) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) Field(org.codice.ddf.admin.api.Field) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) BaseFunctionField(org.codice.ddf.admin.common.fields.base.BaseFunctionField) Feature(org.apache.karaf.features.Feature) Set(java.util.Set) GraphMLExporter(org.jgrapht.ext.GraphMLExporter) Collectors(java.util.stream.Collectors) FeatureUtils(org.codice.ddf.admin.query.dev.system.dependency.FeatureUtils) List(java.util.List) Paths(java.nio.file.Paths) DependencyEdge(org.codice.ddf.admin.query.dev.system.graph.DependencyEdge) DirectedGraph(org.jgrapht.DirectedGraph) FeatureGraphProvider(org.codice.ddf.admin.query.dev.system.graph.FeatureGraphProvider) DirectoryField(org.codice.ddf.admin.common.fields.common.DirectoryField) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) BooleanField(org.codice.ddf.admin.common.fields.base.scalar.BooleanField) FunctionField(org.codice.ddf.admin.api.fields.FunctionField) Field(org.codice.ddf.admin.api.Field) BaseFunctionField(org.codice.ddf.admin.common.fields.base.BaseFunctionField) DirectoryField(org.codice.ddf.admin.common.fields.common.DirectoryField) DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) DependencyEdge(org.codice.ddf.admin.query.dev.system.graph.DependencyEdge) Feature(org.apache.karaf.features.Feature) DirectedPseudograph(org.jgrapht.graph.DirectedPseudograph)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Paths (java.nio.file.Paths)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Feature (org.apache.karaf.features.Feature)1 Field (org.codice.ddf.admin.api.Field)1 FunctionField (org.codice.ddf.admin.api.fields.FunctionField)1 BaseFunctionField (org.codice.ddf.admin.common.fields.base.BaseFunctionField)1 BooleanField (org.codice.ddf.admin.common.fields.base.scalar.BooleanField)1 DirectoryField (org.codice.ddf.admin.common.fields.common.DirectoryField)1 DIRECTORY_DOES_NOT_EXIST (org.codice.ddf.admin.common.report.message.DefaultMessages.DIRECTORY_DOES_NOT_EXIST)1 FAILED_PERSIST (org.codice.ddf.admin.common.report.message.DefaultMessages.FAILED_PERSIST)1 DefaultMessages.failedPersistError (org.codice.ddf.admin.common.report.message.DefaultMessages.failedPersistError)1 FeatureUtils (org.codice.ddf.admin.query.dev.system.dependency.FeatureUtils)1 FeatureField (org.codice.ddf.admin.query.dev.system.fields.FeatureField)1 DependencyEdge (org.codice.ddf.admin.query.dev.system.graph.DependencyEdge)1 FeatureGraphProvider (org.codice.ddf.admin.query.dev.system.graph.FeatureGraphProvider)1