Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/exports/fixings/DeltaWtExporter.java @ 9360:ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
Removed old outliers theme.
Also consider showpoints property.
Also consider pointsize property.
author | gernotbelger |
---|---|
date | Wed, 01 Aug 2018 17:13:52 +0200 |
parents | a49fe0ebb297 |
children | 9744ce3c3853 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5603
diff
changeset
|
9 package org.dive4elements.river.exports.fixings; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.io.IOException; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.io.OutputStream; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 import java.text.DateFormat; |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
14 import java.text.MessageFormat; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import java.text.NumberFormat; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import java.util.ArrayList; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import java.util.List; |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
18 import java.util.TreeMap; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
9082 | 21 import org.dive4elements.artifacts.CallMeta; |
22 import org.dive4elements.river.artifacts.D4EArtifact; | |
9306 | 23 import org.dive4elements.river.artifacts.access.RangeAccess; |
9082 | 24 import org.dive4elements.river.artifacts.access.RiverAccess; |
9306 | 25 import org.dive4elements.river.artifacts.common.DefaultCalculationResults; |
26 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
27 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
28 import org.dive4elements.river.artifacts.common.JasperReporter; | |
29 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
9082 | 30 import org.dive4elements.river.artifacts.model.CalculationResult; |
31 import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod; | |
32 import org.dive4elements.river.artifacts.model.fixings.FixAnalysisResult; | |
33 import org.dive4elements.river.artifacts.model.fixings.QWD; | |
34 import org.dive4elements.river.artifacts.resources.Resources; | |
9306 | 35 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils; |
36 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
9082 | 37 import org.dive4elements.river.exports.AbstractExporter; |
38 import org.dive4elements.river.utils.Formatter; | |
39 import org.dive4elements.river.utils.KMIndex; | |
40 | |
41 import au.com.bytecode.opencsv.CSVWriter; | |
9306 | 42 import net.sf.jasperreports.engine.JRException; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
3644
fa633f6a5fd9
smaller part of issue825 fixed (column ordering of dwt-export).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
44 /** Exports fixation analysis deltaw(t) computation results to csv. */ |
9082 | 45 public class DeltaWtExporter extends AbstractExporter { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7088
diff
changeset
|
46 /** Private log. */ |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 private static Logger log = Logger.getLogger(DeltaWtExporter.class); |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
9306 | 49 private static final String JASPER_FILE = "/jasper/templates/fixanalysis.delta_wt.jrxml"; |
50 | |
9082 | 51 public static final String CSV_KM_HEADER = "export.fixings.deltawt.csv.header.km"; |
3397
6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
52 |
9082 | 53 public static final String CSV_DELTA_W_HEADER = "export.fixings.deltawt.csv.header.deltaw"; |
3402
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
54 |
9082 | 55 public static final String CSV_Q_HEADER = "export.fixings.deltawt.csv.header.q"; |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
56 |
9082 | 57 public static final String CSV_W_HEADER = "export.fixings.deltawt.csv.header.w"; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
9082 | 59 public static final String CSV_TRANGE_HEADER = "export.fixings.deltawt.csv.header.time.range"; |
60 | |
61 public static final String CSV_T_HEADER = "export.fixings.deltawt.csv.header.t"; | |
62 | |
63 public static final String CSV_T_FORMAT = "export.fixings.deltawt.csv.t.format"; | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 public static final String DEFAULT_CSV_KM_HEADER = "km"; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 public static final String DEFAULT_CSV_DELTA_W_HEADER = "\u0394 W [cm]"; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
3402
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
69 public static final String DEFAULT_CSV_W_HEADER = "Wasserstand [m]"; |
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
70 |
3397
6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
71 public static final String DEFAULT_CSV_Q_HEADER = "Abfluss [m\u00b3/s]"; |
6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
72 |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 public static final String DEFAULT_CSV_T_HEADER = "Datum"; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 |
9082 | 75 public static final String DEFAULT_CSV_TRANGE_DESC_HEADER = "Status"; |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
76 |
9082 | 77 public static final String CSV_REFERENCE = "export.fixings.deltawt.csv.reference"; |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
78 |
9082 | 79 public static final String CSV_ANALYSIS = "export.fixings.deltawt.csv.analysis"; |
3402
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
80 |
9082 | 81 public static final String DEFAULT_CSV_REFERENCE = "B"; |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
82 |
9082 | 83 public static final String DEFAULT_CSV_ANALYSIS = "A{0,number,integer}"; |
84 | |
85 public static final String DEFAULT_CSV_T_FORMAT = "dd.MM.yyyy"; | |
86 | |
87 protected List<KMIndex<AnalysisPeriod[]>> analysisPeriods; | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 protected List<KMIndex<QWD[]>> referenceEvents; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 |
7077
0a337f0005c2
Extended init() of OutGenerator to take name of the out to serve.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
91 public DeltaWtExporter() { |
9082 | 92 this.analysisPeriods = new ArrayList<>(); |
93 this.referenceEvents = new ArrayList<>(); | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 @Override |
9082 | 97 protected void addData(final Object d) { |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 log.debug("DeltaWtExporter.addData"); |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 if (!(d instanceof CalculationResult)) { |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 log.warn("Invalid data type"); |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 return; |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 |
9082 | 104 final Object data = ((CalculationResult) d).getData(); |
3415
e3c7a3228bc2
FixA: Renamed FixResult to FixAnalysisResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3402
diff
changeset
|
105 if (!(data instanceof FixAnalysisResult)) { |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 log.warn("Invalid data stored in result."); |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 } |
9082 | 108 final FixAnalysisResult result = (FixAnalysisResult) data; |
109 this.analysisPeriods.add(result.getAnalysisPeriods()); | |
9360
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
110 this.referenceEvents.add(result.getFixings()); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 @Override |
9082 | 114 protected void writeCSVData(final CSVWriter writer) throws IOException { |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 writeCSVHeader(writer); |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 |
9306 | 118 final TreeMap<Double, ArrayList<String[]>> sorted = getRows(); |
119 for (final ArrayList<String[]> list : sorted.values()) { | |
120 for (final String[] row : list) { | |
121 writer.writeNext(row); | |
122 } | |
123 } | |
124 | |
125 writer.flush(); | |
126 } | |
127 | |
128 private TreeMap<Double, ArrayList<String[]>> getRows() { | |
9082 | 129 final NumberFormat kmF = getKMFormatter(); |
130 final NumberFormat dwF = getDeltaWFormatter(); | |
131 final NumberFormat qF = getQFormatter(); | |
132 final NumberFormat wF = getWFormatter(); | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 |
9082 | 134 final DateFormat dF = getDateFormatter(); |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
135 |
9082 | 136 final TreeMap<Double, ArrayList<String[]>> sorted = new TreeMap<>(); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 |
9082 | 138 final String referenceS = getReference(); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 |
9082 | 140 for (final KMIndex<QWD[]> reference : this.referenceEvents) { |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
141 |
9082 | 142 for (final KMIndex.Entry<QWD[]> kmEntry : reference) { |
143 | |
144 final Double km = kmEntry.getKm(); | |
145 | |
146 ArrayList<String[]> list = sorted.get(km); | |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
147 |
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
148 if (list == null) { |
9082 | 149 list = new ArrayList<>(); |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
150 sorted.put(km, list); |
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
151 } |
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
152 |
9082 | 153 final String kmS = kmF.format(kmEntry.getKm()); |
154 for (final QWD qwd : kmEntry.getValue()) { | |
9360
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
155 if( !qwd.isOutlier() ) { |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
156 final String deltaWS = dwF.format(qwd.getDeltaW()); |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
157 final String qS = qF.format(qwd.getQ()); |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
158 final String wS = wF.format(qwd.getW()); |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
159 final String dateS = dF.format(qwd.getDate()); |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
160 |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
161 list.add(new String[] { kmS, dateS, qS, wS, referenceS, deltaWS }); |
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9322
diff
changeset
|
162 } |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
163 } |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
164 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
165 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
166 |
9082 | 167 final String analysisTemplate = getAnalysisTemplate(); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 |
9082 | 169 for (final KMIndex<AnalysisPeriod[]> periods : this.analysisPeriods) { |
4736
b195fede1c3b
Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4238
diff
changeset
|
170 |
9082 | 171 for (final KMIndex.Entry<AnalysisPeriod[]> kmEntry : periods) { |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
172 |
9082 | 173 final Double km = kmEntry.getKm(); |
174 | |
175 ArrayList<String[]> list = sorted.get(km); | |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
176 |
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
177 if (list == null) { |
9082 | 178 list = new ArrayList<>(); |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
179 sorted.put(km, list); |
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
180 } |
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
181 |
9082 | 182 final String kmS = kmF.format(kmEntry.getKm()); |
4238
50273de4cf63
flys/issue825/2 Fix labeling of Analysisperiods (like A1, A2....)
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3915
diff
changeset
|
183 int analysisCount = 1; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
184 |
9082 | 185 for (final AnalysisPeriod period : kmEntry.getValue()) { |
4238
50273de4cf63
flys/issue825/2 Fix labeling of Analysisperiods (like A1, A2....)
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3915
diff
changeset
|
186 // Typically resulting in A1,A2... |
9082 | 187 final String analyisS = MessageFormat.format(analysisTemplate, analysisCount); |
188 final QWD[] qwds = period.getQWDs(); | |
3644
fa633f6a5fd9
smaller part of issue825 fixed (column ordering of dwt-export).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
189 |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 if (qwds != null) { |
9082 | 191 for (final QWD qwd : qwds) { |
192 final String deltaWS = dwF.format(qwd.getDeltaW()); | |
193 final String qS = qF.format(qwd.getQ()); | |
194 final String wS = wF.format(qwd.getW()); | |
195 final String dateS = dF.format(qwd.getDate()); | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 |
9082 | 197 list.add(new String[] { kmS, dateS, qS, wS, analyisS, deltaWS }); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
198 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 } |
4238
50273de4cf63
flys/issue825/2 Fix labeling of Analysisperiods (like A1, A2....)
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3915
diff
changeset
|
200 ++analysisCount; |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
201 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
202 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
203 } |
9306 | 204 return sorted; |
5603
47e5bc64d3de
FixA: tab output ist now grouped by km and periods. Fixes flys/issue1163
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4736
diff
changeset
|
205 |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
206 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
207 |
3644
fa633f6a5fd9
smaller part of issue825 fixed (column ordering of dwt-export).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
208 /** Template to create "State" strings like A1,A2... */ |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
209 protected String getAnalysisTemplate() { |
9082 | 210 return Resources.getMsg(this.context.getMeta(), CSV_ANALYSIS, DEFAULT_CSV_ANALYSIS); |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
211 } |
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
212 |
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
213 protected String getReference() { |
9082 | 214 return Resources.getMsg(this.context.getMeta(), CSV_REFERENCE, DEFAULT_CSV_REFERENCE); |
3398
7f9fe694f8d1
FixA: Added time range column to Delta W(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3397
diff
changeset
|
215 } |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
216 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
217 protected NumberFormat getKMFormatter() { |
9082 | 218 return Formatter.getFixDeltaWKM(this.context); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
219 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
220 |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
221 protected NumberFormat getDeltaWFormatter() { |
9082 | 222 return Formatter.getFixDeltaWDeltaW(this.context); |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
223 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
224 |
9082 | 225 @Override |
3397
6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
226 protected NumberFormat getQFormatter() { |
9082 | 227 return Formatter.getFixDeltaWQ(this.context); |
3397
6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
228 } |
6d1740533810
FixA: Added discharge column to DeltaW(t) CSV export.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
229 |
9082 | 230 @Override |
3402
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
231 protected NumberFormat getWFormatter() { |
9082 | 232 return Formatter.getFixDeltaWW(this.context); |
3402
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
233 } |
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
234 |
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
235 protected DateFormat getDateFormatter() { |
9082 | 236 final CallMeta meta = this.context.getMeta(); |
237 return Formatter.getDateFormatter(meta, Resources.getMsg(meta, CSV_T_FORMAT, DEFAULT_CSV_T_FORMAT)); | |
3402
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
238 } |
0336132ec9db
Adjusted Delta W(t) CSV exporter to customers wishes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3398
diff
changeset
|
239 |
9082 | 240 protected void writeCSVHeader(final CSVWriter writer) { |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 log.debug("DeltaWtExporter.writeCSVHeader"); |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 |
9082 | 243 /* |
244 * issue825 | |
245 * km; Ereignis, Abfluss, GEMESSENER Wasserstand; | |
246 * Status (RECHTSBÜNDIG), del W | |
247 */ | |
248 final RiverAccess river = new RiverAccess((D4EArtifact) this.master); | |
249 final String unit = river.getRiver().getWstUnit().getName(); | |
3644
fa633f6a5fd9
smaller part of issue825 fixed (column ordering of dwt-export).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
250 |
9082 | 251 writer.writeNext(new String[] { msg(CSV_KM_HEADER, DEFAULT_CSV_KM_HEADER), msg(CSV_T_HEADER, DEFAULT_CSV_T_HEADER), |
252 msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER), msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { unit }), | |
253 msg(CSV_TRANGE_HEADER, DEFAULT_CSV_TRANGE_DESC_HEADER), msg(CSV_DELTA_W_HEADER, DEFAULT_CSV_DELTA_W_HEADER) }); | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
254 } |
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 |
9306 | 256 private void addMetaData(final MetaAndTableJRDataSource source) { |
257 final D4EArtifact flys = (D4EArtifact) this.master; | |
258 final String user = CalculationUtils.findArtifactUser(this.context, flys); | |
259 final RangeAccess ra = new RangeAccess(flys); | |
260 final RiverInfo ri = new RiverInfo(ra.getRiver()); | |
261 | |
262 final DefaultCalculationResults results = new DefaultCalculationResults(msg("calculation.analysis"), user, ri, ra.getRange()); | |
263 final ExportContextPDF contextPdf = new ExportContextPDF(this.context, results); | |
264 contextPdf.addJRMetaDataDefaults(source); | |
9322 | 265 contextPdf.addJRMetaDataForModules(source); |
9306 | 266 |
267 /* column headings */ | |
268 contextPdf.addJRMetadata(source, "station_header", GeneralResultType.station); | |
269 contextPdf.addJRMetadata(source, "fix_date", msg(CSV_T_HEADER)); | |
270 contextPdf.addJRMetadata(source, "fix_q", msg(CSV_Q_HEADER)); | |
271 contextPdf.addJRMetadata(source, "fix_w", msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER, new Object[] { ri.getWstUnit() })); | |
272 contextPdf.addJRMetadata(source, "fix_state", msg(CSV_TRANGE_HEADER)); | |
273 contextPdf.addJRMetadata(source, "fix_delta_w", msg(CSV_DELTA_W_HEADER)); | |
274 } | |
275 | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
276 @Override |
9082 | 277 protected void writePDF(final OutputStream out) { |
9306 | 278 final MetaAndTableJRDataSource source = new MetaAndTableJRDataSource(); |
279 final String jasperFile = Resources.getMsg(this.context.getMeta(), JASPER_FILE); | |
280 addMetaData(source); | |
281 try { | |
282 final TreeMap<Double, ArrayList<String[]>> sorted = getRows(); // Custom Result could be nice, too... | |
283 for (final ArrayList<String[]> list : sorted.values()) { | |
284 for (final String[] row : list) { | |
285 source.addData(row); | |
286 } | |
287 } | |
288 final JasperReporter reporter = new JasperReporter(); | |
289 reporter.addReport(jasperFile, source); | |
290 reporter.exportPDF(out); | |
291 } | |
292 catch (final JRException je) { | |
293 log.warn("Error generating PDF Report!", je); | |
294 } | |
3216
a46910e61dfb
FixA: Moved DeltaWtExporter to fixings exporter package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
295 } |
9306 | 296 } |