Search in sources :

Example 1 with FeatureField

use of org.codice.ddf.admin.query.dev.system.fields.FeatureField 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)

Example 2 with FeatureField

use of org.codice.ddf.admin.query.dev.system.fields.FeatureField in project admin-console-beta by connexta.

the class FeatureUtils method featureToField.

private FeatureField featureToField(Feature feat, Map<String, BundleField> bundlesByLocation) {
    List<String> featDeps = feat.getDependencies().stream().map(Dependency::getName).collect(Collectors.toList());
    List<BundleField> bundleDepLocations = feat.getBundles().stream().map(BundleInfo::getLocation).map(loc -> createBundleFromLocation(loc, bundlesByLocation)).collect(Collectors.toList());
    return new FeatureField().name(feat.getName()).featDescription(feat.getDescription()).state(feat.getInstall()).id(feat.getId()).repoUrl(feat.getRepositoryUrl()).addFeatureDeps(featDeps).addBundleDeps(bundleDepLocations);
}
Also used : Dependency(org.apache.karaf.features.Dependency) Arrays(java.util.Arrays) BundleInfo(org.apache.karaf.features.BundleInfo) Logger(org.slf4j.Logger) Feature(org.apache.karaf.features.Feature) LoggerFactory(org.slf4j.LoggerFactory) Collectors(java.util.stream.Collectors) FeaturesService(org.apache.karaf.features.FeaturesService) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField) List(java.util.List) Map(java.util.Map) Collections(java.util.Collections) BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) BundleField(org.codice.ddf.admin.query.dev.system.fields.BundleField) BundleInfo(org.apache.karaf.features.BundleInfo) FeatureField(org.codice.ddf.admin.query.dev.system.fields.FeatureField)

Aggregations

List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Feature (org.apache.karaf.features.Feature)2 FeatureField (org.codice.ddf.admin.query.dev.system.fields.FeatureField)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Paths (java.nio.file.Paths)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Set (java.util.Set)1 BundleInfo (org.apache.karaf.features.BundleInfo)1 Dependency (org.apache.karaf.features.Dependency)1 FeaturesService (org.apache.karaf.features.FeaturesService)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