Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WWQQJRDataSource.java @ 3298:b92e86a78895
Removed superfluous imports.
flys-artifacts/trunk@4983 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 13 Jul 2012 10:15:55 +0000 |
parents | 3e5f45a9e052 |
children |
rev | line source |
---|---|
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.util.HashMap; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import net.sf.jasperreports.engine.JRDataSource; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import net.sf.jasperreports.engine.JRException; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import net.sf.jasperreports.engine.JRField; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 public class WWQQJRDataSource implements JRDataSource |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 /** The logger used in this exporter.*/ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 private static Logger logger = Logger.getLogger(WWQQJRDataSource.class); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 * |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 private ArrayList<String[]> data; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 private HashMap<String, String> metaData; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 private int index = -1; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 * |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 public WWQQJRDataSource() |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 data = new ArrayList<String[]>(); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 metaData = new HashMap<String, String>(); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 } |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 * |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 public void addData(String[] data) { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 this.data.add(data); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 } |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 * |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 public void addMetaData(String key, String value) { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 this.metaData.put(key, value); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 } |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 * |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 public boolean next() throws JRException |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 index++; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 return (index < data.size()); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 } |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 /** |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 * |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 */ |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 public Object getFieldValue(JRField field) throws JRException |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 Object value = ""; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 String fieldName = field.getName(); |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 if ("river".equals(fieldName)) { |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 value = metaData.get("river"); |
ecb76933362f
Added PDF export to reference curve calculation.
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)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 value = metaData.get("date"); |
ecb76933362f
Added PDF export to reference curve calculation.
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)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 value = metaData.get("calculation"); |
ecb76933362f
Added PDF export to reference curve calculation.
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 ("reference".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 value = metaData.get("reference"); |
ecb76933362f
Added PDF export to reference curve calculation.
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 ("location".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 value = metaData.get("location"); |
ecb76933362f
Added PDF export to reference curve calculation.
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 ("km1".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 value = data.get(index)[0]; |
ecb76933362f
Added PDF export to reference curve calculation.
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 ("location1".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 value = data.get(index)[1]; |
ecb76933362f
Added PDF export to reference curve calculation.
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 ("W1".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 value = data.get(index)[2]; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
97 else if ("Q1".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 value = data.get(index)[3]; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
100 else if ("km2".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 value = data.get(index)[4]; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
103 else if ("location2".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 value = data.get(index)[5]; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
106 else if ("W2".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 value = data.get(index)[6]; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
109 else if ("Q2".equals(fieldName)) { |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 value = data.get(index)[7]; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
112 else if ("Wcm1".equals(fieldName)) { |
2631
87085ccea466
Issue 528, 637.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2310
diff
changeset
|
113 value = data.get(index)[8]; |
87085ccea466
Issue 528, 637.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2310
diff
changeset
|
114 } |
3085
3e5f45a9e052
Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3083
diff
changeset
|
115 else if ("Wcm2".equals(fieldName)) { |
2631
87085ccea466
Issue 528, 637.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2310
diff
changeset
|
116 value = data.get(index)[9]; |
87085ccea466
Issue 528, 637.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2310
diff
changeset
|
117 } |
2310
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 return value; |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 } |
ecb76933362f
Added PDF export to reference curve calculation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 } |
3083
4bd3d8bbb60c
Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2631
diff
changeset
|
121 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |