use of org.n52.io.request.RequestStyledParameterSet in project series-rest-api by 52North.
the class IoStyleContext method createContextForSingleSeries.
public static IoStyleContext createContextForSingleSeries(DatasetOutput metadata, IoParameters ioConfig) {
RequestStyledParameterSet parameters = ioConfig.toStyledParameterSet();
parameters.addSeriesWithStyleOptions(metadata.getId(), ioConfig.getStyle());
return createContextWith(parameters, Collections.singletonList(metadata));
}
use of org.n52.io.request.RequestStyledParameterSet in project series-rest-api by 52North.
the class TimeseriesDataController method getChart.
@RequestMapping(value = "/{timeseriesId}/getData", produces = { "image/png" }, method = RequestMethod.GET)
public void getChart(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 parameterSet = RequestSimpleParameterSet.createForSingleSeries(timeseriesId, map);
RequestStyledParameterSet styledParameters = map.toStyledParameterSet();
checkAgainstTimespanRestriction(parameterSet.getTimespan());
parameterSet.setGeneralize(map.isGeneralize());
parameterSet.setBase64(map.isBase64());
parameterSet.setExpanded(map.isExpanded());
response.setContentType(MimeType.IMAGE_PNG.getMimeType());
createIoFactory(parameterSet).withStyledRequest(styledParameters).createHandler(MimeType.IMAGE_PNG.toString()).writeBinary(response.getOutputStream());
}
use of org.n52.io.request.RequestStyledParameterSet in project series-rest-api by 52North.
the class ChartIoHandler method configureTitle.
private void configureTitle(JFreeChart chart) {
RequestStyledParameterSet config = getChartStyleDefinitions();
if (config.containsParameter(PARAMETER_PRERENDERING_TITLE)) {
String title = config.getAsString(PARAMETER_PRERENDERING_TITLE);
if (config.containsParameter(Parameters.RENDERING_TRIGGER)) {
String trigger = config.getAsString(Parameters.RENDERING_TRIGGER);
title = RENDERING_TRIGGER_PRERENDERING.equalsIgnoreCase(trigger) ? getTitleForSingle(config, title) : title;
}
chart.setTitle(title);
}
}
use of org.n52.io.request.RequestStyledParameterSet 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.RequestStyledParameterSet 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());
}
Aggregations