use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class ResourcesController method getResources.
@RequestMapping("/")
public ModelAndView getResources(@RequestParam(required = false) MultiValueMap<String, String> parameters) {
IoParameters query = QueryParameters.createFromQuery(parameters);
query = IoParameters.ensureBackwardsCompatibility(query);
return new ModelAndView().addObject(createResources(query));
}
use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class ResourcesController method createResources.
protected List<ResourceCollection> createResources(IoParameters params) {
IoParameters parameters = IoParameters.ensureBackwardsCompatibility(params);
I18N i18n = I18N.getMessageLocalizer(parameters.getLocale());
ResourceCollection services = add("services", "Service Provider", i18n.get("msg.web.resources.services"));
ResourceCollection stations = add("stations", "Station", i18n.get("msg.web.resources.stations"));
ResourceCollection timeseries = add("timeseries", "Timeseries", i18n.get("msg.web.resources.timeseries"));
ResourceCollection categories = add("categories", "Category", i18n.get("msg.web.resources.categories"));
ResourceCollection offerings = add("offerings", "Offering", i18n.get("msg.web.resources.offerings"));
ResourceCollection features = add("features", "Feature", i18n.get("msg.web.resources.features"));
ResourceCollection procedures = add("procedures", "Procedure", i18n.get("msg.web.resources.procedures"));
ResourceCollection phenomena = add("phenomena", "Phenomenon", i18n.get("msg.web.resources.phenomena"));
if (parameters.isExpanded()) {
services.setSize(getMetadataService().getServiceCount(parameters));
if (new FilterResolver(parameters).shallBehaveBackwardsCompatible()) {
// ensure backwards compatibility
stations.setSize(getMetadataService().getStationCount());
timeseries.setSize(getMetadataService().getTimeseriesCount());
}
categories.setSize(getMetadataService().getCategoryCount(parameters));
offerings.setSize(getMetadataService().getOfferingCount(parameters));
features.setSize(getMetadataService().getFeatureCount(parameters));
procedures.setSize(getMetadataService().getProcedureCount(parameters));
phenomena.setSize(getMetadataService().getPhenomenaCount(parameters));
}
List<ResourceCollection> resources = new ArrayList<>();
resources.add(services);
resources.add(stations);
resources.add(timeseries);
resources.add(categories);
resources.add(offerings);
resources.add(features);
resources.add(procedures);
resources.add(phenomena);
// since 2.0.0
ResourceCollection platforms = add("platforms", "Platforms", i18n.get("msg.web.resources.platforms"));
ResourceCollection datasets = add("datasets", "Datasets", i18n.get("msg.web.resources.datasets"));
ResourceCollection geometries = add("geometries", "Geometries", i18n.get("msg.web.resources.geometries"));
resources.add(platforms);
resources.add(datasets);
resources.add(geometries);
if (parameters.isExpanded()) {
platforms.setSize(getMetadataService().getPlatformCount(parameters));
datasets.setSize(getMetadataService().getDatasetCount(parameters));
}
return resources;
}
use of org.n52.io.request.IoParameters 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));
}
use of org.n52.io.request.IoParameters in project series-rest-api by 52North.
the class TimeseriesDataController method getTimeseriesAsCsv.
private void getTimeseriesAsCsv(String timeseriesId, IoParameters query, HttpServletResponse response) throws IoHandlerException, DatasetFactoryException, URISyntaxException, MalformedURLException, IOException {
checkIfUnknownTimeseries(query, timeseriesId);
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, query);
checkAgainstTimespanRestriction(parameters.getTimespan());
parameters.setGeneralize(query.isGeneralize());
parameters.setExpanded(query.isExpanded());
response.setCharacterEncoding("UTF-8");
if (Boolean.parseBoolean(query.getOther(MimeType.APPLICATION_ZIP.name()))) {
response.setContentType(MimeType.APPLICATION_ZIP.toString());
} else {
response.setContentType(MimeType.TEXT_CSV.toString());
}
createIoFactory(parameters).createHandler(MimeType.TEXT_CSV.toString()).writeBinary(response.getOutputStream());
}
use of org.n52.io.request.IoParameters 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);
}
Aggregations