use of org.n52.io.IoProcessChain in project series-rest-api by 52North.
the class DataController method getSeriesData.
@RequestMapping(value = "/{seriesId}/data", produces = { "application/json" }, method = RequestMethod.GET)
public ModelAndView getSeriesData(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 for item '{}' with query: {}", seriesId, map);
IntervalWithTimeZone timespan = map.getTimespan();
checkAgainstTimespanRestriction(timespan.toString());
checkForUnknownDatasetIds(map, seriesId);
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
String handleAsValueTypeFallback = map.getAsString(Parameters.HANDLE_AS_VALUE_TYPE);
String valueType = ValueType.extractType(seriesId, handleAsValueTypeFallback);
IoProcessChain<?> ioChain = createIoFactory(valueType).withSimpleRequest(parameters).createProcessChain();
DataCollection<?> formattedDataCollection = ioChain.getProcessedData();
final Map<String, ?> processed = formattedDataCollection.getAllSeries();
return map.isExpanded() ? new ModelAndView().addObject(processed) : new ModelAndView().addObject(processed.get(seriesId));
}
use of org.n52.io.IoProcessChain in project series-rest-api by 52North.
the class QuantityIoFactory method createProcessChain.
@Override
public IoProcessChain<QuantityData> createProcessChain() {
return new IoProcessChain<QuantityData>() {
@Override
public DataCollection<QuantityData> getData() {
final boolean generalize = getParameters().isGeneralize();
DataService<QuantityData> dataService = generalize ? new GeneralizingQuantityService(getDataService()) : getDataService();
return dataService.getData(getRequestParameters());
}
@Override
public DataCollection<?> getProcessedData() {
String format = getParameters().getFormat();
return FormatterFactory.createFormatterFactory(format).create().format(getData());
}
};
}
Aggregations