annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsJRDataSource.java @ 2552:c7dbe696286c

Refactored the wq data fields. flys-artifacts/trunk@4065 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 16 Feb 2012 12:36:25 +0000
parents 65b32220f197
children 4bd3d8bbb60c
rev   line source
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 import java.util.HashMap;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 import net.sf.jasperreports.engine.JRDataSource;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 import net.sf.jasperreports.engine.JRException;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import net.sf.jasperreports.engine.JRField;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 public class WKmsJRDataSource implements JRDataSource
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 /** The logger used in this exporter.*/
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 private static Logger logger = Logger.getLogger(WKmsJRDataSource.class);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 *
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 private ArrayList<String[]> data;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 private HashMap<String, String> metaData;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 private int index = -1;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 *
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 public WKmsJRDataSource()
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 data = new ArrayList<String[]>();
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 metaData = new HashMap<String, String>();
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 *
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 public void addData(String[] data) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 this.data.add(data);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 *
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 public void addMetaData(String key, String value) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 this.metaData.put(key, value);
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 *
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 public boolean next() throws JRException
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 index++;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 return (index < data.size());
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 /**
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 *
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 */
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 public Object getFieldValue(JRField field) throws JRException
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 Object value = "";
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 String fieldName = field.getName();
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 if ("river".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 value = metaData.get("river");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 if ("date".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 value = metaData.get("date");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 if ("range".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 value = metaData.get("range");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 if ("gauge".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 value = metaData.get("gauge");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 if ("calculation".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 value = metaData.get("calculation");
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 }
2180
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2178
diff changeset
88 if ("differences".equals(fieldName)) {
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2178
diff changeset
89 value = metaData.get("differences");
65b32220f197 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2178
diff changeset
90 }
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 if ("km".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 value = data.get(index)[0];
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 if ("W".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 value = data.get(index)[1];
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 if ("Q".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 value = data.get(index)[2];
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 if ("description".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 value = data.get(index)[3];
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 if ("location".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 value = data.get(index)[4];
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 if ("gaugename".equals(fieldName)) {
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 value = data.get(index)[5];
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 }
2178
1d7fb2cabfc7 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
109 if ("day".equals(fieldName)) {
1d7fb2cabfc7 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
110 value = data.get(index)[6];
1d7fb2cabfc7 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2176
diff changeset
111 }
2176
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 return value;
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 }
65dac9cf6ff5 Issue 138.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 }

http://dive4elements.wald.intevation.org