use of org.codice.ddf.admin.sources.fields.SourceInfoField 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;
}
use of org.codice.ddf.admin.sources.fields.SourceInfoField in project admin-console-beta by connexta.
the class SourceUtilCommons method createSourceInfoField.
public static SourceInfoField createSourceInfoField(boolean isAvailable, SourceConfigUnionField config) {
config.credentials().password(FLAG_PASSWORD);
SourceInfoField sourceInfoField = new SourceInfoField();
sourceInfoField.isAvaliable(isAvailable);
sourceInfoField.configuration(config);
return sourceInfoField;
}
Aggregations