Search in sources :

Example 71 with Value

use of org.n52.shetland.ogc.om.values.Value in project series-rest-api by 52North.

the class TimeseriesDataController method getCollectionData.

@RequestMapping(value = "/getData", produces = { "application/json" }, method = RequestMethod.POST)
public ModelAndView getCollectionData(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestSimpleParameterSet query) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    checkIfUnknownTimeseries(query, query.getDatasets());
    if (query.isSetRawFormat()) {
        getRawCollectionData(response, locale, query);
        return null;
    }
    DataCollection<QuantityData> seriesData = getTimeseriesData(query);
    DataCollection<?> formattedDataCollection = format(seriesData, query.getFormat());
    return new ModelAndView().addObject(formattedDataCollection.getAllSeries());
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) QuantityData(org.n52.io.response.dataset.quantity.QuantityData) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 72 with Value

use of org.n52.shetland.ogc.om.values.Value in project series-rest-api by 52North.

the class TimeseriesDataController method getAsZippedCsv.

@RequestMapping(value = "/{timeseriesId}/getData", produces = { "application/zip" }, method = RequestMethod.GET)
public void getAsZippedCsv(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).extendWith(MimeType.APPLICATION_ZIP.name(), Boolean.TRUE.toString());
    response.setContentType(MimeType.APPLICATION_ZIP.getMimeType());
    getTimeseriesAsCsv(timeseriesId, map, response);
}
Also used : IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 73 with Value

use of org.n52.shetland.ogc.om.values.Value in project series-rest-api by 52North.

the class TimeseriesDataController method getCollectionChart.

@RequestMapping(value = "/getData", produces = { "image/png" }, method = RequestMethod.POST)
public void getCollectionChart(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestStyledParameterSet query) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkIfUnknownTimeseries(map, query.getDatasets());
    RequestSimpleParameterSet parameterSet = map.mergeToSimpleParameterSet(query);
    checkAgainstTimespanRestriction(parameterSet.getTimespan());
    parameterSet.setGeneralize(map.isGeneralize());
    parameterSet.setExpanded(map.isExpanded());
    parameterSet.setBase64(map.isBase64());
    response.setContentType(MimeType.IMAGE_PNG.getMimeType());
    createIoFactory(parameterSet).withStyledRequest(query).createHandler(MimeType.IMAGE_PNG.toString()).writeBinary(response.getOutputStream());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 74 with Value

use of org.n52.shetland.ogc.om.values.Value in project series-rest-api by 52North.

the class DataController method getSeriesReport.

@RequestMapping(value = "/{seriesId}/data", produces = { "application/pdf" }, method = RequestMethod.GET)
public void getSeriesReport(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 collection report for '{}' with query: {}", seriesId, map);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
    checkAgainstTimespanRestriction(parameters.getTimespan());
    checkForUnknownDatasetIds(map, seriesId);
    final String datasetType = parameters.getValueType();
    String outputFormat = MimeType.APPLICATION_PDF.toString();
    response.setContentType(outputFormat);
    createIoFactory(datasetType).withSimpleRequest(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 75 with Value

use of org.n52.shetland.ogc.om.values.Value in project series-rest-api by 52North.

the class DataController method getSeriesCollectionReport.

@RequestMapping(value = "/data", produces = { "application/pdf" }, method = RequestMethod.POST)
public void getSeriesCollectionReport(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestStyledParameterSet parameters) throws Exception {
    RequestUtils.overrideQueryLocaleWhenSet(locale, parameters);
    IoParameters map = QueryParameters.createFromQuery(parameters);
    LOGGER.debug("get data collection report with query: {}", map);
    checkForUnknownSeriesIds(parameters, parameters.getDatasets());
    checkAgainstTimespanRestriction(parameters.getTimespan());
    final String datasetType = parameters.getValueType();
    String outputFormat = MimeType.APPLICATION_PDF.toString();
    response.setContentType(outputFormat);
    createIoFactory(datasetType).withStyledRequest(map.mergeToStyledParameterSet(parameters)).withSimpleRequest(map.mergeToSimpleParameterSet(parameters)).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
Also used : IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5