Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQTJRDataSource.java @ 3064:478e8d9d88ba
Add missing imports.
flys-artifacts/trunk@4648 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 13 Jun 2012 09:28:39 +0000 |
parents | 89ca1e8572e4 |
children | 4bd3d8bbb60c |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 if ("date".equals(fieldName)) { |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 if ("calculation".equals(fieldName)) { |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 if ("range".equals(fieldName)) { |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 if ("W".equals(fieldName)) { |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 if ("Q".equals(fieldName)) { |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 if ("delta".equals(fieldName)) { |
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 } |
89ca1e8572e4
Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 if ("gaugename".equals(fieldName)) { |
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 } |