Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java @ 9438:d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
author | mschaefer |
---|---|
date | Mon, 20 Aug 2018 16:05:06 +0200 |
parents | af872dab1a0a |
children | ecadc9ed0ba0 |
rev | line source |
---|---|
9313 | 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 | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
15 import org.dive4elements.river.artifacts.bundu.BunduResultType; |
9313 | 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; | |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
23 import org.dive4elements.river.artifacts.model.WQKms; |
9313 | 24 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; |
25 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
26 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
27 | |
28 /** | |
29 * Contains the results of a //TODO LINK{@link BezugswstCalculation}. | |
30 * | |
31 * @author Gernot Belger | |
32 */ | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
33 final class BezugswstMainCalculationResult extends AbstractCalculationExportableResult { |
9313 | 34 |
35 private static final long serialVersionUID = 1L; | |
36 | |
37 private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.jrxml"; | |
38 | |
9323 | 39 private final WstInfo wst; |
40 private final BedHeightInfo sounding; | |
41 private final String function; | |
42 private final boolean preprocessing; | |
43 private final int startYear; | |
44 private final int endYear; | |
45 private final Double missingVolumeFrom; | |
46 private final Double missingVolumeTo; | |
47 private final Integer ud; | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
48 private final String qOfGauges; |
9313 | 49 |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
50 private final WQKms wqkms; |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
51 |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
52 public BezugswstMainCalculationResult(final String label, final Collection<ResultRow> rows, final BedHeightInfo sounding, final WstInfo wst, |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
53 final String function, final boolean preprocessing, final int startYear, final int endYear, final Integer ud, final String qOfGauges, |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
54 final WQKms wqkms, final Double missingVolumeFrom, final Double missingVolumeTo) { |
9313 | 55 super(label, rows); |
9323 | 56 this.wst = wst; |
57 this.sounding = sounding; | |
58 this.function = function; | |
59 this.preprocessing = preprocessing; | |
60 this.startYear = startYear; | |
61 this.endYear = endYear; | |
62 this.missingVolumeTo = missingVolumeTo; | |
63 this.missingVolumeFrom = missingVolumeFrom; | |
64 this.ud = ud; | |
65 this.qOfGauges = qOfGauges; | |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
66 this.wqkms = wqkms; |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
67 } |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
68 |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
69 public WQKms getWQKms() { |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
70 return this.wqkms; |
9313 | 71 } |
72 | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
73 public String getWstLabel() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
74 if (this.ud != null) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
75 return Integer.toString(this.endYear) + "; UD=" + Integer.toString(this.ud); // FIXME per WaterlevelDescriptionBuilder o.ä. zentralisieren |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
76 return Integer.toString(this.endYear) + "; " + this.wst.getLabel(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
77 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
78 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
79 public String getBedHeightLabel() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
80 if (this.sounding != null) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
81 return this.sounding.getDescription(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
82 return ""; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
83 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
84 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
85 public boolean getIsMissingVolume() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
86 return !Double.isNaN(this.missingVolumeFrom); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
87 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
88 |
9313 | 89 @Override |
90 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
91 | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
92 exportContextCSV.writeCSVWaterlevelMetadata(this.wst); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
93 exportContextCSV.writeBlankLine(); |
9435 | 94 exportContextCSV.writeCSVSoundingMetadata(this.sounding, "common.export.csv.meta.header.sounding"); |
9323 | 95 |
96 // Reihenfolge in der LV anders; ich finde sie aber so sinnvoller | |
97 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function); | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
98 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.preprocessing", exportContextCSV.msg(String.valueOf(this.preprocessing))); |
9323 | 99 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.q_period", String.valueOf(this.startYear), String.valueOf(this.endYear)); |
100 if (this.ud != null) | |
101 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.ud", this.ud); | |
102 else if (this.qOfGauges != null) | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
103 exportContextCSV.writeCSVMetaEntry("common.export.waterlevel.csv.meta.q", this.qOfGauges); |
9323 | 104 |
9337 | 105 if (this.missingVolumeFrom != null && this.missingVolumeTo != null) |
106 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.missing_volume_range", this.missingVolumeFrom, this.missingVolumeTo); | |
9323 | 107 |
108 exportContextCSV.writeBlankLine(); | |
9313 | 109 } |
110 | |
111 @Override | |
112 protected String getJasperFile() { | |
113 return JASPER_FILE; | |
114 } | |
115 | |
116 protected String[] formatRow(final IExportContext exportContext, final ResultRow row) { | |
117 | |
118 final Collection<String> lines = new ArrayList<>(10); | |
119 | |
120 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
121 lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst)); |
9313 | 122 lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit)); |
123 | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
124 lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
125 lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); |
9313 | 126 lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); |
127 | |
128 return lines.toArray(new String[lines.size()]); | |
129 } | |
130 | |
131 @Override | |
132 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
133 final int colSize = 6; |
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
134 exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.overview", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
135 final Collection<String> header = new ArrayList<>(colSize); |
9313 | 136 |
137 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
138 header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst) + " [" + river.getWstUnit() + "]"); |
9313 | 139 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit)); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
140 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
141 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); |
9313 | 142 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); |
143 | |
144 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
145 | |
146 } | |
147 | |
148 @Override | |
149 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
150 | |
151 return this.formatRow(exportContextCSV, row); | |
152 } | |
153 | |
154 @Override | |
155 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
156 | |
157 return this.formatRow(exportContextPDF, row); | |
158 } | |
159 | |
160 @Override | |
161 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
162 /* column headings */ | |
163 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
164 exportContextPDF.addJRMetadata(source, "bezugswst_header", BunduResultType.bezugswst); |
9331 | 165 // exportContextPDF.addJRMetadata(source, " [" + river.getWstUnit() + "]"); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
166 exportContextPDF.addJRMetadata(source, "discharge_header", GeneralResultType.dischargeQwithUnit); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
167 exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
168 exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); |
9313 | 169 exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); |
170 | |
171 } | |
172 } |