Search in sources :

Example 6 with Value

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

the class DataController method getRawSeriesData.

@RequestMapping(value = "/{seriesId}/data", method = RequestMethod.GET, params = { RawFormats.RAW_FORMAT })
public void getRawSeriesData(HttpServletResponse response, @PathVariable String seriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkForUnknownDatasetIds(map, seriesId);
    LOGGER.debug("getSeriesCollection() with query: {}", map);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
    writeRawData(parameters, response);
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with Value

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

the class StationsParameterController method getItem.

@RequestMapping(value = "/{item}", method = RequestMethod.GET)
public ModelAndView getItem(@PathVariable("item") String procedureId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    map = IoParameters.ensureBackwardsCompatibility(map);
    // TODO check parameters and throw BAD_REQUEST if invalid
    Stopwatch stopwatch = Stopwatch.startStopwatch();
    Object result = parameterService.getParameter(procedureId, map);
    logRequestTime(stopwatch);
    if (result == null) {
        throw new ResourceNotFoundException("Found no station with given id.");
    }
    return new ModelAndView().addObject(result);
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) ResourceNotFoundException(org.n52.web.exception.ResourceNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with Value

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

the class StationsParameterController method getCollection.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView getCollection(@RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    map = IoParameters.ensureBackwardsCompatibility(map);
    if (map.isExpanded()) {
        Stopwatch stopwatch = Stopwatch.startStopwatch();
        OutputCollection<?> result = parameterService.getExpandedParameters(map);
        logRequestTime(stopwatch);
        // TODO add paging
        return new ModelAndView().addObject(result.getItems());
    } else {
        Stopwatch stopwatch = Stopwatch.startStopwatch();
        OutputCollection<?> result = parameterService.getCondensedParameters(map);
        logRequestTime(stopwatch);
        // TODO add paging
        return new ModelAndView().addObject(result.getItems());
    }
}
Also used : Stopwatch(org.n52.web.common.Stopwatch) ModelAndView(org.springframework.web.servlet.ModelAndView) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with Value

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

the class TimeseriesDataController method getRawData.

@RequestMapping(value = "/{timeseriesId}/getData", method = RequestMethod.GET, params = { RawFormats.RAW_FORMAT })
public void getRawData(HttpServletResponse response, @PathVariable String timeseriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam MultiValueMap<String, String> query) {
    RequestUtils.overrideQueryLocaleWhenSet(locale, query);
    IoParameters map = QueryParameters.createFromQuery(query);
    checkIfUnknownTimeseries(map, timeseriesId);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
    processRawDataRequest(response, parameters);
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with Value

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

the class TimeseriesDataController method getAsCsv.

@RequestMapping(value = "/{timeseriesId}/getData", produces = { "text/csv" }, method = RequestMethod.GET)
public void getAsCsv(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);
    getTimeseriesAsCsv(timeseriesId, map, response);
}
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