Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java @ 9376:f318359b81a2
S-Info flood duration theme rename, and more infrastructure themes in the duration curve
author | mschaefer |
---|---|
date | Fri, 03 Aug 2018 17:02:38 +0200 |
parents | a49fe0ebb297 |
children | 10530f1d7dd5 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.artifacts.sinfo.flood_duration; import java.util.List; import org.dive4elements.river.artifacts.common.AbstractCommonExporter; import org.dive4elements.river.artifacts.common.ExportContextCSV; import org.dive4elements.river.artifacts.common.ExportContextPDF; import org.dive4elements.river.artifacts.common.GeneralResultType; import org.dive4elements.river.artifacts.common.JasperDesigner; import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.sinfo.common.SInfoI18NStrings; /** * Generates different output formats (csv, pdf) of data that resulted from a flood duration computation. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> * @author Gernot Belger */ // REMARK: must be public because its registered in generators.xml public class FloodDurationExporter extends AbstractCommonExporter<FloodDurationCalculationResult, FloodDurationCalculationResults> { @Override protected void writeCSVGlobalMetadata(final ExportContextCSV exportContext, final FloodDurationCalculationResults results) { exportContext.writeCSVGlobalMetadataDefaults(); exportContext.writeBlankLine(); final List<FloodDurationCalculationResult> resultList = results.getResults(); if (resultList.isEmpty()) return; final FloodDurationCalculationResult result = resultList.get(0); final int waterlevelCount = result.getWaterlevelCount(); if (waterlevelCount >= 1) { // "##METADATEN WASSERSPIEGELLAGE" exportContext.writeCSVMetaEntry(SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL); for (int i = 0; i < waterlevelCount; i++) { // "# Bezeichnung der Wasserspiegellage: " final String label = result.getWaterlevelLabel(i); exportContext.writeCSVMetaEntry(SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_NAME, String.format("%d: %s", i + 1, label)); } // "# Bezugspegel: " for (final ResultRow row : result.getRows()) { exportContext.writeCSVMetaEntry(SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_GAUGE, row.getValue(GeneralResultType.gaugeLabel)); break; } } } @Override protected void writePDFGlobalMetadata(final ExportContextPDF exportContext, final MetaAndTableJRDataSource source) { exportContext.addJRMetaDataForModules(source); } @Override protected void configureDesign(final FloodDurationCalculationResult result, final JasperDesigner design) { final int wlCount = result.getWaterlevelCount(); if (wlCount == 0 || wlCount == 2) { design.removeColumn("wOpt"); design.removeColumn("qOpt"); design.removeColumn("bezOpt"); design.removeColumn("durOpt"); } } }