Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java @ 9432:d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
author | mschaefer |
---|---|
date | Mon, 20 Aug 2018 09:46:02 +0200 |
parents | 66c7f2defc80 |
children | af872dab1a0a |
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.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 String 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 String 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; } public String getWstLabel() { if (this.ud != null) return Integer.toString(this.endYear) + "; UD=" + Integer.toString(this.ud); // FIXME per WaterlevelDescriptionBuilder o.ä. zentralisieren return Integer.toString(this.endYear) + "; " + this.wst.getLabel(); } public String getBedHeightLabel() { if (this.sounding != null) return this.sounding.getDescription(); return ""; } public boolean getIsMissingVolume() { return !Double.isNaN(this.missingVolumeFrom); } @Override protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { exportContextCSV.writeCSVWaterlevelMetadata(this.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); if (this.missingVolumeFrom != null && this.missingVolumeTo != null) 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, " [" + river.getWstUnit() + "]"); 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); } }