Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMissVolCalculationResult2.java @ 9448:d32b11d585cd
CSV-Export bundu.wst fehlvolumen
author | gernotbelger |
---|---|
date | Wed, 22 Aug 2018 11:51:46 +0200 |
parents | e60584f2a531 |
children | 7e1fb8d0cb0d |
rev | line source |
---|---|
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
9331 | 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 import java.util.List; | |
15 | |
16 import org.dive4elements.river.artifacts.bundu.BunduResultType; | |
17 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; | |
18 import org.dive4elements.river.artifacts.common.AbstractExportContext; | |
19 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
20 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
21 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
22 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
23 import org.dive4elements.river.artifacts.common.ResultRow; | |
24 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
25 import org.dive4elements.river.model.BedHeightValueType; |
9331 | 26 |
27 /** | |
28 * Contains the results of a //TODO LINK{@link BezugswstCalculation}. | |
29 * | |
30 * @author Gernot Belger | |
31 */ | |
9332 | 32 final class BezugswstMissVolCalculationResult2 extends AbstractCalculationExportableResult implements BunduWstExporter.MissResultType { |
9331 | 33 |
34 private static final long serialVersionUID = 1L; | |
35 | |
36 private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.result2.jrxml"; | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
37 private static final String fieldVolumeMsgKey = "bundu.export.bezugswst.csv.meta.miss.volume.field"; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
38 private static final String fieldMassMsgKey = "bundu.export.bezugswst.csv.meta.miss.mass.field"; |
9331 | 39 |
40 public BezugswstMissVolCalculationResult2(final String label, final Collection<ResultRow> rows) { | |
41 super(label, rows); | |
42 | |
43 } | |
44 | |
45 @Override | |
46 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
47 // no metadata | |
48 } | |
49 | |
50 @Override | |
51 protected String getJasperFile() { | |
52 return JASPER_FILE; | |
53 } | |
54 | |
55 protected String[] formatRow(final AbstractExportContext exportContext, final ResultRow row) { | |
56 | |
57 final Collection<String> lines = new ArrayList<>(20); | |
58 | |
59 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
60 @SuppressWarnings("unchecked") |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
61 final List<Double> vFields = (List<Double>) row.getValue(BunduResultType.missVolumeFields); |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
62 assert (vFields.size() == fieldSize()); // immer abgleichen mit der Calculation! |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
63 @SuppressWarnings("unchecked") |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
64 final List<Double> mFields = (List<Double>) row.getValue(BunduResultType.missMassFields); |
9448 | 65 assert (vFields.size() == mFields.size()); |
66 for (int i = 0; i < vFields.size(); i++) { | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
67 lines.add(BunduResultType.missVolumeFields.exportValue(exportContext.getContext(), vFields.get(i))); |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
68 lines.add(BunduResultType.missMassFields.exportValue(exportContext.getContext(), mFields.get(i))); |
9331 | 69 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
70 lines.add(exportContext.formatRowValue(row, BunduResultType.missVolumeMeanBed)); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
71 lines.add(exportContext.formatRowValue(row, BunduResultType.missMassMeanBed)); |
9331 | 72 |
73 return lines.toArray(new String[lines.size()]); | |
74 } | |
75 | |
76 @Override | |
77 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
78 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
79 final int colSize = 2 * fieldSize() + 3; |
9331 | 80 exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.result2", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
81 final Collection<String> header = new ArrayList<>(colSize); | |
82 | |
83 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
84 | |
9448 | 85 for (int i = 1; i <= fieldSize() * 2; i++) { |
86 final double index = Math.ceil(i / 2.); | |
87 header.add(exportContextCSV.msg(fieldVolumeMsgKey, index)); | |
88 i++; | |
89 header.add(exportContextCSV.msg(fieldMassMsgKey, index)); | |
9331 | 90 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
91 header.add(exportContextCSV.formatCsvHeader(BunduResultType.missVolumeMeanBed)); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
92 header.add(exportContextCSV.formatCsvHeader(BunduResultType.missMassMeanBed)); |
9331 | 93 |
94 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
95 | |
96 } | |
97 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
98 /** |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
99 * Number of elements of the various field lists |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
100 */ |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
101 private int fieldSize() { |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
102 return BedHeightValueType.FIELD_LAST_INDEX - BedHeightValueType.FIELD_FIRST_INDEX + 1; |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
103 } |
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
104 |
9331 | 105 @Override |
106 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
107 | |
108 return this.formatRow(exportContextCSV, row); | |
109 } | |
110 | |
111 @Override | |
112 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
113 | |
114 return this.formatRow(exportContextPDF, row); | |
115 } | |
116 | |
117 @Override | |
118 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
119 /* column headings */ | |
120 | |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
121 // TODO Auftrennung jeder Volumen+Masse-Spalte in zwei getrennte Volumen- und Masse-Spalten |
9331 | 122 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); |
9446
e60584f2a531
Added bundu bzws calculation for missing volumes (masses still not yet ready) and results1/2/3
mschaefer
parents:
9444
diff
changeset
|
123 for (int i = 1; i <= fieldSize(); i++) { |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
124 exportContextPDF.addJRMetadata(source, "field_header" + String.valueOf(i), exportContextPDF.msg(fieldVolumeMsgKey, i)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9432
diff
changeset
|
125 exportContextPDF.addJRMetadata(source, "field_header" + String.valueOf(i), exportContextPDF.msg(fieldMassMsgKey, i)); |
9331 | 126 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
127 exportContextPDF.addJRMetadata(source, "mean_bedheight_header", BunduResultType.missVolumeMeanBed); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9332
diff
changeset
|
128 exportContextPDF.addJRMetadata(source, "mean_bedheight_header", BunduResultType.missMassMeanBed); |
9331 | 129 |
130 } | |
131 } |