Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/SQOverview.java @ 3286:f062b5a90e26
Add showpointlabel style attribute
flys-artifacts/trunk@4948 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 12 Jul 2012 11:51:32 +0000 |
parents | 4903e491992e |
children | 30f157c7e466 |
rev | line source |
---|---|
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import java.text.SimpleDateFormat; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import java.util.ArrayList; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import java.util.Date; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import java.util.List; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import org.apache.log4j.Logger; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import org.hibernate.SQLQuery; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import org.hibernate.Session; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import org.hibernate.type.StandardBasicTypes; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import org.w3c.dom.Document; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import org.w3c.dom.Element; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.utils.KMIndex; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 public class SQOverview |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 implements Serializable |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 /** |
3276
4903e491992e
Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3275
diff
changeset
|
28 * Serial version UId. |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 */ |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 private static final long serialVersionUID = -8934372438968398508L; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 public interface Filter { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 boolean accept(KMIndex<List<Date>> entry); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 } // interface Filter |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 public static final Filter ACCEPT = new Filter() { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 @Override |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 public boolean accept(KMIndex<List<Date>> entry) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 return true; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 }; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 public static class KmFilter implements Filter { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 protected double km; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 public KmFilter (double km) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 this.km = km; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 @Override |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 public boolean accept(KMIndex<List<Date>> list) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 for (KMIndex.Entry<List<Date>> e: list){ |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 if (e.getKm() == km) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 return true; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 return false; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 }; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 public static class DateFilter implements Filter { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 protected Date date; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 public DateFilter (Date date) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 this.date = date; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 @Override |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 public boolean accept(KMIndex<List<Date>> list) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 for (KMIndex.Entry<List<Date>> e: list){ |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 if (e.getValue().equals(this.date)) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 return true; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 return false; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 }; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 private static Logger log = Logger.getLogger(FixingsOverview.class); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
84 public static final double EPSILON = 1e-4; |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 public static final String DATE_FORMAT = "dd.MM.yyyy"; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 public static final String SQL_SQ = |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 "SELECT" + |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
90 " s.km AS km," + |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
91 " m.datum AS datum " + |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 "FROM messung m " + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 " JOIN station s" + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 " on m.stationid = s.stationid " + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 " JOIN gewaesser g " + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 " on s.gewaesserid = g.gewaesserid " + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 "WHERE" + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 " g.name = :name " + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 " order by" + |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 " s.km, m.datum"; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 protected String riverName; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 protected KMIndex<List<Date>> entries; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 public SQOverview() { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 entries = new KMIndex<List<Date>>(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 public SQOverview(String riverName) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 this(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 this.riverName = riverName; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
115 private static final boolean epsilonEquals(double a, double b) { |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
116 return Math.abs(a - b) < EPSILON; |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
117 } |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
118 |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 protected void loadData(Session session) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 SQLQuery query = session.createSQLQuery(SQL_SQ) |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 .addScalar("km", StandardBasicTypes.DOUBLE) |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 .addScalar("datum", StandardBasicTypes.DATE); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 query.setString("name", riverName); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 List<Object []> list = query.list(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 if (list.isEmpty()) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 log.warn("No river '" + riverName + "' found."); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
132 Double prevKm = -Double.MAX_VALUE; |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 List<Date> dates = new ArrayList<Date>(); |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
134 |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
135 for (Object [] row: list) { |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
136 Double km = (Double)row[0]; |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
137 if (!epsilonEquals(km, prevKm) && !dates.isEmpty()) { |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 entries.add(prevKm, dates); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 dates = new ArrayList<Date>(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 } |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
141 dates.add((Date)row[1]); |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 prevKm = km; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 } |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
144 |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
145 if (!dates.isEmpty()) { |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
146 entries.add(prevKm, dates); |
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
147 } |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 public boolean load(Session session) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 loadData(session); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 return true; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 public void generateOverview(Document document) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 generateOverview(document, ACCEPT); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 public KMIndex<List<Date>> filter(Filter f) { |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
163 // TODO: Apply filter |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 return entries; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 public void generateOverview( |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 Document document, |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 Filter filter |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 ) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 KMIndex<List<Date>> filtered = filter(ACCEPT); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 Element sqElement = document.createElement("sq"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 Element riverElement = document.createElement("river"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 riverElement.setAttribute("name", riverName); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 sqElement.appendChild(riverElement); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 Element kmE = document.createElement("km"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 for (KMIndex.Entry<List<Date>> e: filtered) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 List<Date> dates = e.getValue(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 if (!dates.isEmpty()) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 Element dEs = document.createElement("dates"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 for (Date d: dates) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 Element dE = document.createElement("date"); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 dE.setAttribute("value", df.format(d)); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 dEs.appendChild(dE); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 kmE.appendChild(dEs); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
203 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
204 sqElement.appendChild(kmE); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 document.appendChild(sqElement); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
208 } |
3275
3570abdf7daa
SQOverview: Made km separating of dates epsilon tolerant and avoid empty date lists.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3274
diff
changeset
|
209 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |