Search in sources :

Example 1 with MetadataExtension

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;
}
Also used : HashMap(java.util.HashMap) IoParameters(org.n52.io.request.IoParameters)

Example 2 with MetadataExtension

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;
}
Also used : HashMap(java.util.HashMap) IoParameters(org.n52.io.request.IoParameters)

Example 3 with MetadataExtension

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;
}
Also used : StyleProperties(org.n52.io.request.StyleProperties) MetadataExtension(org.n52.io.response.extension.MetadataExtension) MultiValueMap(org.springframework.util.MultiValueMap) Map(java.util.Map)

Aggregations

HashMap (java.util.HashMap)2 IoParameters (org.n52.io.request.IoParameters)2 Map (java.util.Map)1 StyleProperties (org.n52.io.request.StyleProperties)1 MetadataExtension (org.n52.io.response.extension.MetadataExtension)1 MultiValueMap (org.springframework.util.MultiValueMap)1