use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class TimeseriesDataController method getCollectionData.
@RequestMapping(value = "/getData", produces = { "application/json" }, method = RequestMethod.POST)
public ModelAndView getCollectionData(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestSimpleParameterSet query) throws Exception {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
checkIfUnknownTimeseries(query, query.getDatasets());
if (query.isSetRawFormat()) {
getRawCollectionData(response, locale, query);
return null;
}
DataCollection<QuantityData> seriesData = getTimeseriesData(query);
DataCollection<?> formattedDataCollection = format(seriesData, query.getFormat());
return new ModelAndView().addObject(formattedDataCollection.getAllSeries());
}
use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class TimeseriesDataController method getCollectionChart.
@RequestMapping(value = "/getData", produces = { "image/png" }, method = RequestMethod.POST)
public void getCollectionChart(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestStyledParameterSet query) throws Exception {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
checkIfUnknownTimeseries(map, query.getDatasets());
RequestSimpleParameterSet parameterSet = map.mergeToSimpleParameterSet(query);
checkAgainstTimespanRestriction(parameterSet.getTimespan());
parameterSet.setGeneralize(map.isGeneralize());
parameterSet.setExpanded(map.isExpanded());
parameterSet.setBase64(map.isBase64());
response.setContentType(MimeType.IMAGE_PNG.getMimeType());
createIoFactory(parameterSet).withStyledRequest(query).createHandler(MimeType.IMAGE_PNG.toString()).writeBinary(response.getOutputStream());
}
use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class DataController method writeRawData.
private void writeRawData(RequestSimpleParameterSet parameters, HttpServletResponse response) throws InternalServerException, ResourceNotFoundException, BadRequestException {
if (!dataService.supportsRawData()) {
throw new BadRequestException("Querying of raw timeseries data is not supported " + "by the underlying service!");
}
final RawDataService rawDataService = dataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(parameters)) {
if (inputStream == null) {
throw new ResourceNotFoundException("No raw data found.");
}
response.setContentType(parameters.getRawFormat());
IOUtils.copyLarge(inputStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerException("Error while querying raw data", e);
}
}
use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class DataController method getSeriesReport.
@RequestMapping(value = "/{seriesId}/data", produces = { "application/pdf" }, method = RequestMethod.GET)
public void getSeriesReport(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 report for '{}' with query: {}", seriesId, map);
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
checkAgainstTimespanRestriction(parameters.getTimespan());
checkForUnknownDatasetIds(map, seriesId);
final String datasetType = parameters.getValueType();
String outputFormat = MimeType.APPLICATION_PDF.toString();
response.setContentType(outputFormat);
createIoFactory(datasetType).withSimpleRequest(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
Aggregations