use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class TimeseriesDataController method processRawDataRequest.
private void processRawDataRequest(HttpServletResponse response, RequestSimpleParameterSet query) {
if (!timeseriesDataService.supportsRawData()) {
throwNewRawDataQueryNotSupportedException();
}
final RawDataService rawDataService = timeseriesDataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(query)) {
if (inputStream == null) {
throw new ResourceNotFoundException("No raw data found.");
}
response.setContentType(query.getFormat());
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 TimeseriesDataController method getTimeseriesData.
private DataCollection<QuantityData> getTimeseriesData(RequestSimpleParameterSet parameters) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
DataCollection<QuantityData> timeseriesData = parameters.isGeneralize() ? new GeneralizingQuantityService(timeseriesDataService).getData(parameters) : timeseriesDataService.getData(parameters);
LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
return timeseriesData;
}
use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class TimeseriesDataController method getChart.
@RequestMapping(value = "/{timeseriesId}/getData", produces = { "image/png" }, method = RequestMethod.GET)
public void getChart(HttpServletResponse response, @PathVariable String timeseriesId, @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);
checkIfUnknownTimeseries(map, timeseriesId);
RequestSimpleParameterSet parameterSet = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
RequestStyledParameterSet styledParameters = map.toStyledParameterSet();
checkAgainstTimespanRestriction(parameterSet.getTimespan());
parameterSet.setGeneralize(map.isGeneralize());
parameterSet.setBase64(map.isBase64());
parameterSet.setExpanded(map.isExpanded());
response.setContentType(MimeType.IMAGE_PNG.getMimeType());
createIoFactory(parameterSet).withStyledRequest(styledParameters).createHandler(MimeType.IMAGE_PNG.toString()).writeBinary(response.getOutputStream());
}
use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class TimeseriesDataController method getData.
@RequestMapping(value = "/{timeseriesId}/getData", produces = { "application/json" }, method = RequestMethod.GET)
public ModelAndView getData(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
checkIfUnknownTimeseries(map, timeseriesId);
IntervalWithTimeZone timespan = map.getTimespan();
checkAgainstTimespanRestriction(timespan.toString());
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
if (map.getResultTime() != null) {
parameters.setResultTime(map.getResultTime().toString());
}
parameters.setGeneralize(map.isGeneralize());
parameters.setExpanded(map.isExpanded());
// TODO add paging
DataCollection<QuantityData> seriesData = getTimeseriesData(parameters);
DataCollection<?> formattedDataCollection = format(seriesData, map.getFormat());
if (map.isExpanded()) {
return new ModelAndView().addObject(formattedDataCollection.getAllSeries());
}
Object formattedTimeseries = formattedDataCollection.getAllSeries().get(timeseriesId);
return new ModelAndView().addObject(formattedTimeseries);
}
use of org.n52.io.request.RequestSimpleParameterSet in project series-rest-api by 52North.
the class RequestSimpleParameterSet method createForSingleSeries.
public static RequestSimpleParameterSet createForSingleSeries(String seriesId, IoParameters parameters) {
RequestSimpleParameterSet parameterSet = parameters.toSimpleParameterSet();
parameterSet.setDatasets(new String[] { seriesId });
IntervalWithTimeZone timespan = parameters.getTimespan();
parameterSet.setTimespan(timespan.toString());
return parameterSet;
}
Aggregations