Search in sources :

Example 1 with RequestSimpleParameterSet

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

the class DataController method getSeriesChart.

@RequestMapping(value = "/{seriesId}/data", produces = { "image/png" }, method = RequestMethod.GET)
public void getSeriesChart(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 collection chart for '{}' with query: {}", seriesId, map);
    checkAgainstTimespanRestriction(map.getTimespan().toString());
    checkForUnknownDatasetIds(map, seriesId);
    String handleAsValueTypeFallback = map.getAsString(Parameters.HANDLE_AS_VALUE_TYPE);
    String valueType = ValueType.extractType(seriesId, handleAsValueTypeFallback);
    RequestSimpleParameterSet parameters = map.toSimpleParameterSet();
    String outputFormat = MimeType.IMAGE_PNG.toString();
    response.setContentType(outputFormat);
    createIoFactory(valueType).withSimpleRequest(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with RequestSimpleParameterSet

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

the class DataController method getSeriesAsCsv.

@RequestMapping(value = "/{seriesId}/data", produces = { "text/csv" }, method = RequestMethod.GET)
public void getSeriesAsCsv(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 collection csv for '{}' with query: {}", seriesId, map);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
    checkAgainstTimespanRestriction(parameters.getTimespan());
    checkForUnknownDatasetIds(map, seriesId);
    response.setCharacterEncoding(DEFAULT_RESPONSE_ENCODING);
    if (Boolean.parseBoolean(map.getOther("zip"))) {
        response.setContentType(MimeType.APPLICATION_ZIP.toString());
    } else {
        response.setContentType(MimeType.TEXT_CSV.toString());
    }
    final String datasetType = parameters.getValueType();
    createIoFactory(datasetType).withSimpleRequest(parameters).createHandler(MimeType.TEXT_CSV.toString()).writeBinary(response.getOutputStream());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with RequestSimpleParameterSet

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

the class DataController method getSeriesAsZippedCsv.

@RequestMapping(value = "/{seriesId}/data", produces = { "application/zip" }, method = RequestMethod.GET)
public void getSeriesAsZippedCsv(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 collection zip for '{}' with query: {}", seriesId, map);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
    checkAgainstTimespanRestriction(parameters.getTimespan());
    checkForUnknownDatasetIds(map, seriesId);
    response.setCharacterEncoding(DEFAULT_RESPONSE_ENCODING);
    response.setContentType(MimeType.APPLICATION_ZIP.toString());
    final String datasetType = parameters.getValueType();
    createIoFactory(datasetType).withSimpleRequest(parameters).createHandler(MimeType.APPLICATION_ZIP.toString()).writeBinary(response.getOutputStream());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with RequestSimpleParameterSet

use of org.n52.io.request.RequestSimpleParameterSet 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 5 with RequestSimpleParameterSet

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

the class TimeseriesDataController method getRawData.

@RequestMapping(value = "/{timeseriesId}/getData", method = RequestMethod.GET, params = { RawFormats.RAW_FORMAT })
public void getRawData(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkIfUnknownTimeseries(map, timeseriesId);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
    processRawDataRequest(response, parameters);
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)14 IoParameters (org.n52.io.request.IoParameters)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 IOException (java.io.IOException)3 IntervalWithTimeZone (org.n52.io.IntervalWithTimeZone)3 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 InputStream (java.io.InputStream)2 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)2 RawDataService (org.n52.series.spi.srv.RawDataService)2 InternalServerException (org.n52.web.exception.InternalServerException)2 ResourceNotFoundException (org.n52.web.exception.ResourceNotFoundException)2 FileOutputStream (java.io.FileOutputStream)1 GeneralizingQuantityService (org.n52.io.quantity.generalize.GeneralizingQuantityService)1 ChartDimension (org.n52.io.quantity.img.ChartDimension)1 Stopwatch (org.n52.web.common.Stopwatch)1 BadRequestException (org.n52.web.exception.BadRequestException)1