use of org.n52.io.response.dataset.DatasetParameters in project series-rest-api by 52North.
the class ChartRendererTest method shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive.
@Test
public void shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive() {
DatasetParameters datasetParameters = new DatasetParameters();
datasetParameters.setCategory(createParameter(new CategoryOutput(), "cat_1", "category"));
FeatureOutput feature = createParameter(new FeatureOutput(), "feat_1", "feature");
datasetParameters.setOffering(createParameter(new OfferingOutput(), "off_1", "offering"));
datasetParameters.setPhenomenon(createParameter(new PhenomenonOutput(), "phen_1", "phenomenon"));
datasetParameters.setProcedure(createParameter(new ProcedureOutput(), "proc_1", "procedure"));
datasetParameters.setService(createParameter(new ServiceOutput(), "ser_1", "service"));
DatasetOutput<?> metadata = new DatasetOutput();
metadata.setFeature(OptionalOutput.of(feature));
metadata.setDatasetParameters(OptionalOutput.of(datasetParameters)).setUom(OptionalOutput.of("")).setId("timeseries");
PlatformOutput platformOutput = new PlatformOutput();
platformOutput.setId("plat_1");
platformOutput.setLabel(OptionalOutput.of("platform"));
datasetParameters.setPlatform(platformOutput);
// build expected title
StringBuilder expected = new StringBuilder();
// ParameterOutput platform = datasetParameters.getPlatform();
// expected.append(platform.getLabel());
ParameterOutput phenomenon = datasetParameters.getPhenomenon();
ParameterOutput procedure = datasetParameters.getProcedure();
ParameterOutput offering = datasetParameters.getOffering();
ParameterOutput service = datasetParameters.getService();
ParameterOutput category = datasetParameters.getCategory();
expected.append(platformOutput.getLabel()).append(" ").append(phenomenon.getLabel()).append(" ").append(procedure.getLabel()).append(" (4 opted-out)").append(" ").append(offering.getLabel()).append(" ").append(feature.getLabel()).append(" ").append(service.getLabel()).append(" ").append(metadata.getUom());
IoParameters ioConfig = createDefaults().extendWith("rendering_trigger", "prerendering");
IoStyleContext context = IoStyleContext.createContextWith(ioConfig, Collections.singletonList(metadata));
MyChartRenderer chartRenderer = new MyChartRenderer(ioConfig, 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()));
}
use of org.n52.io.response.dataset.DatasetParameters in project series-rest-api by 52North.
the class ChartIoHandler method formatTitle.
protected String formatTitle(DatasetOutput<?> metadata, String title) {
DatasetParameters parameters = metadata.getDatasetParameters();
Object[] varargs = { // index important to reference in config!
parameters.getPlatform().getLabel(), parameters.getPhenomenon().getLabel(), parameters.getProcedure().getLabel(), parameters.getCategory().getLabel(), parameters.getOffering().getLabel(), metadata.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;
}
}
use of org.n52.io.response.dataset.DatasetParameters in project series-rest-api by 52North.
the class PDFReportGenerator method addTimeseries.
private TimeSeries addTimeseries(DatasetOutput<?> output) {
DocumentStructureType report = document.getDocumentStructure();
TimeSeries timeseries = report.addNewTimeSeries();
DatasetParameters parameters = output.getDatasetParameters();
timeseries.setFeatureOfInterestID(output.getFeature().getLabel());
timeseries.setPhenomenID(parameters.getPhenomenon().getLabel());
timeseries.setProcedureID(parameters.getProcedure().getLabel());
return timeseries;
}
use of org.n52.io.response.dataset.DatasetParameters in project series-rest-api by 52North.
the class PDFReportGenerator method createValueTableHeader.
private String createValueTableHeader(TimeseriesMetadataOutput metadata) {
DatasetParameters parameters = metadata.getDatasetParameters();
String phenomenon = parameters.getPhenomenon().getLabel();
return phenomenon + " (" + metadata.getUom() + ")";
}
Aggregations