use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class TransformingStationOutputService method getParameter.
@Override
public StationOutput getParameter(String item, IoParameters query) {
StationOutput feature = composedService.getParameter(item, query);
transformService.transformInline(feature, query);
return feature;
}
use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class DataController method getSeriesCollectionChart.
@RequestMapping(value = "/data", produces = { "image/png" }, method = RequestMethod.POST)
public void getSeriesCollectionChart(HttpServletResponse response, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestBody RequestStyledParameterSet parameters) throws Exception {
RequestUtils.overrideQueryLocaleWhenSet(locale, parameters);
IoParameters map = QueryParameters.createFromQuery(parameters);
checkForUnknownDatasetIds(map, parameters.getDatasets());
LOGGER.debug("get data collection chart with query: {}", map);
final String datasetType = parameters.getValueType();
String outputFormat = MimeType.IMAGE_PNG.toString();
response.setContentType(outputFormat);
createIoFactory(datasetType).withStyledRequest(parameters).createHandler(outputFormat).writeBinary(response.getOutputStream());
}
use of org.n52.io.request.IoParameters 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));
}
use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class ParameterController method getItem.
@Override
public ModelAndView getItem(String id, String locale, MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
LOGGER.debug("getItem() with id '{}' and query '{}'", id, map);
T item = parameterService.getParameter(id, map);
if (item == null) {
throw new ResourceNotFoundException("Resource with id '" + id + "' not found.");
}
T parameter = addExtensionInfos(item);
return new ModelAndView().addObject(parameter);
}
use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class ParameterController method getCollection.
@Override
public ModelAndView getCollection(String locale, MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters queryMap = QueryParameters.createFromQuery(query);
LOGGER.debug("getCollection() with query '{}'", queryMap);
if (queryMap.isExpanded()) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
OutputCollection<T> result = addExtensionInfos(parameterService.getExpandedParameters(queryMap));
LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
return createModelAndView(result);
} else {
OutputCollection<T> results = parameterService.getCondensedParameters(queryMap);
return createModelAndView(results);
}
}
Aggregations