Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/SQOverview.java @ 3316:2495b24147ff
Forget file to save.
flys-artifacts/trunk@5006 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 15 Jul 2012 16:02:25 +0000 |
parents | 36f3b53d5cfc |
children | 816ceb0418b9 |
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" + |
3287
30f157c7e466
SQ: Filter out meassures which don't have a 'Siebsatz'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3276
diff
changeset
|
94 " ON m.stationid = s.stationid " + |
3274
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 " + |
3287
30f157c7e466
SQ: Filter out meassures which don't have a 'Siebsatz'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3276
diff
changeset
|
96 " ON s.gewaesserid = g.gewaesserid " + |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 "WHERE" + |
3290
36f3b53d5cfc
SQ relation: Added infrastructure to extract fractions from measurments.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3289
diff
changeset
|
98 " m.q IS NOT NULL AND" + |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 " g.name = :name " + |
3287
30f157c7e466
SQ: Filter out meassures which don't have a 'Siebsatz'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3276
diff
changeset
|
100 "ORDER by" + |
30f157c7e466
SQ: Filter out meassures which don't have a 'Siebsatz'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3276
diff
changeset
|
101 " s.km, m.datum"; |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 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
|
104 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 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
|
106 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 public SQOverview() { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 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
|
109 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 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
|
112 this(); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 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
|
114 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 |
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
|
116 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
|
117 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
|
118 } |
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
|
119 |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 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
|
121 SQLQuery query = session.createSQLQuery(SQL_SQ) |
3289
ec9aab93f292
SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3287
diff
changeset
|
122 .addScalar("km", StandardBasicTypes.DOUBLE) |
ec9aab93f292
SQ: First peek into fetching relevant data from SedDB
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3287
diff
changeset
|
123 .addScalar("datum", StandardBasicTypes.DATE); |
3274
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 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
|
126 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 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
|
128 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 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
|
130 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
|
131 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 |
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
|
133 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
|
134 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
|
135 |
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 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 } |
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
|
142 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
|
143 prevKm = km; |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 } |
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
|
145 |
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 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
|
147 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
|
148 } |
3274
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 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 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
|
152 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 loadData(session); |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 return true; |
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 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 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
|
160 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
|
161 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 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
|
164 // 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
|
165 return entries; |
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 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 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
|
169 Document document, |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 Filter filter |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 ) { |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 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
|
173 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 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
|
175 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 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
|
177 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 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
|
179 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 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
|
181 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 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
|
183 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 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
|
185 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 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
|
187 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 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
|
189 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 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
|
191 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
|
192 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 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
|
194 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
|
195 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 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
|
197 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 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
|
199 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 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
|
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 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 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
|
206 |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
207 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
|
208 } |
43e42315ce22
Added service for an overview chart of measuring points in sq relation.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
209 } |
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
|
210 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |