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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations