Search in sources :

Example 1 with RequestStyledParameterSet

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));
}
Also used : RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet)

Example 2 with RequestStyledParameterSet

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());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with RequestStyledParameterSet

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);
    }
}
Also used : RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet)

Example 4 with RequestStyledParameterSet

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());
}
Also used : IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with RequestStyledParameterSet

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());
}
Also used : RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) IoParameters(org.n52.io.request.IoParameters) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IoParameters (org.n52.io.request.IoParameters)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)4 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)4 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ChartDimension (org.n52.io.quantity.img.ChartDimension)1 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)1