comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/SQRelationJRDataSource.java @ 6173:5d88268f184d

Add SQRelationJRDataSource class Forgot to add it in the last commit
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 03 Jun 2013 17:16:47 +0200
parents
children f0f62743c83a
comparison
equal deleted inserted replaced
6172:58a613798386 6173:5d88268f184d
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 package org.dive4elements.river.artifacts.model.sq;
10
11 import java.util.ArrayList;
12 import java.util.HashMap;
13
14 import org.apache.log4j.Logger;
15
16 import net.sf.jasperreports.engine.JRDataSource;
17 import net.sf.jasperreports.engine.JRException;
18 import net.sf.jasperreports.engine.JRField;
19
20
21 /**
22 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
23 */
24 public class SQRelationJRDataSource implements JRDataSource
25 {
26 /** The logger used in this exporter.*/
27 private static Logger logger = Logger.getLogger(SQRelationJRDataSource.class);
28
29 private ArrayList<String[]> data;
30 private HashMap<String, String> metaData;
31
32 private int index = -1;
33
34 public SQRelationJRDataSource() {
35 data = new ArrayList<String[]>();
36 metaData = new HashMap<String, String>();
37 }
38
39 public void addData(String[] val) {
40 data.add(val);
41 }
42
43 public void addMetaData(String key, String value) {
44 metaData.put(key, value);
45 }
46
47 public boolean next() throws JRException {
48 index++;
49 return (index < data.size());
50 }
51
52 public Object getFieldValue(JRField field) throws JRException {
53 Object value = "";
54 String fieldName = field.getName();
55 if ("river".equals(fieldName)) {
56 value = metaData.get("river");
57 }
58 else if ("date".equals(fieldName)) {
59 value = metaData.get("date");
60 }
61 else if ("calculation".equals(fieldName)) {
62 value = metaData.get("calculation");
63 }
64 else if ("location".equals(fieldName)) {
65 value = metaData.get("location");
66 }
67 else if ("outliers".equals(fieldName)) {
68 value = metaData.get("outliers");
69 }
70 else if ("outliertest".equals(fieldName)) {
71 value = metaData.get("outliertest");
72 }
73 else if ("periods".equals(fieldName)) {
74 value = metaData.get("periods");
75 }
76 else if ("km".equals(fieldName)) {
77 value = data.get(index)[0];
78 }
79 else if ("param".equals(fieldName)) {
80 value = data.get(index)[1];
81 }
82 else if ("a".equals(fieldName)) {
83 value = data.get(index)[2];
84 }
85 else if ("b".equals(fieldName)) {
86 value = data.get(index)[3];
87 }
88 else if ("total".equals(fieldName)) {
89 value = data.get(index)[4];
90 }
91 else if ("out".equals(fieldName)) {
92 value = data.get(index)[5];
93 }
94 else if ("variance".equals(fieldName)) {
95 value = data.get(index)[6];
96 }
97 return value;
98 }
99 }
100 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org