Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 7181:805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 26 Sep 2013 21:44:53 +0200 |
parents | e0b6b6cf4708 |
children | 73d7886fa59e |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5789
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.minfo; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 import gnu.trove.TDoubleArrayList; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import java.util.Calendar; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 import java.util.Date; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import java.util.List; |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
16 import java.util.TreeMap; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 import net.sf.ehcache.Cache; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 import net.sf.ehcache.Element; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 import org.apache.log4j.Logger; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5789
diff
changeset
|
22 import org.dive4elements.river.artifacts.cache.CacheFactory; |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
23 import org.dive4elements.river.artifacts.model.Range; |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
24 import org.dive4elements.river.artifacts.model.RiverFactory; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5789
diff
changeset
|
25 import org.dive4elements.river.artifacts.model.StaticSedimentLoadCacheKey; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5789
diff
changeset
|
26 import org.dive4elements.river.backend.SessionHolder; |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
27 import org.dive4elements.river.model.MeasurementStation; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
28 import org.hibernate.SQLQuery; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
29 import org.hibernate.Session; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
30 import org.hibernate.type.StandardBasicTypes; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
32 |
5662
7e3cde8b564c
Cosmetics, docs, vimlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
33 /** Pull Sediment Loads out of db. */ |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 public class SedimentLoadFactory |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 /** Private logger to use here. */ |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 private static Logger log = Logger.getLogger(SedimentLoadFactory.class); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
39 // Cache name/keys |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 public static final String LOADS_CACHE_NAME = "sedimentloads"; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 public static final String LOAD_DATA_CACHE_NAME = "sedimentload-data"; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
43 /** Query to get description and start year of single type |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
44 * sediment_yields. */ |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 public static final String SQL_SELECT_SINGLES = |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 "SELECT DISTINCT " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 " sy.description AS description, " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 " ti.start_time AS year " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 " FROM sediment_yield sy " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 " JOIN rivers r ON sy.river_id = r.id " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 " WHERE r.name = :name " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 " AND ti.stop_time IS NULL " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 " AND syv.station BETWEEN :startKm AND :endKm"; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
57 /** Query to get description, name and time range for official |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
58 * epoch-type sediment yields. */ |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
59 public static final String SQL_SELECT_OFFEPOCHS = |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
60 "SELECT DISTINCT " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
61 " ti.start_time AS startYear, " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
62 " ti.stop_time AS end " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
63 " FROM sediment_yield sy " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
64 " JOIN rivers r ON sy.river_id = r.id " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
65 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
66 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
67 " WHERE r.name = :name " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
68 " AND ti.stop_time IS NOT NULL " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
69 " AND syv.station BETWEEN :startKm AND :endKm " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
70 " AND sy.kind = 1"; |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
71 |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
72 /** Query to get description, name and time range for epoch-type |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
73 * sediment yields. */ |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 public static final String SQL_SELECT_EPOCHS = |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 "SELECT DISTINCT " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 " sy.description AS description, " + |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
77 " ti.start_time AS startYear, " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
78 " ti.stop_time AS end, " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
79 " u.name AS unit" + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 " FROM sediment_yield sy " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 " JOIN rivers r ON sy.river_id = r.id " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
84 " JOIN units u ON u.id = sy.unit_id " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 " WHERE r.name = :name " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 " AND ti.stop_time IS NOT NULL " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 " AND syv.station BETWEEN :startKm AND :endKm"; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
89 public static final String SQL_SELECT_SINGLES_DATA_BY_ID = |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
90 "SELECT" + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
91 " sy.description AS description, " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
92 " syv.value AS load, " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
93 " syv.station AS km, " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
94 " u.name AS unit " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
95 " gf.name AS fraction " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
96 " FROM sediment_yield sy " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
97 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
98 " JOIN units u ON u.id = sy.unit_id" + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
99 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
100 " WHERE sy.id = :id" + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
101 " ORDER BY syv.station"; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
102 |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 public static final String SQL_SELECT_SINGLES_DATA = |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 "SELECT" + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 " sy.description AS description, " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 " ti.start_time AS year, " + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
107 " syv.value AS load, " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
108 " syv.station AS km, " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
109 " u.name AS unit " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 " FROM sediment_yield sy " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 " JOIN rivers r ON sy.river_id = r.id " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
113 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
115 " JOIN units u ON u.id = sy.unit_id" + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 " WHERE r.name = :name " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 " AND ti.start_time BETWEEN :begin AND :end " + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
118 " AND ti.stop_time IS NULL " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
119 " AND gf.name = :grain " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
120 " AND syv.station BETWEEN :startKm AND :endKm " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
121 " ORDER BY syv.station"; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
122 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
123 public static final String SQL_SELECT_UNKNOWN_DATA = |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
124 "SELECT" + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
125 " sy.description AS description, " + |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
126 " ti.start_time AS startYear, " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
127 " ti.stop_time AS end, " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
128 " syv.value AS load, " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
129 " syv.station AS km, " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
130 " u.name AS unit " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
131 " FROM sediment_yield sy " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
132 " JOIN rivers r ON sy.river_id = r.id " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
133 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
134 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
135 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
136 " JOIN units u ON u.id = sy.unit_id" + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
137 " WHERE r.name = :name " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
138 " AND sy.description = :descr " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
139 " AND gf.name = 'unknown' " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
140 " ORDER BY syv.station"; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
141 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
142 public static final String SQL_SELECT_UNKNOWN = |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
143 "SELECT DISTINCT " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
144 " sy.description AS description, " + |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
145 " ti.start_time AS startYear, " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
146 " ti.stop_time AS end " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
147 "FROM sediment_yield sy " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
148 " JOIN rivers r ON sy.river_id = r.id " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
149 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
150 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " + |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
151 " JOIN units u ON sy.unit_id = u.id " + |
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
152 "WHERE r.name = :river " + |
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
153 " AND gf.name = 'unknown' " + |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
154 " AND sy.kind = :type " + |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
155 " AND u.name = :unit"; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
156 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 public static final String SQL_SELECT_EPOCHS_DATA = |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
158 "SELECT" + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
159 " sy.description AS description, " + |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
160 " ti.start_time AS startYear, " + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
161 " syv.value AS load, " + |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
162 " syv.station AS km," + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
163 " ti.stop_time AS endYear, " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
164 " u.name AS unit" + |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
165 " FROM sediment_yield sy " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
166 " JOIN rivers r ON sy.river_id = r.id " + |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
167 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
168 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
169 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
170 " JOIN units u ON u.id = sy.unit_id " + |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
171 " WHERE r.name = :name " + |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
172 " AND ti.start_time BETWEEN :sbegin AND :send " + |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
173 " AND ti.stop_time BETWEEN :ebegin AND :eend " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
174 " AND gf.name = :grain " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
175 " AND syv.station BETWEEN :startKm AND :endKm " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
176 " ORDER BY syv.station"; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
177 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
178 private SedimentLoadFactory() { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
179 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
180 |
4434
60c728e557f4
Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4428
diff
changeset
|
181 /** |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
182 * @param river name of river. |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
183 * @param type |
4434
60c728e557f4
Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4428
diff
changeset
|
184 */ |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
185 public static SedimentLoad[] getLoads( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
186 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
187 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
188 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
189 double endKm |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
190 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
191 log.debug("SedimentLoadFactory.getLoads"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
192 Cache cache = CacheFactory.getCache(LOADS_CACHE_NAME); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
193 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
194 if (cache == null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
195 log.debug("Cache not configured."); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
196 return getSedimentLoadsUncached(river, type, startKm, endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
197 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
198 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
199 StaticSedimentLoadCacheKey key = |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
200 new StaticSedimentLoadCacheKey(river, startKm, endKm, 0, 0); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
201 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
202 Element element = cache.get(key); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
203 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
204 if (element != null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
205 log.debug("SedimentLoad found in cache"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
206 return (SedimentLoad[])element.getValue(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
207 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
208 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
209 SedimentLoad[] values = |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
210 getSedimentLoadsUncached(river, type, startKm, endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
211 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
212 if (values != null && key != null) { |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
213 log.debug("Store static sediment load values in cache."); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
214 element = new Element(key, values); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
215 cache.put(element); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
216 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
217 return values; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
218 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
219 |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
220 /** |
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
221 * Get a sedimentLoad filled with data from db (or cache). |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
222 * @param type "epoch", "off_epoch" or "single" |
7028 | 223 * @return A Sedimentload filled with values from db or cache. |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
224 */ |
5661
b6297a67823e
SedimentLoadFactory: Renamed getLoadwithData to getLoadWithData, update callers.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4736
diff
changeset
|
225 public static SedimentLoad getLoadWithData( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
226 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
227 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
228 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
229 double endKm, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
230 int syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
231 int eyear |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
232 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
233 log.debug("SedimentLoadFactory.getLoadWithData"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
234 Cache cache = CacheFactory.getCache(LOAD_DATA_CACHE_NAME); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
235 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
236 if (cache == null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
237 log.debug("Cache not configured."); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
238 return getSedimentLoadWithDataUncached( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
239 river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
240 type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
241 startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
242 endKm, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
243 syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
244 eyear); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
245 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
246 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
247 StaticSedimentLoadCacheKey key = |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
248 new StaticSedimentLoadCacheKey(river, startKm, endKm, syear, eyear); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
249 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
250 Element element = cache.get(key); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
251 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
252 if (element != null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
253 log.debug("SedimentLoad found in cache"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
254 return (SedimentLoad)element.getValue(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
255 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
256 |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
257 SedimentLoad values = getSedimentLoadWithDataUncached( |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
258 river, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
259 type, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
260 startKm, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
261 endKm, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
262 syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
263 eyear); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
264 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
265 if (values != null && key != null) { |
7053
3a55f49be155
Corrected debug output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7028
diff
changeset
|
266 log.debug("Store sediment loads in cache."); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
267 element = new Element(key, values); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
268 cache.put(element); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
269 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
270 return values; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
271 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
272 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
273 /** |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
274 * Get sediment loads from db. |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
275 * @param river the river |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
276 * @param type the sediment load type (year or epoch) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
277 * @return according sediment loads. |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
278 */ |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
279 public static SedimentLoad[] getSedimentLoadsUncached( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
280 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
281 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
282 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
283 double endKm |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
284 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
285 log.debug("SedimentLoadFactory.getSedimentLoadsUncached"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
286 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
287 Session session = SessionHolder.HOLDER.get(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
288 SQLQuery sqlQuery = null; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
289 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
290 if (type.equals("single")) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
291 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
292 .addScalar("description", StandardBasicTypes.STRING) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
293 .addScalar("year", StandardBasicTypes.DATE); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
294 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
295 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
296 sqlQuery.setDouble("endKm", endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
297 List<Object []> results = sqlQuery.list(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
298 SedimentLoad[] loads = new SedimentLoad[results.size()]; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
299 for (int i = 0; i < results.size(); i++) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
300 Object[] row = results.get(i); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
301 loads[i] = new SedimentLoad( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
302 (String) row[0], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
303 (Date) row[1], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
304 null, |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
305 false, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
306 ""); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
307 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
308 return loads; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
309 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
310 else if (type.equals("epoch")) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
311 sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
312 .addScalar("description", StandardBasicTypes.STRING) |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
313 .addScalar("startYear", StandardBasicTypes.DATE) |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
314 .addScalar("end", StandardBasicTypes.DATE); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
315 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
316 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
317 sqlQuery.setDouble("endKm", endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
318 List<Object []> results = sqlQuery.list(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
319 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
320 SedimentLoad[] loads = new SedimentLoad[results.size()]; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
321 for (int i = 0; i < results.size(); i++) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
322 Object[] row = results.get(i); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
323 loads[i] = new SedimentLoad( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
324 (String) row[0], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
325 (Date) row[1], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
326 (Date) row[2], |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
327 true, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
328 ""); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
329 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
330 return loads; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
331 } |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
332 else if (type.equals("off_epoch")) { |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
333 sqlQuery = session.createSQLQuery(SQL_SELECT_OFFEPOCHS) |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
334 .addScalar("startYear", StandardBasicTypes.DATE) |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
335 .addScalar("end", StandardBasicTypes.DATE); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
336 sqlQuery.setString("name", river); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
337 sqlQuery.setDouble("startKm", startKm); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
338 sqlQuery.setDouble("endKm", endKm); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
339 List<Object []> results = sqlQuery.list(); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
340 |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
341 SedimentLoad[] loads = new SedimentLoad[results.size()]; |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
342 for (int i = 0; i < results.size(); i++) { |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
343 Object[] row = results.get(i); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
344 loads[i] = new SedimentLoad( |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
345 ((Date) row[0]).toString() + (Date) row[1], |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
346 (Date) row[0], |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
347 (Date) row[1], |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
348 true, |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
349 ""); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
350 } |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
351 return loads; |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
352 } |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
353 else { |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
354 log.warn("getSedimentLoadsUncached does not understand type " + type); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
355 } |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
356 return new SedimentLoad[0]; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
357 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
358 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
359 /** |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
360 * Get a specific sediment load from db. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
361 * |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
362 * @param id the sediment yields id. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
363 * |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
364 * @return according sediment load. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
365 */ |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
366 public static SedimentLoad getSedimentLoadWithDataUncached( |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
367 String id, |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
368 String river |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
369 ) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
370 log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached / id " + id); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
371 Session session = SessionHolder.HOLDER.get(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
372 SQLQuery sqlQuery = null; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
373 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
374 // Measurement stations: all, for float-stuff, for suspended stuff. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
375 // Because they need fast sorted access, use TreeMaps. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
376 // They map the starting validity range km to the station itself. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
377 List<MeasurementStation> allStations = |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
378 RiverFactory.getRiver(river).getMeasurementStations(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
379 TreeMap<Double,MeasurementStation> floatStations = |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
380 new TreeMap<Double, MeasurementStation>(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
381 TreeMap<Double,MeasurementStation> suspStations = |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
382 new TreeMap<Double, MeasurementStation>(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
383 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
384 // From all stations, sort into the two kinds, skip undefined ones. |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
385 for (MeasurementStation measurementStation: allStations) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
386 if (measurementStation.getMeasurementType() == null || |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
387 measurementStation.getRange() == null) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
388 continue; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
389 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
390 if (measurementStation.getMeasurementType().equals("Schwebstoff")) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
391 suspStations.put( |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
392 measurementStation.getRange().getA().doubleValue(), |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
393 measurementStation); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
394 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
395 else if (measurementStation.getMeasurementType().equals("Geschiebe")) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
396 floatStations.put( |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
397 measurementStation.getRange().getA().doubleValue(), |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
398 measurementStation); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
399 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
400 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
401 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
402 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES_DATA_BY_ID) |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
403 .addScalar("description", StandardBasicTypes.STRING) |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
404 .addScalar("load", StandardBasicTypes.DOUBLE) |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
405 .addScalar("km", StandardBasicTypes.DOUBLE) |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
406 .addScalar("fraction", StandardBasicTypes.STRING) |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
407 .addScalar("unit", StandardBasicTypes.STRING); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
408 sqlQuery.setInteger("id", Integer.valueOf(id)); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
409 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
410 List<Object []> results = sqlQuery.list(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
411 SedimentLoad load = new SedimentLoad(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
412 if (results.isEmpty()) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
413 log.warn("Empty result for year calculation."); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
414 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
415 else { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
416 Object[] row = results.get(0); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
417 load = new SedimentLoad( |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
418 (String) row[0], //description |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
419 null,//(Date) row[1], //start |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
420 null, //end |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
421 false, //isEpoch |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
422 (String) row[4]); //unit |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
423 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
424 String fraction = (String) row[3]; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
425 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
426 TreeMap<Double,MeasurementStation> relevantStations = |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
427 fraction.equals("suspended_sediment") |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
428 ? suspStations |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
429 : floatStations; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
430 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
431 for (int i = 0; i < results.size(); i++) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
432 row = results.get(i); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
433 double km = (Double) row[2]; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
434 Range range = findMeasurementStationRange(relevantStations, km); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
435 if (range == null) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
436 log.warn("No measurement station for " + fraction + " km " + km); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
437 continue; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
438 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
439 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
440 double v = -1; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
441 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
442 if (row[1] != null) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
443 v = ((Double)row[1]).doubleValue(); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
444 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
445 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
446 setLoadFraction(load, km, v, range, fraction); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
447 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
448 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
449 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
450 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
451 return load; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
452 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
453 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
454 /** |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
455 * Get sediment loads from db. |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
456 * |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
457 * @param river the river |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
458 * @param type the sediment load type (year, epoch or off_epoch) |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
459 * |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
460 * @return according sediment loads. |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
461 */ |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
462 public static SedimentLoad getSedimentLoadWithDataUncached( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
463 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
464 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
465 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
466 double endKm, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
467 int syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
468 int eyear |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
469 ) { |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
470 log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached"); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
471 Session session = SessionHolder.HOLDER.get(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
472 SQLQuery sqlQuery = null; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
473 |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
474 // Measurement stations: all, for float-stuff, for suspended stuff. |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
475 // Because they need fast sorted access, use TreeMaps. |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
476 // They map the starting validity range km to the station itself. |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
477 List<MeasurementStation> allStations = |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
478 RiverFactory.getRiver(river).getMeasurementStations(); |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
479 TreeMap<Double,MeasurementStation> floatStations = |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
480 new TreeMap<Double, MeasurementStation>(); |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
481 TreeMap<Double,MeasurementStation> suspStations = |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
482 new TreeMap<Double, MeasurementStation>(); |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
483 |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
484 // From all stations, sort into the two kinds, skip undefined ones. |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
485 for (MeasurementStation measurementStation: allStations) { |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
486 if (measurementStation.getMeasurementType() == null || |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
487 measurementStation.getRange() == null) { |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
488 continue; |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
489 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
490 if (measurementStation.getMeasurementType().equals("Schwebstoff")) { |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
491 suspStations.put( |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
492 measurementStation.getRange().getA().doubleValue(), |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
493 measurementStation); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
494 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
495 else if (measurementStation.getMeasurementType().equals("Geschiebe")) { |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
496 floatStations.put( |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
497 measurementStation.getRange().getA().doubleValue(), |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
498 measurementStation); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
499 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
500 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
501 |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
502 // Construct date constraint. |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
503 Calendar start = Calendar.getInstance(); |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
504 start.set(syear - 1, 11, 31); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
505 Calendar end = Calendar.getInstance(); |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
506 end.set(syear, 11, 30); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
507 |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
508 if (type.equals("year") || type.equals("epoch")) { |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
509 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES_DATA) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
510 .addScalar("description", StandardBasicTypes.STRING) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
511 .addScalar("year", StandardBasicTypes.DATE) |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
512 .addScalar("load", StandardBasicTypes.DOUBLE) |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
513 .addScalar("km", StandardBasicTypes.DOUBLE) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
514 .addScalar("unit", StandardBasicTypes.STRING); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
515 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
516 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
517 sqlQuery.setDouble("endKm", endKm); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
518 sqlQuery.setDate("begin", start.getTime()); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
519 sqlQuery.setDate("end", end.getTime()); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
520 sqlQuery.setString("grain", "total"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
521 List<Object []> results = sqlQuery.list(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
522 SedimentLoad load = new SedimentLoad(); |
6785
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
523 if (results.isEmpty()) { |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
524 log.warn("Empty result for year calculation."); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
525 } |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
526 else { |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
527 Object[] row = results.get(0); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
528 load = new SedimentLoad( |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
529 (String) row[0], //description |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
530 (Date) row[1], //start |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
531 null, //end |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
532 false, //isEpoch |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
533 (String) row[4]); //unit |
6785
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
534 } |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
535 load = getValues("coarse", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
536 load = getValues("fine_middle", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
537 load = getValues("sand", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
538 load = getValues("suspended_sediment", sqlQuery, load, suspStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
539 load = getValues("susp_sand_bed", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
540 load = getValues("susp_sand", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
541 |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
542 return load; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
543 } |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
544 else if (type.equals("off_epoch")) { |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
545 // Set calendars to fetch the epochs by their start and end |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
546 // dates. |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
547 Calendar toStart = Calendar.getInstance(); |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
548 toStart.set(eyear - 1, 11, 31); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
549 Calendar toEnd = Calendar.getInstance(); |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
550 toEnd.set(eyear+1, 00, 01); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
551 // Set query parameters. |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
552 sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS_DATA) |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
553 .addScalar("description", StandardBasicTypes.STRING) |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
554 .addScalar("startYear", StandardBasicTypes.DATE) |
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
555 .addScalar("load", StandardBasicTypes.DOUBLE) |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
556 .addScalar("km", StandardBasicTypes.DOUBLE) |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
557 .addScalar("endYear", StandardBasicTypes.DATE) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
558 .addScalar("unit", StandardBasicTypes.STRING); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
559 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
560 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
561 sqlQuery.setDouble("endKm", endKm); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
562 sqlQuery.setDate("sbegin", start.getTime()); |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
563 sqlQuery.setDate("send", end.getTime()); |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
564 sqlQuery.setDate("ebegin", toStart.getTime()); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
565 sqlQuery.setDate("eend", toEnd.getTime()); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
566 sqlQuery.setString("grain", "total"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
567 |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
568 List<Object[]> results = null; |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
569 results = sqlQuery.list(); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
570 |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
571 SedimentLoad load = null; |
6737
1960d55bafb1
issue1393: Avoid NPE for off-epoch when actually no off-epoch data available.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6725
diff
changeset
|
572 if (results.isEmpty()) { |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
573 log.warn("No total results for off-epoch"); |
6737
1960d55bafb1
issue1393: Avoid NPE for off-epoch when actually no off-epoch data available.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6725
diff
changeset
|
574 } |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
575 else { |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
576 Object[] row = results.get(0); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
577 load = new SedimentLoad( |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
578 (String) row[0], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
579 (Date) row[1], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
580 (Date) row[4], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
581 true, |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
582 (String)row[5]); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
583 TDoubleArrayList kms = new TDoubleArrayList(); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
584 for (int i = 0; i < results.size(); i++) { |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
585 row = results.get(i); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
586 kms.add((Double)row[3]); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
587 load.setLoadTotal((Double)row[3], (Double)row[2]); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
588 } |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
589 } |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
590 load = getValues("coarse", sqlQuery, load, floatStations); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
591 load = getValues("fine_middle", sqlQuery, load, floatStations); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
592 load = getValues("sand", sqlQuery, load, floatStations); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
593 load = getValues("suspended_sediment", sqlQuery, load, suspStations); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
594 load = getValues("susp_sand_bed", sqlQuery, load, floatStations); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
595 load = getValues("susp_sand", sqlQuery, load, floatStations); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
596 return load; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
597 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
598 return new SedimentLoad(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
599 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
600 |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
601 protected static Range findMeasurementStationRange( |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
602 TreeMap<Double, MeasurementStation> stations, |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
603 double km |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
604 ) { |
6984
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
605 MeasurementStation station = stations.get(km); |
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
606 if (station == null) { |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
607 return null; |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
608 } |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
609 |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
610 double endKm; |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
611 |
6984
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
612 if (stations.ceilingEntry(km + 0.1d) != null) { |
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
613 MeasurementStation nextStation = stations.ceilingEntry(km + 0.1d).getValue(); |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
614 endKm = nextStation.getRange().getA().doubleValue(); |
6966
328854c0467f
SedimentLoadFactory: Further code simplification.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6965
diff
changeset
|
615 } |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
616 else { |
6966
328854c0467f
SedimentLoadFactory: Further code simplification.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6965
diff
changeset
|
617 // TODO end-of-river instead of B. |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
618 endKm = station.getRange().getB().doubleValue(); |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
619 } |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
620 |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
621 return new Range( |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
622 station.getRange().getA().doubleValue(), |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
623 endKm); |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
624 } |
5662
7e3cde8b564c
Cosmetics, docs, vimlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
625 |
5789 | 626 /** |
627 * Run query with grain parameter set to fraction, feed result into | |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
628 * load. Create load if null. |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
629 * |
5789 | 630 * @param fraction value to set 'grain' parameter in query to. |
631 * @param query query in which to set 'grain' parameter and run. | |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
632 * @param load[out] SedimentLoad which to populate with values. if null |
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
633 * and values are found, return a new load. |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
634 * @return param load or new load if null. |
5789 | 635 */ |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
636 protected static SedimentLoad getValues ( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
637 String fraction, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
638 SQLQuery query, |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
639 SedimentLoad load, |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
640 TreeMap<Double, MeasurementStation> stations |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
641 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
642 query.setString("grain", fraction); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
643 List<Object[]> results = query.list(); |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
644 |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
645 // We have the first results for this query, create new load. |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
646 if (!results.isEmpty() && load == null) { |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
647 Object[] row = results.get(0); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
648 load = new SedimentLoad( |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
649 (String) row[0], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
650 (Date) row[1], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
651 (Date) row[4], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
652 true, |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
653 (String)row[5]); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
654 } |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
655 |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
656 for (int i = 0; i < results.size(); i++) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
657 Object[] row = results.get(i); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
658 double km = (Double)row[3]; |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
659 Range range = findMeasurementStationRange(stations, km); |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
660 if (range == null) { |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
661 log.warn("No measurement station for " + fraction + " km " + km); |
6544
b24dc0320b75
issue1386: Prevent null-ranges to be set when station of sediment measurement
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6477
diff
changeset
|
662 continue; |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
663 } |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
664 double v = -1; |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
665 |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
666 if (row[2] != null) { |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
667 v = ((Double)row[2]).doubleValue(); |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
668 } |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
669 |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
670 setLoadFraction(load, km, v, range, fraction); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
671 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
672 |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
673 if (results.isEmpty()) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
674 log.warn("No " + fraction + " values found."); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
675 } |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
676 |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
677 return load; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
678 } |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
679 |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
680 |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
681 /** Set a fraction value of load to given km, value and range. */ |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
682 private static void setLoadFraction( |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
683 SedimentLoad load, double km, double v, Range range, String fraction) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
684 if (fraction.equals("coarse")) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
685 load.setCoarse(km, v, range); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
686 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
687 else if (fraction.equals("sand")) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
688 load.setSand(km, v, range); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
689 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
690 else if (fraction.equals("fine_middle")) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
691 load.setFineMiddle(km, v, range); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
692 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
693 else if (fraction.equals("suspended_sediment")) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
694 load.setSuspSediment(km, v, range); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
695 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
696 else if (fraction.equals("susp_sand")) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
697 load.setSuspSand(km, v, range); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
698 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
699 else if (fraction.equals("susp_sand_bed")) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
700 load.setSuspSandBed(km, v, range); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
701 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
702 else { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
703 log.error("Unknown fraction type " + fraction); |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
704 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
705 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
706 |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
707 public static SedimentLoad getLoadUnknown( |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
708 String river, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
709 String description |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
710 ) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
711 log.debug("SedimentLoadFactory.getLoadWithData"); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
712 Cache cache = CacheFactory.getCache(LOAD_DATA_CACHE_NAME); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
713 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
714 if (cache == null) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
715 log.debug("Cache not configured."); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
716 return getSedimentLoadUnknownUncached(river, description); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
717 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
718 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
719 StaticSedimentLoadCacheKey key = |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
720 new StaticSedimentLoadCacheKey(river, 0d, 0d, 0, 0); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
721 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
722 Element element = cache.get(key); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
723 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
724 if (element != null) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
725 log.debug("SedimentLoad found in cache"); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
726 return (SedimentLoad)element.getValue(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
727 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
728 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
729 SedimentLoad values = getSedimentLoadUnknownUncached(river, description); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
730 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
731 if (values != null && key != null) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
732 log.debug("Store static bed height values in cache."); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
733 element = new Element(key, values); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
734 cache.put(element); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
735 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
736 return values; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
737 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
738 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
739 /** |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
740 * Get sediment loads with fraction 'unknown' from db. |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
741 * @param river the river |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
742 * @param type the sediment load type (year or epoch) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
743 * @return according sediment loads. |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
744 */ |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
745 public static SedimentLoad getSedimentLoadUnknownUncached( |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
746 String river, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
747 String description |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
748 ) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
749 log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached"); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
750 Session session = SessionHolder.HOLDER.get(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
751 SQLQuery sqlQuery = null; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
752 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
753 sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN_DATA) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
754 .addScalar("description", StandardBasicTypes.STRING) |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
755 .addScalar("startYear", StandardBasicTypes.DATE) |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
756 .addScalar("end", StandardBasicTypes.DATE) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
757 .addScalar("load", StandardBasicTypes.DOUBLE) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
758 .addScalar("km", StandardBasicTypes.DOUBLE) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
759 .addScalar("unit", StandardBasicTypes.STRING); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
760 sqlQuery.setString("name", river); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
761 sqlQuery.setString("descr", description); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
762 List<Object []> results = sqlQuery.list(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
763 SedimentLoad load = new SedimentLoad(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
764 if (results.isEmpty()) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
765 return new SedimentLoad(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
766 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
767 Object[] row = results.get(0); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
768 load = new SedimentLoad( |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
769 (String) row[0], |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
770 (Date) row[1], |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
771 (Date) row[2], |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
772 false, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
773 (String)row[5]); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
774 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
775 for (int i = 0; i < results.size(); i++) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
776 row = results.get(i); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
777 SedimentLoadFraction fraction = new SedimentLoadFraction(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
778 fraction.setUnknown((Double)row[3]); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
779 load.addKm((Double)row[4], fraction); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
780 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
781 return load; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
782 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
783 |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
784 /** |
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
785 * Return sediment loads with 'unknown' fraction type. |
6785
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
786 * @param river Name of the river |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
787 * @param unit Restrict result set to those of given unit. |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
788 * @param type Type like year, epoch, off_epoch |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
789 */ |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
790 public static SedimentLoad[] getSedimentLoadUnknown( |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
791 String river, |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
792 String unit, |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
793 String type) { |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
794 Session session = SessionHolder.HOLDER.get(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
795 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN) |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
796 .addScalar("description", StandardBasicTypes.STRING) |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
797 .addScalar("startYear", StandardBasicTypes.DATE) |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
798 .addScalar("end", StandardBasicTypes.DATE); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
799 sqlQuery.setString("river", river); |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
800 sqlQuery.setString("unit", unit); |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
801 if (type.equals("off_epoch")) { |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
802 sqlQuery.setInteger("type", 1); |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
803 } |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
804 else { |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
805 sqlQuery.setInteger("type", 0); |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
806 } |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
807 List<Object[]> results = sqlQuery.list(); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
808 SedimentLoad[] loads = new SedimentLoad[results.size()]; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
809 int counter = 0; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
810 for (Object[] row: results) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
811 loads[counter] = new SedimentLoad( |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
812 (String)row[0], (Date)row[1], (Date)row[2], false, ""); |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
813 counter++; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
814 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
815 return loads; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
816 } |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
817 } |
5662
7e3cde8b564c
Cosmetics, docs, vimlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
818 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |