Search in sources :

Example 16 with IoParameters

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

the class TransformingStationOutputService method getParameter.

@Override
public StationOutput getParameter(String item, IoParameters query) {
    StationOutput feature = composedService.getParameter(item, query);
    transformService.transformInline(feature, query);
    return feature;
}
Also used : StationOutput(org.n52.io.response.dataset.StationOutput)

Example 17 with IoParameters

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

the class DataController method getSeriesCollectionChart.

@RequestMapping(value = "/data", produces = { "image/png" }, method = RequestMethod.POST)
public void getSeriesCollectionChart(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestStyledParameterSet parameters) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, parameters);
    IoParameters map = QueryParameters.createFromQuery(parameters);
    checkForUnknownDatasetIds(map, parameters.getDatasets());
    LOGGER.debug("get data collection chart with query: {}", map);
    final String datasetType = parameters.getValueType();
    String outputFormat = MimeType.IMAGE_PNG.toString();
    response.setContentType(outputFormat);
    createIoFactory(datasetType).withStyledRequest(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
Also used : IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with IoParameters

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

the class DataController method getSeriesData.

@RequestMapping(value = "/{seriesId}/data", produces = { "application/json" }, method = RequestMethod.GET)
public ModelAndView getSeriesData(HttpServletResponse response, @PathVariable String seriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    LOGGER.debug("get data for item '{}' with query: {}", seriesId, map);
    IntervalWithTimeZone timespan = map.getTimespan();
    checkAgainstTimespanRestriction(timespan.toString());
    checkForUnknownDatasetIds(map, seriesId);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
    String handleAsValueTypeFallback = map.getAsString(Parameters.HANDLE_AS_VALUE_TYPE);
    String valueType = ValueType.extractType(seriesId, handleAsValueTypeFallback);
    IoProcessChain<?> ioChain = createIoFactory(valueType).withSimpleRequest(parameters).createProcessChain();
    DataCollection<?> formattedDataCollection = ioChain.getProcessedData();
    final Map<String, ?> processed = formattedDataCollection.getAllSeries();
    return map.isExpanded() ? new ModelAndView().addObject(processed) : new ModelAndView().addObject(processed.get(seriesId));
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) IntervalWithTimeZone(org.n52.io.IntervalWithTimeZone) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with IoParameters

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

the class ParameterController method getItem.

@Override
public ModelAndView getItem(String id, String locale, MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    LOGGER.debug("getItem() with id '{}' and query '{}'", id, map);
    T item = parameterService.getParameter(id, map);
    if (item == null) {
        throw new ResourceNotFoundException("Resource with id '" + id + "' not found.");
    }
    T parameter = addExtensionInfos(item);
    return new ModelAndView().addObject(parameter);
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) ResourceNotFoundException(org.n52.web.exception.ResourceNotFoundException)

Example 20 with IoParameters

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

the class ParameterController method getCollection.

@Override
public ModelAndView getCollection(String locale, MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters queryMap = QueryParameters.createFromQuery(query);
    LOGGER.debug("getCollection() with query '{}'", queryMap);
    if (queryMap.isExpanded()) {
        Stopwatch stopwatch = Stopwatch.startStopwatch();
        OutputCollection<T> result = addExtensionInfos(parameterService.getExpandedParameters(queryMap));
        LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
        return createModelAndView(result);
    } else {
        OutputCollection<T> results = parameterService.getCondensedParameters(queryMap);
        return createModelAndView(results);
    }
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) IoParameters(org.n52.io.request.IoParameters)

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