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