Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
9329:6a7758923762 | 9330:0a0937f33bb5 |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.bundu.bezugswst; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
14 | |
15 import org.dive4elements.river.artifacts.bundu.BunduResultType; | |
16 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | |
17 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
18 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
19 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
20 import org.dive4elements.river.artifacts.common.IExportContext; | |
21 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
22 import org.dive4elements.river.artifacts.common.ResultRow; | |
23 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; | |
24 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
25 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
26 | |
27 /** | |
28 * Contains the results of a //TODO LINK{@link BezugswstCalculation}. | |
29 * | |
30 * @author Gernot Belger | |
31 */ | |
32 final class BezugswstMainCalculationResult extends AbstractCalculationExportableResult { | |
33 | |
34 private static final long serialVersionUID = 1L; | |
35 | |
36 private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.jrxml"; | |
37 | |
38 private final WstInfo wst; | |
39 private final BedHeightInfo sounding; | |
40 private final String function; | |
41 private final boolean preprocessing; | |
42 private final int startYear; | |
43 private final int endYear; | |
44 private final Double missingVolumeFrom; | |
45 private final Double missingVolumeTo; | |
46 private final Integer ud; | |
47 private final double[] qOfGauges; | |
48 | |
49 public BezugswstMainCalculationResult(final String label, final Collection<ResultRow> rows, final BedHeightInfo sounding, final WstInfo wst, | |
50 final String function, final boolean preprocessing, final int startYear, final int endYear, final Integer ud, final double[] qOfGauges, | |
51 final Double missingVolumeFrom, final Double missingVolumeTo) { | |
52 super(label, rows); | |
53 this.wst = wst; | |
54 this.sounding = sounding; | |
55 this.function = function; | |
56 this.preprocessing = preprocessing; | |
57 this.startYear = startYear; | |
58 this.endYear = endYear; | |
59 this.missingVolumeTo = missingVolumeTo; | |
60 this.missingVolumeFrom = missingVolumeFrom; | |
61 this.ud = ud; | |
62 this.qOfGauges = qOfGauges; | |
63 } | |
64 | |
65 @Override | |
66 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
67 | |
68 // TODO: wenn wst und peilung vorhanden sind, sollte dieser Teil wieder einkommentiert werden | |
69 // exportContextCSV.writeCSVWaterlevelMetadata(wst); | |
70 // exportContextCSV.writeBlankLine(); | |
71 // exportContextCSV.writeCSVSoundingMetadata(this.sounding, " "); | |
72 | |
73 // Reihenfolge in der LV anders; ich finde sie aber so sinnvoller | |
74 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function); | |
75 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.preprocessing", exportContextCSV.msg(String.valueOf(this.preprocessing))); | |
76 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.q_period", String.valueOf(this.startYear), String.valueOf(this.endYear)); | |
77 if (this.ud != null) | |
78 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.ud", this.ud); | |
79 else if (this.qOfGauges != null) | |
80 exportContextCSV.writeCSVMetaEntry("common.export.waterlevel.csv.meta.q", this.qOfGauges); // was auch immer dieser String beinhalten mag | |
81 | |
82 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function); | |
83 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.missing_volume_range", this.missingVolumeFrom, this.missingVolumeTo); | |
84 | |
85 exportContextCSV.writeBlankLine(); | |
86 } | |
87 | |
88 @Override | |
89 protected String getJasperFile() { | |
90 return JASPER_FILE; | |
91 } | |
92 | |
93 protected String[] formatRow(final IExportContext exportContext, final ResultRow row) { | |
94 | |
95 final Collection<String> lines = new ArrayList<>(10); | |
96 | |
97 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
98 lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst)); | |
99 lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit)); | |
100 | |
101 lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); | |
102 lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); | |
103 lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); | |
104 | |
105 return lines.toArray(new String[lines.size()]); | |
106 } | |
107 | |
108 @Override | |
109 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
110 final int colSize = 6; | |
111 exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.overview", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern | |
112 final Collection<String> header = new ArrayList<>(colSize); | |
113 | |
114 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
115 header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst) + " [" + river.getWstUnit() + "]"); | |
116 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit)); | |
117 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); | |
118 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); | |
119 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); | |
120 | |
121 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
122 | |
123 } | |
124 | |
125 @Override | |
126 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
127 | |
128 return this.formatRow(exportContextCSV, row); | |
129 } | |
130 | |
131 @Override | |
132 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
133 | |
134 return this.formatRow(exportContextPDF, row); | |
135 } | |
136 | |
137 @Override | |
138 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
139 /* column headings */ | |
140 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | |
141 exportContextPDF.addJRMetadata(source, "bezugswst_header", BunduResultType.bezugswst); | |
142 exportContextPDF.addJRMetadata(source, "discharge_header", GeneralResultType.dischargeQwithUnit); | |
143 exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); | |
144 exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); | |
145 exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); | |
146 | |
147 } | |
148 } |