Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTJRDataSource.java @ 4693:a91d3bde7255
Change parameters of updateCollectionName
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Mon, 17 Dec 2012 16:15:05 +0100 |
parents | 3e5f45a9e052 |
children |
rev | line source |
---|---|
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.util.HashMap; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import net.sf.jasperreports.engine.JRDataSource; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import net.sf.jasperreports.engine.JRException; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import net.sf.jasperreports.engine.JRField; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 public class WQTJRDataSource implements JRDataSource |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 /** The logger used in this exporter.*/ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 private static Logger logger = Logger.getLogger(WQTJRDataSource.class); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 * |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 private ArrayList<String[]> data; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 private HashMap<String, String> metaData; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 private int index = -1; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 * |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 public WQTJRDataSource() |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 data = new ArrayList<String[]>(); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 metaData = new HashMap<String, String>(); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 * |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 public void addData(String[] data) { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 this.data.add(data); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 * |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 public void addMetaData(String key, String value) { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 this.metaData.put(key, value); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 * |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 public boolean next() throws JRException |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 index++; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 return (index < data.size()); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 /** |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 * |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 */ |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 public Object getFieldValue(JRField field) throws JRException |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 Object value = ""; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 String fieldName = field.getName(); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 if ("river".equals(fieldName)) { |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 value = metaData.get("river"); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
76 else if ("date".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 value = metaData.get("date"); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
79 else if ("calculation".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 value = metaData.get("calculation"); |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
82 else if ("range".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 value = data.get(index)[0]; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
85 else if ("W".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 value = data.get(index)[1]; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
88 else if ("Q".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 value = data.get(index)[2]; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
91 else if ("delta".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 value = data.get(index)[3]; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
94 else if ("gaugename".equals(fieldName)) { |
2286
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 value = data.get(index)[4]; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 return value; |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2286
diff
changeset
|
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |