Search in sources :

Example 1 with SeriesParameters

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

the class PDFReportGenerator method addTimeseries.

private TimeSeries addTimeseries(DatasetOutput metadata) {
    DocumentStructureType report = document.getDocumentStructure();
    TimeSeries timeseries = report.addNewTimeSeries();
    SeriesParameters parameters = metadata.getSeriesParameters();
    timeseries.setFeatureOfInterestID(parameters.getFeature().getLabel());
    timeseries.setPhenomenID(parameters.getPhenomenon().getLabel());
    timeseries.setProcedureID(parameters.getProcedure().getLabel());
    return timeseries;
}
Also used : TimeSeries(org.n52.oxf.DocumentStructureType.TimeSeries) SeriesParameters(org.n52.io.response.dataset.SeriesParameters) DocumentStructureType(org.n52.oxf.DocumentStructureType)

Example 2 with SeriesParameters

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

the class PDFReportGenerator method createValueTableHeader.

private String createValueTableHeader(TimeseriesMetadataOutput metadata) {
    SeriesParameters parameters = metadata.getSeriesParameters();
    String phenomenon = parameters.getPhenomenon().getLabel();
    return phenomenon + " (" + metadata.getUom() + ")";
}
Also used : SeriesParameters(org.n52.io.response.dataset.SeriesParameters)

Example 3 with SeriesParameters

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

the class ChartIoHandler method formatTitle.

protected String formatTitle(DatasetOutput metadata, String title) {
    SeriesParameters parameters = metadata.getSeriesParameters();
    Object[] varargs = { // index important to reference in config!
    parameters.getPlatform().getLabel(), parameters.getPhenomenon().getLabel(), parameters.getProcedure().getLabel(), parameters.getCategory().getLabel(), parameters.getOffering().getLabel(), parameters.getFeature().getLabel(), parameters.getService().getLabel(), metadata.getUom() };
    try {
        return String.format(title, varargs);
    } catch (Exception e) {
        String datasetId = metadata.getId();
        LOGGER.info("Couldn't format title while prerendering dataset '{}'", datasetId, e);
        // return template as fallback
        return title;
    }
}
Also used : SeriesParameters(org.n52.io.response.dataset.SeriesParameters) IoParseException(org.n52.io.IoParseException) IOException(java.io.IOException)

Example 4 with SeriesParameters

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

the class ChartRendererTest method shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive.

@Test
public void shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive() {
    QuantityDatasetOutput metadata = new QuantityDatasetOutput();
    SeriesParameters parameters = new SeriesParameters();
    parameters.setCategory(createParameter(new CategoryOutput(), "cat_1", "category"));
    parameters.setFeature(createParameter(new FeatureOutput(), "feat_1", "feature"));
    parameters.setOffering(createParameter(new OfferingOutput(), "off_1", "offering"));
    parameters.setPhenomenon(createParameter(new PhenomenonOutput(), "phen_1", "phenomenon"));
    parameters.setProcedure(createParameter(new ProcedureOutput(), "proc_1", "procedure"));
    parameters.setService(createParameter(new ServiceOutput(), "ser_1", "service"));
    metadata.setSeriesParameters(parameters);
    metadata.setId("timeseries");
    metadata.setUom("");
    PlatformOutput platformOutput = new PlatformOutput(PlatformType.STATIONARY_INSITU);
    platformOutput.setId("sta_1");
    platformOutput.setLabel("station");
    parameters.setPlatform(platformOutput);
    // build expected title
    StringBuilder expected = new StringBuilder();
    expected.append(parameters.getPlatform().getLabel());
    expected.append(" ").append(parameters.getPhenomenon().getLabel());
    expected.append(" ").append(parameters.getProcedure().getLabel());
    // expected.append(" ").append(parameters.getCategory().getLabel());
    expected.append(" (4 opted-out)");
    expected.append(" ").append(parameters.getOffering().getLabel());
    expected.append(" ").append(parameters.getFeature().getLabel());
    expected.append(" ").append(parameters.getService().getLabel());
    expected.append(" ").append(metadata.getUom());
    IoParameters ioConfig = createDefaults().extendWith("rendering_trigger", "prerendering");
    IoStyleContext context = IoStyleContext.createContextForSingleSeries(metadata, ioConfig);
    MyChartRenderer chartRenderer = new MyChartRenderer(context);
    // String template = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s";
    String template = "%1$s %2$s %3$s (4 opted-out) %5$s %6$s %7$s %8$s";
    String actual = chartRenderer.formatTitle(metadata, template);
    assertThat(actual, is(expected.toString()));
}
Also used : OfferingOutput(org.n52.io.response.OfferingOutput) ServiceOutput(org.n52.io.response.ServiceOutput) FeatureOutput(org.n52.io.response.FeatureOutput) IoStyleContext(org.n52.io.IoStyleContext) IoParameters(org.n52.io.request.IoParameters) PlatformOutput(org.n52.io.response.PlatformOutput) CategoryOutput(org.n52.io.response.CategoryOutput) ProcedureOutput(org.n52.io.response.ProcedureOutput) SeriesParameters(org.n52.io.response.dataset.SeriesParameters) QuantityDatasetOutput(org.n52.io.response.dataset.quantity.QuantityDatasetOutput) PhenomenonOutput(org.n52.io.response.PhenomenonOutput) Test(org.junit.Test)

Example 5 with SeriesParameters

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

the class ChartIoHandler method createRangeLabel.

protected String createRangeLabel(DatasetOutput timeseriesMetadata) {
    SeriesParameters parameters = timeseriesMetadata.getSeriesParameters();
    ParameterOutput phenomenon = parameters.getPhenomenon();
    StringBuilder uom = new StringBuilder();
    uom.append(phenomenon.getLabel());
    String uomLabel = timeseriesMetadata.getUom();
    if (uomLabel != null && !uomLabel.isEmpty()) {
        uom.append(" [").append(uomLabel).append("]");
    }
    return uom.toString();
}
Also used : SeriesParameters(org.n52.io.response.dataset.SeriesParameters) ParameterOutput(org.n52.io.response.ParameterOutput)

Aggregations

SeriesParameters (org.n52.io.response.dataset.SeriesParameters)5 IOException (java.io.IOException)1 Test (org.junit.Test)1 IoParseException (org.n52.io.IoParseException)1 IoStyleContext (org.n52.io.IoStyleContext)1 IoParameters (org.n52.io.request.IoParameters)1 CategoryOutput (org.n52.io.response.CategoryOutput)1 FeatureOutput (org.n52.io.response.FeatureOutput)1 OfferingOutput (org.n52.io.response.OfferingOutput)1 ParameterOutput (org.n52.io.response.ParameterOutput)1 PhenomenonOutput (org.n52.io.response.PhenomenonOutput)1 PlatformOutput (org.n52.io.response.PlatformOutput)1 ProcedureOutput (org.n52.io.response.ProcedureOutput)1 ServiceOutput (org.n52.io.response.ServiceOutput)1 QuantityDatasetOutput (org.n52.io.response.dataset.quantity.QuantityDatasetOutput)1 DocumentStructureType (org.n52.oxf.DocumentStructureType)1 TimeSeries (org.n52.oxf.DocumentStructureType.TimeSeries)1