Search in sources :

Example 11 with DatasetOutput

use of org.n52.io.response.dataset.DatasetOutput in project series-rest-api by 52North.

the class QuantityCsvIoHandler method writeData.

private void writeData(DataCollection<QuantityData> data, OutputStream stream) throws IOException {
    for (DatasetOutput metadata : seriesMetadatas) {
        QuantityData series = data.getSeries(metadata.getId());
        writeData(metadata, (QuantityData) series, stream);
    }
}
Also used : DatasetOutput(org.n52.io.response.dataset.DatasetOutput) QuantityData(org.n52.io.response.dataset.quantity.QuantityData)

Example 12 with DatasetOutput

use of org.n52.io.response.dataset.DatasetOutput in project series-rest-api by 52North.

the class PreRenderingJob method execute.

@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    if (interrupted) {
        return;
    }
    LOGGER.info("Start prerendering task");
    final Stopwatch stopwatch = Stopwatch.startStopwatch();
    final JobDetail details = context.getJobDetail();
    JobDataMap jobDataMap = details.getJobDataMap();
    taskConfigPrerendering = readJobConfig(jobDataMap.getString(JOB_DATA_CONFIG_FILE));
    webappFolder = jobDataMap.getString(JOB_DATA_WEBAPP_FOLDER);
    List<RenderingConfig> phenomenonStyles = taskConfigPrerendering.getPhenomenonStyles();
    List<RenderingConfig> styles = taskConfigPrerendering.getSeriesStyles();
    for (RenderingConfig config : phenomenonStyles) {
        Map<String, String> parameters = new HashMap<>();
        parameters.put("phenomenon", config.getId());
        IoParameters query = QueryParameters.createFromQuery(parameters);
        for (DatasetOutput<?, ?> metadata : datasetService.getCondensedParameters(query)) {
            String timeseriesId = metadata.getId();
            renderConfiguredIntervals(timeseriesId, config);
            if (interrupted) {
                return;
            }
        }
    }
    for (RenderingConfig config : styles) {
        renderConfiguredIntervals(config.getId(), config);
        if (interrupted) {
            return;
        }
    }
    LOGGER.debug("prerendering took '{}'", stopwatch.stopInSeconds());
}
Also used : JobDetail(org.quartz.JobDetail) JobDataMap(org.quartz.JobDataMap) HashMap(java.util.HashMap) Stopwatch(org.n52.web.common.Stopwatch) IoParameters(org.n52.io.request.IoParameters) RenderingConfig(org.n52.io.PrerenderingJobConfig.RenderingConfig)

Example 13 with DatasetOutput

use of org.n52.io.response.dataset.DatasetOutput in project series-rest-api by 52North.

the class PreRenderingJob method renderWithStyle.

private void renderWithStyle(String datasetId, RenderingConfig renderingConfig, String interval) throws IOException, DatasetFactoryException, URISyntaxException {
    IntervalWithTimeZone timespan = createTimespanFromInterval(datasetId, interval);
    IoParameters config = createConfig(timespan.toString(), renderingConfig);
    DatasetOutput<?, ?> metadata = datasetService.getParameter(datasetId, config);
    IoStyleContext context = IoStyleContext.createContextForSingleSeries(metadata, config);
    RequestStyledParameterSet styleDefinition = context.getChartStyleDefinitions();
    context.setDimensions(new ChartDimension(styleDefinition.getWidth(), styleDefinition.getHeight()));
    RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(datasetId, config);
    String chartQualifier = renderingConfig.getChartQualifier();
    FileOutputStream fos = createFile(datasetId, interval, chartQualifier);
    try (FileOutputStream out = fos) {
        createIoFactory(parameters).createHandler(IMAGE_EXTENSION).writeBinary(out);
        fos.flush();
    } catch (IoHandlerException | IOException e) {
        LOGGER.error("Image creation occures error.", e);
    }
}
Also used : RequestStyledParameterSet(org.n52.io.request.RequestStyledParameterSet) RequestSimpleParameterSet(org.n52.io.request.RequestSimpleParameterSet) FileOutputStream(java.io.FileOutputStream) ChartDimension(org.n52.io.quantity.img.ChartDimension) IoParameters(org.n52.io.request.IoParameters) IOException(java.io.IOException)

Aggregations

DatasetOutput (org.n52.io.response.dataset.DatasetOutput)4 ParameterOutput (org.n52.io.response.ParameterOutput)3 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)3 IOException (java.io.IOException)2 IoParameters (org.n52.io.request.IoParameters)2 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)2 StyleProperties (org.n52.io.request.StyleProperties)2 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)2 TimeSeries (org.n52.oxf.DocumentStructureType.TimeSeries)2 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1 DateTime (org.joda.time.DateTime)1 IoParseException (org.n52.io.IoParseException)1 RenderingConfig (org.n52.io.PrerenderingJobConfig.RenderingConfig)1 ChartDimension (org.n52.io.quantity.img.ChartDimension)1 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)1 ReferenceValueOutput (org.n52.io.response.dataset.ReferenceValueOutput)1 TimeseriesMetadataOutput (org.n52.io.response.dataset.TimeseriesMetadataOutput)1 QuantityDatasetMetadata (org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)1 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)1