annotate flys-artifacts/src/main/java/de/intevation/flys/exports/ComputedDischargeCurveExporter.java @ 2182:5ff481ab24a1

Refactored class hierachy to integrate model for W~W. flys-artifacts/trunk@3786 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 27 Jan 2012 10:45:34 +0000
parents 28dbeb64ce7c
children a9a8df1473fd
rev   line source
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.exports;
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.io.OutputStream;
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
4 import java.text.NumberFormat;
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.util.ArrayList;
701
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 664
diff changeset
6 import java.util.Arrays;
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import java.util.List;
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
8 import java.util.Map;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
9 import java.util.HashMap;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
10 import java.util.Date;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
11 import java.text.DateFormat;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
12 import java.util.Locale;
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.Document;
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.apache.log4j.Logger;
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import au.com.bytecode.opencsv.CSVWriter;
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
20 import net.sf.jasperreports.engine.JasperExportManager;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
21 import net.sf.jasperreports.engine.JasperFillManager;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
22 import net.sf.jasperreports.engine.JasperPrint;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
23 import net.sf.jasperreports.engine.JRException;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
24
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.artifacts.CallContext;
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
26 import de.intevation.artifacts.CallMeta;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
27
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
28 import de.intevation.flys.artifacts.FLYSArtifact;
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
715
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
30 import de.intevation.flys.artifacts.model.CalculationResult;
394
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
31 import de.intevation.flys.artifacts.model.WQKms;
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
32 import de.intevation.flys.artifacts.model.WKmsJRDataSource;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
33 import de.intevation.flys.artifacts.resources.Resources;
715
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
34
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
35 import de.intevation.flys.utils.FLYSUtils;
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
36 import de.intevation.flys.utils.Formatter;
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 /**
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 */
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 public class ComputedDischargeCurveExporter extends AbstractExporter {
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 /** The logger used in this exporter.*/
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 private static Logger logger =
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 Logger.getLogger(ComputedDischargeCurveExporter.class);
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
48
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
49 public static final String CSV_W_HEADER =
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
50 "export.computed.discharge.curve.csv.header.w";
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
51
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
52 public static final String CSV_Q_HEADER =
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
53 "export.computed.discharge.curve.csv.header.q";
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
54
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
55 public static final String DEFAULT_CSV_W_HEADER = "W [NN + m]";
664
e006da5679d2 s@m³/s@m\u00b3/s@
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 445
diff changeset
56 public static final String DEFAULT_CSV_Q_HEADER = "Q [m\u00b3/s]";
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
57
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
58 public static final String PDF_HEADER_MODE = "export.computed.discharge.pdf.mode";
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
59
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
394
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
61 protected List<WQKms> data;
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
62
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
63
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 public void init(Document request, OutputStream out, CallContext context) {
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 logger.debug("ComputedDischargeCurveExporter.init");
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 super.init(request, out, context);
394
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
68
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
69 this.data = new ArrayList<WQKms>();
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 }
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
701
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 664
diff changeset
73 @Override
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 664
diff changeset
74 protected void addData(Object d) {
715
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
75 if (d instanceof CalculationResult) {
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
76 d = ((CalculationResult)d).getData();
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
77 if (d instanceof WQKms []) {
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
78 data.addAll(Arrays.asList((WQKms [])d));
9665d6a48f7b Fix for flys/issue154
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 701
diff changeset
79 }
701
dad1a2c88f9f Base WST/CSV exports on facets. TODO: generate the facets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 664
diff changeset
80 }
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 }
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 protected void writeCSVData(CSVWriter writer) {
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 logger.info("ComputedDischargeCurveExporter.writeData");
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
87 writeCSVHeader(writer);
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
88
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
89 NumberFormat wf = getWFormatter();
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
90 NumberFormat qf = getQFormatter();
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
91
394
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
92 double[] res = new double[3];
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
93
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
94 for (WQKms wqkms: data) {
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
95 int size = wqkms.size();
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
96
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
97 for (int i = 0; i < size; i++) {
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
98 res = wqkms.get(i, res);
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
99
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
100 writer.writeNext(new String[] {
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
101 wf.format(res[0]),
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
102 qf.format(res[1])
394
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
103 });
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
104 }
b9175ddea49b Filled the discharge curve exporter (CSV) with code - now, it generates a CSV export with the computed discharge curve data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 392
diff changeset
105 }
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 }
416
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
107
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
108
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
109 protected void writeCSVHeader(CSVWriter writer) {
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
110 logger.debug("ComputedDischargeCurveExporter.writeCSVHeader");
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
111
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
112 writer.writeNext(new String[] {
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
113 msg(CSV_W_HEADER, DEFAULT_CSV_W_HEADER),
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
114 msg(CSV_Q_HEADER, DEFAULT_CSV_Q_HEADER)
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
115 });
340dc41a7ea3 The CSV exports will now have headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 394
diff changeset
116 }
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
117
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
118
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
119 /**
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
120 * Returns the number formatter for W values.
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
121 *
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
122 * @return the number formatter for W values.
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
123 */
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
124 protected NumberFormat getWFormatter() {
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
125 return Formatter.getComputedDischargeW(context);
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
126 }
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
127
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
128
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
129 /**
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
130 * Returns the number formatter for Q values.
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
131 *
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
132 * @return the number formatter for Q values.
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
133 */
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
134 protected NumberFormat getQFormatter() {
445
a7947972fdeb Added a new class that supports formatters for different types of data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 418
diff changeset
135 return Formatter.getComputedDischargeQ(context);
418
e0fec407a280 ISSUE-53 Formatted number values of CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 416
diff changeset
136 }
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 715
diff changeset
137
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 715
diff changeset
138
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 715
diff changeset
139 @Override
2177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
140 protected void writePDF(OutputStream out) {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
141 WKmsJRDataSource source = createJRData();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
142 Map parameters = new HashMap();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
143 parameters.put("ReportTitle", "Exported Data");
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
144 try {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
145 JasperPrint print = JasperFillManager.fillReport(
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
146 "conf/jasper/computed-discharge.jasper",
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
147 parameters,
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
148 source);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
149 JasperExportManager.exportReportToPdfStream(print, out);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
150 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
151 catch(JRException je) {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
152 logger.warn("Error generating PDF Report!");
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
153 je.printStackTrace();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
154 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
155 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
156
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
157
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
158 protected WKmsJRDataSource createJRData() {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
159 WKmsJRDataSource source = new WKmsJRDataSource();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
160
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
161 addMetaData(source);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
162 addWQData(source);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
163
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
164 return source;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
165 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
166
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
167
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
168 protected void addMetaData(WKmsJRDataSource source) {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
169 CallMeta meta = context.getMeta();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
170
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
171 FLYSArtifact flys = (FLYSArtifact) master;
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
172
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
173 source.addMetaData ("river", FLYSUtils.getRivername(flys));
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
174
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
175 Locale locale = Resources.getLocale(meta);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
176 DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
177
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
178 source.addMetaData("date", df.format(new Date()));
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
179
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
180 double[] kms = FLYSUtils.getKmRange(flys);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
181 source.addMetaData("range", String.valueOf(kms[0]));
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
182
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
183 source.addMetaData("calculation", Resources.getMsg(
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
184 locale,
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
185 PDF_HEADER_MODE,
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
186 "Computed Discharge"));
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
187 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
188
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
189 protected void addWQData(WKmsJRDataSource source) {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
190 NumberFormat wf = getWFormatter();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
191 NumberFormat qf = getQFormatter();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
192
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
193 double[] res = new double[3];
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
194
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
195 for (WQKms wqkms: data) {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
196 int size = wqkms.size();
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
197
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
198 for (int i = 0; i < size; i++) {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
199 res = wqkms.get(i, res);
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
200
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
201 source.addData(new String[] {
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
202 "", // Empty, the WKmsJRDtasource stores km here.
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
203 wf.format(res[0]),
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
204 qf.format(res[1])
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
205 });
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
206 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
207 }
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
208
28dbeb64ce7c Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
209 }
392
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 }
72177020db92 Improved the transition model and added classes to enable the WINFO artifact to create computed discharge curves - NOTE: each of the new classes is just a stub.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org