Search in sources :

Example 1 with IoProcessChain

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));
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) IntervalWithTimeZone(org.n52.io.IntervalWithTimeZone) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with IoProcessChain

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());
        }
    };
}
Also used : IoProcessChain(org.n52.io.IoProcessChain) GeneralizingQuantityService(org.n52.io.quantity.generalize.GeneralizingQuantityService) QuantityData(org.n52.io.response.dataset.quantity.QuantityData)

Aggregations

IntervalWithTimeZone (org.n52.io.IntervalWithTimeZone)1 IoProcessChain (org.n52.io.IoProcessChain)1 GeneralizingQuantityService (org.n52.io.quantity.generalize.GeneralizingQuantityService)1 IoParameters (org.n52.io.request.IoParameters)1 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)1 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1