Search in sources :

Example 56 with Data

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;
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) GeneralizingQuantityService(org.n52.io.type.quantity.generalize.GeneralizingQuantityService) Data(org.n52.io.response.dataset.Data)

Example 57 with Data

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

Example 58 with Data

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

Example 59 with Data

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

Example 60 with Data

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

Aggregations

IoParameters (org.n52.io.request.IoParameters)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 Data (org.n52.io.response.dataset.Data)13 IOException (java.io.IOException)12 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)11 HashMap (java.util.HashMap)6 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)6 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)6 InputStream (java.io.InputStream)5 XmlObject (org.apache.xmlbeans.XmlObject)5 IoParseException (org.n52.io.IoParseException)5 File (java.io.File)4 Test (org.junit.Test)4 InternalServerException (org.n52.web.exception.InternalServerException)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 BigDecimal (java.math.BigDecimal)3 ElasticsearchAwareTest (org.n52.iceland.statistics.basetests.ElasticsearchAwareTest)3 ResultTimeClassifiedData (org.n52.io.format.ResultTimeClassifiedData)3 RawDataService (org.n52.series.spi.srv.RawDataService)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3