annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsJRDataSource.java @ 3781:8e713e9bb4d7

Defined colors for bed quality themes. flys-artifacts/trunk@5488 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 17 Sep 2012 09:40:00 +0000
parents 3e5f45a9e052
children
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 }
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)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
79 else if ("range".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
82 else if ("gauge".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
85 else if ("calculation".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
88 else if ("differences".equals(fieldName)) {
2180
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
91 else if ("km".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
94 else if ("W".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
97 else if ("Q".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
100 else if ("description".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
103 else if ("location".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
106 else if ("gaugename".equals(fieldName)) {
2176
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 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
109 else if ("day".equals(fieldName)) {
2178
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 }
3083
4bd3d8bbb60c Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2180
diff changeset
115 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org