use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class TimeseriesDataController method getTimeseriesData.
private DataCollection<Data<QuantityValue>> getTimeseriesData(IoParameters parameters) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
DataCollection<Data<QuantityValue>> 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.response.dataset.Data in project series-rest-api by 52North.
the class TimeseriesDataController method getCollectionData.
@RequestMapping(value = "/getData", produces = Constants.APPLICATION_JSON, method = RequestMethod.POST)
public ModelAndView getCollectionData(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestBody RequestSimpleParameterSet request) throws Exception {
IoParameters parameters = createParameters(request, httpLocale, response);
checkIfUnknownTimeseriesIds(parameters, parameters.getDatasets());
if (parameters.isSetRawFormat()) {
getRawCollectionData(response, httpLocale, request);
return null;
}
DataCollection<Data<QuantityValue>> seriesData = getTimeseriesData(parameters);
DataCollection<?> formattedDataCollection = format(seriesData, parameters);
return new ModelAndView().addObject(formattedDataCollection.getAllSeries());
}
use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class DataController method getCollectionData.
@RequestMapping(value = "/observations", produces = { Constants.APPLICATION_JSON }, method = RequestMethod.POST)
public ModelAndView getCollectionData(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestBody RequestSimpleParameterSet simpleParameters) throws Exception {
IoParameters parameters = createParameters(simpleParameters, httpLocale, response);
LOGGER.debug("get data collection with parameter set: {}", parameters);
checkForUnknownDatasetIds(parameters, parameters.getDatasets());
checkAgainstTimespanRestriction(parameters.getTimespan());
// final String datasetType = getValueType(parameters);
final String valueType = getValueType(parameters, request.getRequestURI());
IoProcessChain<?> ioChain = createIoFactory(valueType).setParameters(parameters).createProcessChain();
DataCollection<?> processed = ioChain.getData();
return new ModelAndView().addObject(processed.getAllSeries());
}
use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class DataController method getSeriesCollectionReport.
@RequestMapping(value = "/observations", produces = { Constants.APPLICATION_PDF }, method = RequestMethod.POST)
public void getSeriesCollectionReport(HttpServletRequest request, HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestBody RequestStyledParameterSet simpleParameters) throws Exception {
IoParameters parameters = createParameters(simpleParameters, httpLocale, response);
LOGGER.debug("get data collection report with query: {}", parameters);
checkForUnknownDatasetIds(parameters, parameters.getDatasets());
checkAgainstTimespanRestriction(parameters.getTimespan());
// final String datasetType = getValueType(parameters);
final String valueType = getValueType(parameters, request.getRequestURI());
String outputFormat = Constants.APPLICATION_PDF;
response.setContentType(outputFormat);
createIoFactory(valueType).setParameters(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class DataController method getSeriesData.
@RequestMapping(value = "/{datasetId}/observations", produces = { Constants.APPLICATION_JSON }, method = RequestMethod.GET)
public ModelAndView getSeriesData(HttpServletRequest request, HttpServletResponse response, @PathVariable String datasetId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE, required = false) String httpLocale, @RequestParam(required = false) MultiValueMap<String, String> query) throws Exception {
IoParameters map = createParameters(datasetId, query, httpLocale, response);
LOGGER.debug("get data for item '{}' with query: {}", datasetId, map);
checkAgainstTimespanRestriction(map.getTimespan());
checkForUnknownDatasetId(map.removeAllOf(Parameters.BBOX).removeAllOf(Parameters.NEAR), datasetId);
// RequestSimpleIoParameters parameters = RequestSimpleIoParameters.createForSingleSeries(seriesId,
// map);
// String valueType = ValueType.extractType(datasetId, handleAsValueTypeFallback);
String valueType = getValueType(map, request.getRequestURI());
IoProcessChain<?> ioChain = createIoFactory(valueType).setParameters(map).createProcessChain();
DataCollection<?> formattedDataCollection = ioChain.getProcessedData();
final Map<String, ?> processed = formattedDataCollection.getAllSeries();
return map.isExpanded() ? new ModelAndView().addObject(processed) : new ModelAndView().addObject(processed.get(datasetId));
}
Aggregations