use of org.n52.io.response.extension.MetadataExtension in project series-rest-api by 52North.
the class ParameterController method getExtras.
@Override
public Map<String, Object> getExtras(String resourceId, String locale, MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
LOGGER.debug("getExtras() with id '{}' and query '{}'", resourceId, map);
Map<String, Object> extras = new HashMap<>();
for (MetadataExtension<T> extension : metadataExtensions) {
T from = parameterService.getParameter(resourceId, map);
final Map<String, Object> furtherExtras = extension.getExtras(from, map);
Collection<String> overridableKeys = checkForOverridingData(extras, furtherExtras);
if (!overridableKeys.isEmpty()) {
String[] keys = overridableKeys.toArray(new String[0]);
LOGGER.warn("Metadata extension overrides existing extra data: {}", Arrays.toString(keys));
}
extras.putAll(furtherExtras);
}
return extras;
}
use of org.n52.io.response.extension.MetadataExtension in project series-rest-api by 52North.
the class ParameterController method getExtras.
@Override
public Map<String, Object> getExtras(HttpServletResponse response, String resourceId, String locale, MultiValueMap<String, String> query) {
IoParameters map = createParameters(query, locale, response);
LOGGER.debug("getExtras() with id '{}' and query '{}'", resourceId, map);
Map<String, Object> extras = new HashMap<>();
T from = parameterService.getParameter(resourceId, map);
for (MetadataExtension<T> extension : metadataExtensions) {
final Map<String, Object> furtherExtras = extension.getExtras(from, map);
Collection<String> overridableKeys = checkForOverridingData(extras, furtherExtras);
if (!overridableKeys.isEmpty()) {
String[] keys = overridableKeys.toArray(new String[0]);
LOGGER.warn("Metadata extension overrides existing extra data: {}", Arrays.toString(keys));
}
extras.putAll(furtherExtras);
}
return extras;
}
use of org.n52.io.response.extension.MetadataExtension in project series-rest-api by 52North.
the class TimeseriesMetadataController method addRenderingHints.
// stay backwards compatible
@SuppressWarnings("deprecation")
private TimeseriesMetadataOutput addRenderingHints(TimeseriesMetadataOutput output, IoParameters parameters) {
final String valueName = TimeseriesMetadataOutput.RENDERING_HINTS;
Predicate<MetadataExtension<?>> filter = RenderingHintsExtension.class::isInstance;
Optional<Map<String, Object>> extras = getExtras(output, parameters, filter);
extras.ifPresent(it -> {
StyleProperties value = (StyleProperties) it.get(valueName);
output.setValue(valueName, value, parameters, output::setRenderingHints);
});
return output;
}
Aggregations