Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedOverview.java @ 4357:11cf29eb002c
FacetTypes: New type: exreme_wq_curve_base (for the Stuetz-Q-Poits).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 11:58:11 +0100 |
parents | ae598cf50682 |
children |
rev | line source |
---|---|
3751
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.minfo; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.text.SimpleDateFormat; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import java.util.ArrayList; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import java.util.Date; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import java.util.List; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import org.apache.log4j.Logger; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import org.hibernate.SQLQuery; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import org.hibernate.Session; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import org.hibernate.type.StandardBasicTypes; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import org.w3c.dom.Document; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 import org.w3c.dom.Element; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.flys.utils.KMIndex; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 public class BedOverview |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 implements Serializable |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 /** |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 * Serial version UId. |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 */ |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 private static final long serialVersionUID = -7967134407371364911L; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 public interface Filter { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 boolean accept(KMIndex<List<Date>> entry); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 } // interface Filter |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 public static final Filter ACCEPT = new Filter() { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 public boolean accept(KMIndex<List<Date>> entry) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 return true; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 }; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 public static class KmFilter implements Filter { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 protected double km; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 public KmFilter (double km) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 this.km = km; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 public boolean accept(KMIndex<List<Date>> list) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 for (KMIndex.Entry<List<Date>> e: list){ |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 if (e.getKm() == km) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 return true; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 return false; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 }; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 public static class DateFilter implements Filter { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 protected Date date; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 public DateFilter (Date date) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 this.date = date; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 public boolean accept(KMIndex<List<Date>> list) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 for (KMIndex.Entry<List<Date>> e: list){ |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 if (e.getValue().equals(this.date)) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 return true; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 return false; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 }; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 private static Logger log = Logger.getLogger(BedOverview.class); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 public static final double EPSILON = 1e-4; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 public static final String DATE_FORMAT = "dd.MM.yyyy"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 public static final String SQL_SQ = |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 "SELECT" + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 " so.km AS km," + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 " so.datum AS datum " + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 "FROM sohltest so " + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 " JOIN station s" + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 " ON so.stationid = s.stationid " + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 " JOIN gewaesser g " + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 " ON s.gewaesserid = g.gewaesserid " + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 "WHERE" + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 " g.name = :name AND" + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 " so.km IS NOT NULL " + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 "ORDER by" + |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 " so.km, so.datum"; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 protected String riverName; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 protected KMIndex<List<Date>> entries; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 public BedOverview() { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 entries = new KMIndex<List<Date>>(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 public BedOverview(String riverName) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 this(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 this.riverName = riverName; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 private static final boolean epsilonEquals(double a, double b) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 return Math.abs(a - b) < EPSILON; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 protected void loadData(Session session) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 SQLQuery query = session.createSQLQuery(SQL_SQ) |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 .addScalar("km", StandardBasicTypes.DOUBLE) |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 .addScalar("datum", StandardBasicTypes.DATE); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 query.setString("name", riverName); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 List<Object []> list = query.list(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 if (list.isEmpty()) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 log.warn("No river '" + riverName + "' found."); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 Double prevKm = -Double.MAX_VALUE; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 List<Date> dates = new ArrayList<Date>(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 for (Object [] row: list) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 Double km = (Double)row[0]; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 if (!epsilonEquals(km, prevKm) && !dates.isEmpty()) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 entries.add(prevKm, dates); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 dates = new ArrayList<Date>(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 dates.add((Date)row[1]); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 prevKm = km; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 if (!dates.isEmpty()) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 entries.add(prevKm, dates); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 public boolean load(Session session) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 loadData(session); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 return true; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 public void generateOverview(Document document) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 generateOverview(document, ACCEPT); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 public KMIndex<List<Date>> filter(Filter f) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 // TODO: Apply filter |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 return entries; |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 public void generateOverview( |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 Document document, |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 Filter filter |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 ) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 KMIndex<List<Date>> filtered = filter(ACCEPT); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 Element sqElement = document.createElement("bed"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 Element riverElement = document.createElement("river"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 riverElement.setAttribute("name", riverName); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 sqElement.appendChild(riverElement); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
173 SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 Element kmE = document.createElement("km"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
176 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
177 for (KMIndex.Entry<List<Date>> e: filtered) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
178 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 List<Date> dates = e.getValue(); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
181 if (!dates.isEmpty()) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
182 Element dEs = document.createElement("dates"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
183 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
184 for (Date d: dates) { |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
185 Element dE = document.createElement("date"); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
187 dE.setAttribute("value", df.format(d)); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
188 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
189 dEs.appendChild(dE); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 kmE.appendChild(dEs); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 sqElement.appendChild(kmE); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 document.appendChild(sqElement); |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 } |
ae598cf50682
Added new services to render overview charts in minfo bed quality calculation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 } |