Search in sources :

Example 6 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class DataController method getRawSeriesData.

@RequestMapping(value = "/{seriesId}/data", method = RequestMethod.GET, params = { RawFormats.RAW_FORMAT })
public void getRawSeriesData(HttpServletResponse response, @PathVariable String seriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkForUnknownDatasetIds(map, seriesId);
    LOGGER.debug("getSeriesCollection() with query: {}", map);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
    writeRawData(parameters, response);
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class RenderingHintsExtension method getExtras.

@Override
public Map<String, Object> getExtras(DatasetOutput output, IoParameters parameters) {
    if (!hasExtrasToReturn(output, parameters)) {
        return Collections.emptyMap();
    }
    if (hasSeriesConfiguration(output)) {
        final StyleProperties style = createStyle(getSeriesStyle(output));
        checkForBackwardCompatiblity(output, style);
        return wrapSingleIntoMap(style);
    } else if (hasPhenomenonConfiguration(output)) {
        final StyleProperties style = createStyle(getPhenomenonStyle(output));
        checkForBackwardCompatiblity(output, style);
        return wrapSingleIntoMap(style);
    }
    LOGGER.error("No rendering style found for {} (id={})", output, output.getId());
    return Collections.emptyMap();
}
Also used : StyleProperties(org.n52.io.request.StyleProperties)

Example 8 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class IoStyleContext method createContextForSingleSeries.

public static IoStyleContext createContextForSingleSeries(DatasetOutput metadata, IoParameters ioConfig) {
    RequestStyledParameterSet parameters = ioConfig.toStyledParameterSet();
    parameters.addSeriesWithStyleOptions(metadata.getId(), ioConfig.getStyle());
    return createContextWith(parameters, Collections.singletonList(metadata));
}
Also used : RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet)

Example 9 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class StationsParameterController method getItem.

@RequestMapping(value = "/{item}", method = RequestMethod.GET)
public ModelAndView getItem(@PathVariable("item") String procedureId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    map = IoParameters.ensureBackwardsCompatibility(map);
    // TODO check parameters and throw BAD_REQUEST if invalid
    Stopwatch stopwatch = Stopwatch.startStopwatch();
    Object result = parameterService.getParameter(procedureId, map);
    logRequestTime(stopwatch);
    if (result == null) {
        throw new ResourceNotFoundException("Found no station with given id.");
    }
    return new ModelAndView().addObject(result);
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) ResourceNotFoundException(org.n52.web.exception.ResourceNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with IoParameters

use of org.n52.io.request.IoParameters in project series-rest-api by 52North.

the class StationsParameterController method getCollection.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView getCollection(@RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    map = IoParameters.ensureBackwardsCompatibility(map);
    if (map.isExpanded()) {
        Stopwatch stopwatch = Stopwatch.startStopwatch();
        OutputCollection<?> result = parameterService.getExpandedParameters(map);
        logRequestTime(stopwatch);
        // TODO add paging
        return new ModelAndView().addObject(result.getItems());
    } else {
        Stopwatch stopwatch = Stopwatch.startStopwatch();
        OutputCollection<?> result = parameterService.getCondensedParameters(map);
        logRequestTime(stopwatch);
        // TODO add paging
        return new ModelAndView().addObject(result.getItems());
    }
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IoParameters (org.n52.io.request.IoParameters)31 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)14 ModelAndView (org.springframework.web.servlet.ModelAndView)7 Test (org.junit.Test)5 IntervalWithTimeZone (org.n52.io.IntervalWithTimeZone)4 Stopwatch (org.n52.web.common.Stopwatch)4 IoStyleContext (org.n52.io.IoStyleContext)3 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)3 ResourceNotFoundException (org.n52.web.exception.ResourceNotFoundException)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 WKTReader (com.vividsolutions.jts.io.WKTReader)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 I18N (org.n52.io.I18N)1