annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQTJRDataSource.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children af13ceeba52a
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3085
diff changeset
9 package org.dive4elements.river.artifacts.model;
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import java.util.ArrayList;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 import java.util.HashMap;
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 import org.apache.log4j.Logger;
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 import net.sf.jasperreports.engine.JRDataSource;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import net.sf.jasperreports.engine.JRException;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 import net.sf.jasperreports.engine.JRField;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19
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 * @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
23 */
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 public class WQTJRDataSource implements JRDataSource
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 {
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 /** The logger used in this exporter.*/
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 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
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 private ArrayList<String[]> data;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 private HashMap<String, String> metaData;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 private int index = -1;
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 public WQTJRDataSource()
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 data = new ArrayList<String[]>();
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 metaData = new HashMap<String, String>();
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 addData(String[] data) {
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 this.data.add(data);
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 void addMetaData(String key, String value) {
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 this.metaData.put(key, value);
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 }
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
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 public boolean next() throws JRException
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 index++;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 return (index < data.size());
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 }
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 /**
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 */
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 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
78 {
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 Object value = "";
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 String fieldName = field.getName();
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 if ("river".equals(fieldName)) {
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 value = metaData.get("river");
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
84 else if ("date".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 value = metaData.get("date");
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
87 else if ("calculation".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 value = metaData.get("calculation");
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
90 else if ("range".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 value = data.get(index)[0];
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
93 else if ("W".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 value = data.get(index)[1];
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
96 else if ("Q".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 value = data.get(index)[2];
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
99 else if ("delta".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 value = data.get(index)[3];
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 }
3085
3e5f45a9e052 Added missing 'else's in if/else ladders.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3083
diff changeset
102 else if ("gaugename".equals(fieldName)) {
2286
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 value = data.get(index)[4];
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 }
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 return value;
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 }
89ca1e8572e4 Added PDF export for historical discharge curve calculations.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 }
3083
4bd3d8bbb60c Added missing vim lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2286
diff changeset
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org