Search in sources :

Example 1 with ConfigReader

use of org.codice.ddf.admin.configurator.ConfigReader in project admin-console-beta by connexta.

the class SourceUtilCommons method getAllSourceReferences.

public static List<Source> getAllSourceReferences(ConfiguratorFactory configuratorFactory) {
    List<Source> sources = new ArrayList<>();
    ConfigReader configReader = configuratorFactory.getConfigReader();
    sources.addAll(configReader.getServices(FederatedSource.class, null));
    sources.addAll(configReader.getServices(ConnectedSource.class, null));
    return sources;
}
Also used : FederatedSource(ddf.catalog.source.FederatedSource) ConnectedSource(ddf.catalog.source.ConnectedSource) ConfigReader(org.codice.ddf.admin.configurator.ConfigReader) ArrayList(java.util.ArrayList) Source(ddf.catalog.source.Source) ConnectedSource(ddf.catalog.source.ConnectedSource) InputSource(org.xml.sax.InputSource) FederatedSource(ddf.catalog.source.FederatedSource)

Example 2 with ConfigReader

use of org.codice.ddf.admin.configurator.ConfigReader in project admin-console-beta by connexta.

the class SourceUtilCommons method getSourceConfigurations.

/**
     * Gets the configurations for the given factoryPids using the {@link ConfiguratorFactory}. A mapper is used
     * to transform the service properties to a {@link SourceConfigUnionField}. Providing the pid parameter
     * will return only the configuration with that pid.
     *
     * @param factoryPids factory pids to lookup configurations for
     * @param mapper a {@link Function} taking a map of string to objects and returning a {@code SourceConfigUnionField}
     * @param pid a servicePid to select a single configuration, returns all configs when null or empty
     * @return a list of {@code SourceInfoField}s configured in the system
     */
public static ListField<SourceInfoField> getSourceConfigurations(List<String> factoryPids, Function<Map<String, Object>, SourceConfigUnionField> mapper, String pid, ConfiguratorFactory configuratorFactory) {
    ListFieldImpl<SourceInfoField> sourceInfoListField = new ListFieldImpl<>(SourceInfoField.class);
    ConfigReader configReader = configuratorFactory.getConfigReader();
    if (StringUtils.isNotEmpty(pid)) {
        SourceConfigUnionField config = mapper.apply(configReader.getConfig(pid));
        sourceInfoListField.add(createSourceInfoField(true, config));
        populateSourceAvailability(sourceInfoListField.getList(), configuratorFactory);
        return sourceInfoListField;
    }
    factoryPids.stream().flatMap(factoryPid -> configReader.getManagedServiceConfigs(factoryPid).values().stream()).map(mapper).forEach(config -> sourceInfoListField.add(createSourceInfoField(false, config)));
    populateSourceAvailability(sourceInfoListField.getList(), configuratorFactory);
    return sourceInfoListField;
}
Also used : ListFieldImpl(org.codice.ddf.admin.common.fields.base.ListFieldImpl) ConfigReader(org.codice.ddf.admin.configurator.ConfigReader) SourceConfigUnionField(org.codice.ddf.admin.sources.fields.type.SourceConfigUnionField) SourceInfoField(org.codice.ddf.admin.sources.fields.SourceInfoField)

Aggregations

ConfigReader (org.codice.ddf.admin.configurator.ConfigReader)2 ConnectedSource (ddf.catalog.source.ConnectedSource)1 FederatedSource (ddf.catalog.source.FederatedSource)1 Source (ddf.catalog.source.Source)1 ArrayList (java.util.ArrayList)1 ListFieldImpl (org.codice.ddf.admin.common.fields.base.ListFieldImpl)1 SourceInfoField (org.codice.ddf.admin.sources.fields.SourceInfoField)1 SourceConfigUnionField (org.codice.ddf.admin.sources.fields.type.SourceConfigUnionField)1 InputSource (org.xml.sax.InputSource)1