Search in sources :

Example 66 with Value

use of org.n52.shetland.ogc.om.values.Value 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 67 with Value

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

the class StatusIntervalsExtension method createIntervals.

private StatusInterval[] createIntervals(ConfigInterval configInterval) {
    Map<String, StatusInterval> statusIntervals = configInterval.getStatusIntervals();
    for (Entry<String, StatusInterval> entry : statusIntervals.entrySet()) {
        StatusInterval value = entry.getValue();
        value.setName(entry.getKey());
    }
    return statusIntervals.values().toArray(new StatusInterval[0]);
}
Also used : StatusInterval(org.n52.io.response.StatusInterval)

Example 68 with Value

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

the class TimeseriesDataController method getCollectionReport.

@RequestMapping(value = "/getData", produces = { "application/pdf" }, method = RequestMethod.POST)
public void getCollectionReport(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());
    response.setContentType(MimeType.APPLICATION_PDF.getMimeType());
    createIoFactory(parameterSet).withStyledRequest(map.mergeToStyledParameterSet(query)).createHandler(MimeType.APPLICATION_PDF.getMimeType()).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 69 with Value

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

the class TimeseriesDataController method getReport.

@RequestMapping(value = "/{timeseriesId}/getData", produces = { "application/pdf" }, method = RequestMethod.GET)
public void getReport(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);
    checkIfUnknownTimeseries(map, timeseriesId);
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
    checkAgainstTimespanRestriction(parameters.getTimespan());
    parameters.setGeneralize(map.isGeneralize());
    parameters.setExpanded(map.isExpanded());
    response.setContentType(MimeType.APPLICATION_PDF.getMimeType());
    createIoFactory(parameters).createHandler(MimeType.APPLICATION_PDF.getMimeType()).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 70 with Value

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

the class SearchController method searchResources.

@RequestMapping(method = RequestMethod.GET)
public ModelAndView searchResources(@RequestParam String q, @RequestHeader(value = "accept-language") String locale, @RequestParam(required = false) MultiValueMap<String, String> parameters) {
    IoParameters map = QueryParameters.createFromQuery(parameters).extendWith(Parameters.SEARCH_TERM, q).extendWith(Parameters.LOCALE, locale);
    IoParameters query = IoParameters.ensureBackwardsCompatibility(map);
    return new ModelAndView().addObject(searchService.searchResources(query));
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) 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