Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java @ 8768:ef0ec2498dd0
issue1841 Only include loads where value != NaN in info service
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 20 Aug 2015 19:14:56 +0200 |
parents | 665c8326b1a6 |
children | 5e38e2924c07 |
rev | line source |
---|---|
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Bundesanstalt für Gewässerkunde |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
3 * |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
7 */ |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
8 package org.dive4elements.river.artifacts.model.minfo; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
9 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
10 import java.sql.Timestamp; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.HashMap; |
8089
7e55790da464
Use list() instead of iterator(). Why does this not work?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8058
diff
changeset
|
12 import java.util.List; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
13 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
14 import net.sf.ehcache.Cache; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
15 import net.sf.ehcache.Element; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
16 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8097
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.RiverFactory; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
19 import org.dive4elements.river.artifacts.cache.CacheFactory; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.dive4elements.river.backend.SessionHolder; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
21 import org.hibernate.SQLQuery; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
22 import org.hibernate.Session; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
23 import org.hibernate.type.StandardBasicTypes; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
24 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
25 public class SedimentLoadDataFactory |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
26 { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
27 private static Logger log = Logger.getLogger(SedimentLoadDataFactory.class); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
28 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
29 public static final String CACHE_NAME = "sediment-load-data"; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
30 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
31 public static final String SUSPENDED_STRING = "Schwebstoff"; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
32 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
33 public static final String SQL_LOAD_RIVER_SEDIMENT_LOADS = |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
34 "WITH load_at_river AS (" + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
35 "SELECT DISTINCT sl.id, " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
36 "sl.kind, " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
37 "sl.description, " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
38 "sl.time_interval_id, " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
39 "sl.grain_fraction_id, " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
40 "sl.sq_time_interval_id " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
41 "FROM sediment_load sl " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
42 "JOIN sediment_load_values slv ON sl.id = slv.sediment_load_id " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
43 "JOIN measurement_station ms ON ms.id = slv.measurement_station_id " + |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8259
diff
changeset
|
44 "JOIN ranges rs ON rs.id = ms.range_id " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8259
diff
changeset
|
45 "JOIN rivers r ON r.id = rs.river_id " + |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
46 "WHERE r.name = :river) " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
47 "SELECT " + |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
48 "sl.id AS sl_id, " + |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8055
diff
changeset
|
49 "sl.kind AS sl_kind, " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
50 "sl.description AS sl_description, " + |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
51 "ti.start_time AS ti_start_time, " + |
8097
6f3cf934ae99
Fix ti_stop_time naming
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8089
diff
changeset
|
52 "ti.stop_time AS ti_stop_time, " + |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
53 "sqti.start_time AS sq_start_time, " + |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
54 "sqti.stop_time AS sq_stop_time, " + |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
55 "sqti.id AS sq_ti_id, " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
56 "slv.value AS slv_value, " + |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
57 "gf.name AS gf_name, " + |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
58 "ms.id AS ms_id, " + |
8413
665c8326b1a6
We only want to use stations with an end km.
Tom Gottfried <tom@intevation.de>
parents:
8412
diff
changeset
|
59 "CASE WHEN r.km_up = 1 THEN rs.b ELSE rs.a END AS ms_station, " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
60 "ms.measurement_type AS ms_type " + |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
61 "FROM load_at_river sl " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
62 "CROSS JOIN measurement_station ms " + |
8259
1fc453fbc5df
Measurement stations without range should not be used in calculation and we assume the beginning of the range is the station.
Tom Gottfried <tom@intevation.de>
parents:
8237
diff
changeset
|
63 "JOIN ranges rs ON ms.range_id = rs.id " + |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
8259
diff
changeset
|
64 "JOIN rivers r ON rs.river_id = r.id " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
65 "JOIN time_intervals ti ON sl.time_interval_id = ti.id " + |
8210
3bb00338228c
(issue1448) Use left join to permit loads with empty sq_time intervals to be handled.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8199
diff
changeset
|
66 "LEFT JOIN time_intervals sqti ON sl.sq_time_interval_id = sqti.id " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
67 "JOIN grain_fraction gf ON sl.grain_fraction_id = gf.id " + |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
68 "LEFT JOIN sediment_load_values slv " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
69 "ON ms.id=slv.measurement_station_id AND sl.id=slv.sediment_load_id " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
70 "WHERE (" + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
71 "(ms.measurement_type='Geschiebe' AND gf.name IN " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
72 "('coarse', 'fine_middle', 'sand', 'susp_sand', " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
73 "'susp_sand_bed', 'bed_load', 'bed_load_susp_sand', " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
74 "'suspended_load', 'total')) " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
75 "OR " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
76 "(ms.measurement_type='Schwebstoff' AND gf.name IN " + |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
77 "('suspended_sediment', 'suspended_load', 'total'))) " + |
8413
665c8326b1a6
We only want to use stations with an end km.
Tom Gottfried <tom@intevation.de>
parents:
8412
diff
changeset
|
78 "AND rs.b IS NOT NULL " + |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
79 "AND r.name = :river " + |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
80 "ORDER BY sl.id"; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
81 |
8055
cd35b76f1ef8
Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
82 public static final SedimentLoadDataFactory INSTANCE = |
cd35b76f1ef8
Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
83 new SedimentLoadDataFactory(); |
cd35b76f1ef8
Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
84 |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
85 private SedimentLoadDataFactory() { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
86 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
87 |
8055
cd35b76f1ef8
Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8047
diff
changeset
|
88 public synchronized SedimentLoadData getSedimentLoadData(String river) { |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
89 boolean debug = log.isDebugEnabled(); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
90 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
91 if (debug) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
92 log.debug( |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
93 "Looking for sediment load data for river '" + river + "'"); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
94 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
95 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
96 Cache cache = CacheFactory.getCache(CACHE_NAME); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
97 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
98 if (cache == null) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
99 if (debug) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
100 log.debug("Cache not configured."); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
101 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
102 return getUncached(river); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
103 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
104 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
105 String key = "sediment-load-" + river; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
106 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
107 Element element = cache.get(key); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
108 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
109 if (element != null) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
110 if (debug) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
111 log.debug("Sediment load data found in cache"); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
112 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
113 return (SedimentLoadData)element.getValue(); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
114 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
115 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
116 SedimentLoadData sedimentLoad = getUncached(river); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
117 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
118 if (sedimentLoad != null) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
119 if (debug) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
120 log.debug("Store sediment load data in cache."); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
121 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
122 cache.put(new Element(key, sedimentLoad)); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
123 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
124 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
125 return sedimentLoad; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
127 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
128 public SedimentLoadData getUncached(String river) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
129 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
130 Session session = SessionHolder.HOLDER.get(); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
131 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
132 SQLQuery sqlQuery = session.createSQLQuery(SQL_LOAD_RIVER_SEDIMENT_LOADS) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
133 .addScalar("sl_id", StandardBasicTypes.INTEGER) |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8055
diff
changeset
|
134 .addScalar("sl_kind", StandardBasicTypes.INTEGER) |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
135 .addScalar("sl_description", StandardBasicTypes.STRING) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
136 .addScalar("ti_start_time", StandardBasicTypes.TIMESTAMP) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
137 .addScalar("ti_stop_time", StandardBasicTypes.TIMESTAMP) |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
138 .addScalar("sq_start_time", StandardBasicTypes.TIMESTAMP) |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
139 .addScalar("sq_stop_time", StandardBasicTypes.TIMESTAMP) |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
140 .addScalar("sq_ti_id", StandardBasicTypes.INTEGER) |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
141 .addScalar("slv_value", StandardBasicTypes.DOUBLE) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
142 .addScalar("gf_name", StandardBasicTypes.STRING) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
143 .addScalar("ms_id", StandardBasicTypes.INTEGER) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
144 .addScalar("ms_station", StandardBasicTypes.DOUBLE) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
145 .addScalar("ms_type", StandardBasicTypes.STRING); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
146 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
147 sqlQuery.setString("river", river); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
148 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
149 SedimentLoadData.Load load = null; |
8039
3a769d5fb733
Use GF_UNKNOWN constant instead of -1 to identify unknown grain fractions.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
150 int grainFractionIndex = SedimentLoadData.GF_UNKNOWN; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
151 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
152 HashMap<Integer, SedimentLoadData.Station> id2station |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
153 = new HashMap<Integer, SedimentLoadData.Station>(); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
154 |
8089
7e55790da464
Use list() instead of iterator(). Why does this not work?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8058
diff
changeset
|
155 List<Object[]> list = sqlQuery.list(); |
7e55790da464
Use list() instead of iterator(). Why does this not work?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8058
diff
changeset
|
156 |
7e55790da464
Use list() instead of iterator(). Why does this not work?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8058
diff
changeset
|
157 for (Object [] row: list) { |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
158 |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
159 // Load |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
160 Integer sl_id = (Integer)row[0]; |
8058
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8055
diff
changeset
|
161 Integer sl_kind = (Integer)row[1]; |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8055
diff
changeset
|
162 String sl_description = (String)row[2]; |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8055
diff
changeset
|
163 Timestamp ti_start_time = (Timestamp)row[3]; |
fbe3ba5a480e
Sediment load: Fetch kind of sediment load from database to tell if it is official or not.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8055
diff
changeset
|
164 Timestamp ti_stop_time = (Timestamp)row[4]; |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
165 Timestamp sq_start_time = (Timestamp)row[5]; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
166 Timestamp sq_stop_time = (Timestamp)row[6]; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
167 Integer sq_id = (Integer)row[7]; |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
168 |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
169 // Value |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
170 Double slv_value = (Double)row[8]; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
171 String gf_name = (String)row[9]; |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
172 |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
173 // Station |
8199
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
174 Integer ms_id = (Integer)row[10]; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
175 Double ms_station = (Double)row[11]; |
42ac86ec19c7
(issue1448) Add sq time intervals to sediment load data model.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8193
diff
changeset
|
176 String ms_type = (String)row[12]; |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
177 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
178 if (load == null || load.getId() != sl_id) { |
8237
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8215
diff
changeset
|
179 load = new SedimentLoadData.Load( |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8215
diff
changeset
|
180 sl_id, sl_kind, sl_description, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8215
diff
changeset
|
181 ti_start_time, ti_stop_time, sq_id, |
25c3a62863d2
(issue1448) Unify SedimentLoadData ctor again
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8215
diff
changeset
|
182 sq_start_time, sq_stop_time); |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
183 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
184 // Grain fractions only change when a new sediment load starts. |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
185 grainFractionIndex = |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
186 SedimentLoadData.grainFractionIndex(gf_name); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
187 |
8039
3a769d5fb733
Use GF_UNKNOWN constant instead of -1 to identify unknown grain fractions.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8034
diff
changeset
|
188 if (grainFractionIndex == SedimentLoadData.GF_UNKNOWN) { |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
189 log.error("Unknown grain fraction type: " + gf_name); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
190 break; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
191 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
192 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
193 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
194 SedimentLoadData.Station station = id2station.get(ms_id); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
195 if (station == null) { |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
196 int type = ms_type.equalsIgnoreCase(SUSPENDED_STRING) |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
197 ? SedimentLoadData.Station.SUSPENDED |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
198 : SedimentLoadData.Station.BED_LOAD; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
199 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
200 station = new SedimentLoadData.Station(type, ms_station); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
201 id2station.put(ms_id, station); |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
202 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
203 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
204 station.addValue( |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
205 grainFractionIndex, |
8215
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
206 new SedimentLoadData.Value(load, slv_value == null |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
207 ? Double.NaN |
204905c16ade
Fetch missing values from database and show them in diagrams.
Tom Gottfried <tom@intevation.de>
parents:
8210
diff
changeset
|
208 : slv_value)); |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
209 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
210 |
8193
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8097
diff
changeset
|
211 SedimentLoadData sld = new SedimentLoadData(id2station.values(), |
8d447516b7dd
Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents:
8097
diff
changeset
|
212 RiverFactory.getRiver(river).getKmUp()); |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
213 |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
214 return sld; |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
215 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
216 } |
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff
changeset
|
217 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |