Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java @ 9330:0a0937f33bb5
bundu.bezugswst first result for missing volume added
author | gernotbelger |
---|---|
date | Fri, 27 Jul 2018 17:19:27 +0200 |
parents | artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculationResult.java@86d2cbfe7f7f |
children | 127638669052 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java Fri Jul 27 17:19:27 2018 +0200 @@ -0,0 +1,148 @@ +/* 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.bundu.bezugswst; + +import java.util.ArrayList; +import java.util.Collection; + +import org.dive4elements.river.artifacts.bundu.BunduResultType; +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.util.BedHeightInfo; +import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; +import org.dive4elements.river.artifacts.sinfo.util.WstInfo; + +/** + * Contains the results of a //TODO LINK{@link BezugswstCalculation}. + * + * @author Gernot Belger + */ +final class BezugswstMainCalculationResult extends AbstractCalculationExportableResult { + + private static final long serialVersionUID = 1L; + + private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.jrxml"; + + private final WstInfo wst; + private final BedHeightInfo sounding; + private final String function; + private final boolean preprocessing; + private final int startYear; + private final int endYear; + private final Double missingVolumeFrom; + private final Double missingVolumeTo; + private final Integer ud; + private final double[] qOfGauges; + + public BezugswstMainCalculationResult(final String label, final Collection<ResultRow> rows, final BedHeightInfo sounding, final WstInfo wst, + final String function, final boolean preprocessing, final int startYear, final int endYear, final Integer ud, final double[] qOfGauges, + final Double missingVolumeFrom, final Double missingVolumeTo) { + super(label, rows); + this.wst = wst; + this.sounding = sounding; + this.function = function; + this.preprocessing = preprocessing; + this.startYear = startYear; + this.endYear = endYear; + this.missingVolumeTo = missingVolumeTo; + this.missingVolumeFrom = missingVolumeFrom; + this.ud = ud; + this.qOfGauges = qOfGauges; + } + + @Override + protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { + + // TODO: wenn wst und peilung vorhanden sind, sollte dieser Teil wieder einkommentiert werden + // exportContextCSV.writeCSVWaterlevelMetadata(wst); + // exportContextCSV.writeBlankLine(); + // exportContextCSV.writeCSVSoundingMetadata(this.sounding, " "); + + // Reihenfolge in der LV anders; ich finde sie aber so sinnvoller + exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function); + exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.preprocessing", exportContextCSV.msg(String.valueOf(this.preprocessing))); + exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.q_period", String.valueOf(this.startYear), String.valueOf(this.endYear)); + if (this.ud != null) + exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.ud", this.ud); + else if (this.qOfGauges != null) + exportContextCSV.writeCSVMetaEntry("common.export.waterlevel.csv.meta.q", this.qOfGauges); // was auch immer dieser String beinhalten mag + + exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function); + exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.missing_volume_range", this.missingVolumeFrom, this.missingVolumeTo); + + exportContextCSV.writeBlankLine(); + } + + @Override + protected String getJasperFile() { + return JASPER_FILE; + } + + protected String[] formatRow(final IExportContext exportContext, final ResultRow row) { + + final Collection<String> lines = new ArrayList<>(10); + + lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); + lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit)); + + lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); + lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); + + return lines.toArray(new String[lines.size()]); + } + + @Override + public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { + final int colSize = 6; + exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.overview", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern + final Collection<String> header = new ArrayList<>(colSize); + + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); + header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst) + " [" + river.getWstUnit() + "]"); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); + + exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); + + } + + @Override + protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { + + return this.formatRow(exportContextCSV, row); + } + + @Override + protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { + + return this.formatRow(exportContextPDF, row); + } + + @Override + protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { + /* column headings */ + exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); + exportContextPDF.addJRMetadata(source, "bezugswst_header", BunduResultType.bezugswst); + exportContextPDF.addJRMetadata(source, "discharge_header", GeneralResultType.dischargeQwithUnit); + exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); + exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); + exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); + + } +} \ No newline at end of file