Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepthminmax/FlowDepthMinMaxCalculationResult.java @ 9312:740d65e4aa14
Q [m³/s] one message
author | gernotbelger |
---|---|
date | Thu, 26 Jul 2018 15:54:20 +0200 |
parents | a4121ec450d6 |
children | 7b2b086e45f0 |
line wrap: on
line source
/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde * Software engineering by * Björnsen Beratende Ingenieure GmbH * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt * * 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.flowdepthminmax; import java.util.ArrayList; import java.util.Collection; import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; 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.IExportContext; import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; import org.dive4elements.river.artifacts.common.ResultRow; import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; import org.dive4elements.river.artifacts.sinfo.util.WstInfo; /** * Contains the results of a {@link FloodDurationCalculation}. * * @author Gernot Belger */ final class FlowDepthMinMaxCalculationResult extends AbstractCalculationExportableResult { private static final long serialVersionUID = 1L; private static final String JASPER_FILE = "/jasper/templates/sinfo.flowdepthminmax.jrxml"; private final BedHeightInfo sounding; private final WstInfo wst; public FlowDepthMinMaxCalculationResult(final String label, final WstInfo wst, final BedHeightInfo sounding, final Collection<ResultRow> rows) { super(label, rows); this.wst = wst; this.sounding = sounding; } public BedHeightInfo getSounding() { return this.sounding; } @Override public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { final Collection<String> header = new ArrayList<>(11); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthmin)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.flowdepthmax)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.waterlevel, river.getWstUnit())); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.discharge)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.waterlevelLabel)); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.gaugeLabel)); header.add(exportContextCSV.msgUnitCSV(SInfoResultType.meanBedHeight, river.getWstUnit())); header.add(exportContextCSV.formatCsvHeader(SInfoResultType.soundingLabel)); header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); } @Override protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { exportContextCSV.writeCSVSoundingMetadata(this.sounding); exportContextCSV.writeBlankLine(); exportContextCSV.writeCSVWaterlevelMetadata(this.wst); exportContextCSV.writeBlankLine(); } @Override protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { return formatRow(exportContextCSV, row); } @Override protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { return formatRow(exportContextPDF, row); } @Override protected String getJasperFile() { return this.JASPER_FILE; } @Override protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { /* column headings */ exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); exportContextPDF.addJRMetadata(source, "flowdepthmin_header", SInfoResultType.flowdepthmin); exportContextPDF.addJRMetadata(source, "flowdepthmax_header", SInfoResultType.flowdepthmax); exportContextPDF.addJRMetadata(source, "waterlevel_header", SInfoResultType.waterlevel); exportContextPDF.addJRMetadata(source, "discharge_header", SInfoResultType.discharge); exportContextPDF.addJRMetadata(source, "waterlevel_name_header", SInfoResultType.waterlevelLabel); exportContextPDF.addJRMetadata(source, "gauge_header", SInfoResultType.gaugeLabel); exportContextPDF.addJRMetadata(source, "bedheight_header", SInfoResultType.meanBedHeight); exportContextPDF.addJRMetadata(source, "sounding_name_header", SInfoResultType.soundingLabel); exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); } protected String[] formatRow(final IExportContext exportContextCSV, final ResultRow row) { final Collection<String> lines = new ArrayList<>(10); lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); // REMARK: null check as pdf will call this with null and in that case we show all columns (to avoid multiple jasper // FIXME: does not work like this: we may have several pairs of min/max; so we need to look at all of them? // templates) // if (result == null || result.getMinSounding() != null) lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.flowdepthmin)); // if (result == null || result.getMaxSounding() != null) lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.flowdepthmax)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.waterlevel)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.discharge)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.waterlevelLabel)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.gaugeLabel)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.meanBedHeight)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.soundingLabel)); lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); } }