Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 8146:ce35bdf3d750
Let the facet know the period of it's data.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 27 Aug 2014 15:09:45 +0200 |
parents | 5f28aa1be795 |
children |
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 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
44 * sediment_load_lss. */ |
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 " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
49 " FROM sediment_load_ls sy " + |
4296
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 " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
51 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
4296
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 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
57 /** Query to get fraction name of single sediment_load_ls. */ |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
58 public static final String SQL_SELECT_SINGLE_TIMES_BY_ID = |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
59 "SELECT DISTINCT " + |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
60 " ti.start_time AS starttime, " + |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
61 " ti.stop_time AS stoptime " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
62 " FROM sediment_load_ls sy " + |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
63 " JOIN time_intervals ti ON ti.id = sy.time_interval_id " + |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
64 " WHERE sy.id = :id "; |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
65 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
66 /** Query to get fraction name of single sediment_load_ls. */ |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
67 public static final String SQL_SELECT_SINGLE_FRACTION_BY_ID = |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
68 "SELECT DISTINCT " + |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
69 " gf.name AS fraction " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
70 " FROM sediment_load_ls sy " + |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
71 " JOIN grain_fraction gf ON gf.id = grain_fraction_id " + |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
72 " WHERE sy.id = :id "; |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
73 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
74 /** Query to get unit name of single sediment_load_ls. */ |
7498
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
75 public static final String SQL_SELECT_SINGLE_UNIT_BY_ID = |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
76 "SELECT DISTINCT " + |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
77 " u.name AS unit " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
78 " FROM sediment_load_ls sy " + |
7498
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
79 " JOIN units u ON u.id = unit_id " + |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
80 " WHERE sy.id = :id "; |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
81 |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
82 /** Query to get description of single sediment_load_ls. */ |
7185
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
83 public static final String SQL_SELECT_SINGLE_BY_ID = |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
84 "SELECT DISTINCT " + |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
85 " sy.description AS description " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
86 " FROM sediment_load_ls sy " + |
7185
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
87 " WHERE sy.id = :id "; |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
88 |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
89 /** 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
|
90 * epoch-type sediment yields. */ |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
91 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
|
92 "SELECT DISTINCT " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
93 " ti.start_time AS startYear, " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
94 " ti.stop_time AS end " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
95 " FROM sediment_load_ls sy " + |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
96 " JOIN rivers r ON sy.river_id = r.id " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
97 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
98 " 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
|
99 " WHERE r.name = :name " + |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
100 " 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
|
101 " 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
|
102 " AND sy.kind = 1"; |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
103 |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
104 /** 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
|
105 * sediment yields. */ |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 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
|
107 "SELECT DISTINCT " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 " sy.description AS description, " + |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
109 " 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
|
110 " 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
|
111 " u.name AS unit" + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
112 " FROM sediment_load_ls sy " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
113 " JOIN rivers r ON sy.river_id = r.id " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
114 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 " 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
|
116 " 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
|
117 " WHERE r.name = :name " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 " AND ti.stop_time IS NOT NULL " + |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
119 " AND sy.kind = 0" + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
120 " 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
|
121 |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
122 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
|
123 "SELECT" + |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
124 " 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
|
125 " 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
|
126 " syv.station AS km, " + |
7184
73d7886fa59e
SedimentLoadFactory: Fix query, added comment about correctness of
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7181
diff
changeset
|
127 " u.name AS unit, " + |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
128 " gf.name AS fraction " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
129 " FROM sediment_load_ls sy " + |
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
130 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
131 " 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
|
132 " 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
|
133 " 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
|
134 " 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
|
135 |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
136 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
|
137 "SELECT" + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
138 " sy.description AS description, " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
139 " ti.start_time AS year, " + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
140 " 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
|
141 " 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
|
142 " u.name AS unit " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
143 " FROM sediment_load_ls sy " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 " 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
|
145 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
146 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 " 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
|
148 " 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
|
149 " WHERE r.name = :name " + |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
150 " 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
|
151 " 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
|
152 " 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
|
153 " 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
|
154 " 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
|
155 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
156 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
|
157 "SELECT" + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
158 " sy.description AS description, " + |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
159 " 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
|
160 " 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
|
161 " 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
|
162 " 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
|
163 " u.name AS unit " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
164 " FROM sediment_load_ls sy " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
165 " 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
|
166 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
167 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
168 " 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
|
169 " 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
|
170 " 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
|
171 " 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
|
172 " AND gf.name = 'unknown' " + |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
173 " AND sy.kind = :type" + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
174 " 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
|
175 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
176 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
|
177 "SELECT DISTINCT " + |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
178 " sy.description AS description, " + |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
179 " 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
|
180 " ti.stop_time AS end " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
181 "FROM sediment_load_ls sy " + |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
182 " 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
|
183 " 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
|
184 " 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
|
185 " 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
|
186 "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
|
187 " AND gf.name = 'unknown' " + |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
188 " 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
|
189 " AND u.name = :unit"; |
4296
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 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
|
192 "SELECT" + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
193 " sy.description AS description, " + |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
194 " ti.start_time AS startYear, " + |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
195 " syv.value AS load, " + |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
196 " 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
|
197 " 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
|
198 " u.name AS unit" + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
199 " FROM sediment_load_ls sy " + |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
200 " 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
|
201 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
8072
5f28aa1be795
SCHEMA CHANGE: rename database tables from yield to load_ls according to respective classes.
Tom Gottfried <tom@intevation.de>
parents:
8033
diff
changeset
|
202 " JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " + |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
203 " 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
|
204 " 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
|
205 " WHERE r.name = :name " + |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
206 " 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
|
207 " 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
|
208 " 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
|
209 " 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
|
210 " ORDER BY syv.station"; |
4296
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 private SedimentLoadFactory() { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
213 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
214 |
4434
60c728e557f4
Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4428
diff
changeset
|
215 /** |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
216 * @param river name of river. |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
217 * @param type |
4434
60c728e557f4
Backed out changeset e8a4d2fd25cc
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4428
diff
changeset
|
218 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
219 public static SedimentLoadLSData[] getLoads( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
220 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
221 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
222 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
223 double endKm |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
224 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
225 log.debug("SedimentLoadFactory.getLoads"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
226 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
|
227 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
228 if (cache == null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
229 log.debug("Cache not configured."); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
230 return getSedimentLoadsUncached(river, type, startKm, endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
231 } |
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 StaticSedimentLoadCacheKey key = |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
234 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
|
235 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
236 Element element = cache.get(key); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
237 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
238 if (element != null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
239 log.debug("SedimentLoad found in cache"); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
240 return (SedimentLoadLSData[])element.getValue(); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
241 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
242 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
243 SedimentLoadLSData[] values = |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
244 getSedimentLoadsUncached(river, type, startKm, endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
245 |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8024
diff
changeset
|
246 if (values != null) { |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
247 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
|
248 element = new Element(key, values); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
249 cache.put(element); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
250 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
251 return values; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
252 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
253 |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
254 /** |
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
255 * Get a sedimentLoad filled with data from db (or cache). |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
256 * @param type "epoch", "off_epoch" or "single" |
7028 | 257 * @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
|
258 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
259 public static SedimentLoadLSData getLoadWithData( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
260 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
261 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
262 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
263 double endKm, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
264 int syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
265 int eyear |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
266 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
267 log.debug("SedimentLoadFactory.getLoadWithData"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
268 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
|
269 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
270 if (cache == null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
271 log.debug("Cache not configured."); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
272 return getSedimentLoadWithDataUncached( |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
273 river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
274 type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
275 startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
276 endKm, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
277 syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
278 eyear); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
279 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
280 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
281 StaticSedimentLoadCacheKey key = |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
282 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
|
283 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
284 Element element = cache.get(key); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
285 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
286 if (element != null) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
287 log.debug("SedimentLoad found in cache"); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
288 return (SedimentLoadLSData)element.getValue(); |
4296
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 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
291 SedimentLoadLSData values = getSedimentLoadWithDataUncached( |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
292 river, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
293 type, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
294 startKm, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
295 endKm, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
296 syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
297 eyear); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
298 |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8024
diff
changeset
|
299 if (values != null) { |
7053
3a55f49be155
Corrected debug output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7028
diff
changeset
|
300 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
|
301 element = new Element(key, values); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
302 cache.put(element); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
303 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
304 return values; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
305 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
306 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
307 /** |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
308 * Get sediment yields time definition. |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
309 * @param id the sediment yield by id. |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
310 * @return sediment yields fraction name. |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
311 */ |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
312 public static Date[] getSedimentYieldTimes(int id) { |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
313 log.debug("SedimentLoadFactory.getSedimentYieldTimes"); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
314 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
315 Session session = SessionHolder.HOLDER.get(); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
316 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_TIMES_BY_ID) |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
317 .addScalar("starttime", StandardBasicTypes.DATE) |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
318 .addScalar("stoptime", StandardBasicTypes.DATE); |
8033
5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
8024
diff
changeset
|
319 sqlQuery.setInteger("id", id); |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
320 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
321 List<Object[]> results = sqlQuery.list(); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
322 Object[] row = results.get(0); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
323 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
324 return new Date[] {(Date)row[0], (Date) row[1]}; |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
325 } |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
326 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
327 /** |
7498
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
328 * Get sediment load unit name. |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
329 * @param id the sediment yield by id. |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
330 * @return sediment yields unit name. |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
331 */ |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
332 public static String getSedimentYieldUnitName(int id) { |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
333 log.debug("SedimentLoadFactory.getSedimentYieldUnitName"); |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
334 |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
335 Session session = SessionHolder.HOLDER.get(); |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
336 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_UNIT_BY_ID) |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
337 .addScalar("unit", StandardBasicTypes.STRING); |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
338 sqlQuery.setDouble("id", id); |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
339 |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
340 List<Object> results = sqlQuery.list(); |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
341 |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
342 return (String) results.get(0); |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
343 } |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
344 |
6bfa19119040
issue1658: Have SedimentLoadFactory deliver unit name for given id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7430
diff
changeset
|
345 /** |
7305
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
346 * Get sediment load fraction name. |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
347 * @param id the sediment yield by id. |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
348 * @return sediment yields fraction name. |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
349 */ |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
350 public static String getSedimentYieldFractionName(int id) { |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
351 log.debug("SedimentLoadFactory.getSedimentYieldFractionName"); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
352 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
353 Session session = SessionHolder.HOLDER.get(); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
354 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_FRACTION_BY_ID) |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
355 .addScalar("fraction", StandardBasicTypes.STRING); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
356 sqlQuery.setDouble("id", id); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
357 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
358 List<Object> results = sqlQuery.list(); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
359 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
360 return (String) results.get(0); |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
361 } |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
362 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
363 |
2e4ffd35cafa
issue1345: Prepare SedimentLoadFactory to deliver fraction name and time ranges.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7304
diff
changeset
|
364 /** |
7185
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
365 * Get sediment load description. |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
366 * @param id the sediment yield by id. |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
367 * @return sediment yields description |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
368 */ |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
369 public static String getSedimentYieldDescription(int id) { |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
370 log.debug("SedimentLoadFactory.getSedimentYieldDescription"); |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
371 |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
372 Session session = SessionHolder.HOLDER.get(); |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
373 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_BY_ID) |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
374 .addScalar("description", StandardBasicTypes.STRING); |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
375 sqlQuery.setDouble("id", id); |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
376 |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
377 List<Object> results = sqlQuery.list(); |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
378 |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
379 return (String) results.get(0); |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
380 } |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
381 |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
382 |
963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7184
diff
changeset
|
383 /** |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
384 * Get sediment loads from db. |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
385 * @param river the river |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
386 * @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
|
387 * @return according sediment loads. |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
388 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
389 public static SedimentLoadLSData[] getSedimentLoadsUncached( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
390 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
391 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
392 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
393 double endKm |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
394 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
395 log.debug("SedimentLoadFactory.getSedimentLoadsUncached"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
396 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
397 Session session = SessionHolder.HOLDER.get(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
398 SQLQuery sqlQuery = null; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
399 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
400 if (type.equals("single")) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
401 sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
402 .addScalar("description", StandardBasicTypes.STRING) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
403 .addScalar("year", StandardBasicTypes.DATE); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
404 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
405 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
406 sqlQuery.setDouble("endKm", endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
407 List<Object []> results = sqlQuery.list(); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
408 SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
409 for (int i = 0, R = results.size(); i < R; i++) { |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
410 Object[] row = results.get(i); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
411 loads[i] = new SedimentLoadLSData( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
412 (String) row[0], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
413 (Date) row[1], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
414 null, |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
415 false, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
416 ""); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
417 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
418 return loads; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
419 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
420 else if (type.equals("epoch")) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
421 sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
422 .addScalar("description", StandardBasicTypes.STRING) |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
423 .addScalar("startYear", StandardBasicTypes.DATE) |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
424 .addScalar("end", StandardBasicTypes.DATE); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
425 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
426 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
427 sqlQuery.setDouble("endKm", endKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
428 List<Object []> results = sqlQuery.list(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
429 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
430 SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
431 for (int i = 0, R = results.size(); i < R; i++) { |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
432 Object[] row = results.get(i); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
433 loads[i] = new SedimentLoadLSData( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
434 (String) row[0], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
435 (Date) row[1], |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
436 (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
|
437 true, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
438 ""); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
439 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
440 return loads; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
441 } |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
442 else if (type.equals("off_epoch")) { |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
443 sqlQuery = session.createSQLQuery(SQL_SELECT_OFFEPOCHS) |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
444 .addScalar("startYear", StandardBasicTypes.DATE) |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
445 .addScalar("end", StandardBasicTypes.DATE); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
446 sqlQuery.setString("name", river); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
447 sqlQuery.setDouble("startKm", startKm); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
448 sqlQuery.setDouble("endKm", endKm); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
449 List<Object []> results = sqlQuery.list(); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
450 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
451 SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
452 for (int i = 0, R = results.size(); i < R; i++) { |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
453 Object[] row = results.get(i); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
454 loads[i] = new SedimentLoadLSData( |
6725
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
455 ((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
|
456 (Date) row[0], |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
457 (Date) row[1], |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
458 true, |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
459 ""); |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
460 } |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
461 return loads; |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
462 } |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
463 else { |
7ea933f9c6ea
issu1393/SedimentLoadFactory: Handle off_epoch type queries.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6665
diff
changeset
|
464 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
|
465 } |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
466 return new SedimentLoadLSData[0]; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
467 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
468 |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
469 /** |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
470 * 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
|
471 * |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
472 * @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
|
473 * |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
474 * @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
|
475 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
476 public static SedimentLoadLSData getSedimentLoadWithDataUncached( |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
477 String id, |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
478 String river |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
479 ) { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
480 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
|
481 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
|
482 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
|
483 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
484 // 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
|
485 // 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
|
486 // 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
|
487 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
|
488 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
|
489 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
|
490 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
|
491 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
|
492 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
|
493 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
494 // 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
|
495 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
|
496 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
|
497 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
|
498 continue; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
499 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
500 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
|
501 suspStations.put( |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
502 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
|
503 measurementStation); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
504 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
505 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
|
506 floatStations.put( |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
507 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
|
508 measurementStation); |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
509 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
510 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
511 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
512 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
|
513 .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
|
514 .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
|
515 .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
|
516 .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
|
517 .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
|
518 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
|
519 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
520 List<Object []> results = sqlQuery.list(); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
521 SedimentLoadLSData load = new SedimentLoadLSData(); |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
522 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
|
523 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
|
524 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
525 else { |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
526 Object[] row = results.get(0); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
527 load = new SedimentLoadLSData( |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
528 (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
|
529 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
|
530 null, //end |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
531 false, //isEpoch |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
532 (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
|
533 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
534 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
|
535 |
7248
1dff8e71c4d6
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7185
diff
changeset
|
536 TreeMap<Double,MeasurementStation> relevantStations = |
7184
73d7886fa59e
SedimentLoadFactory: Fix query, added comment about correctness of
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7181
diff
changeset
|
537 fraction.equals("suspended_sediment") /* || TODO clarify: fraction.equals("susp_sand") */ |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
538 ? suspStations |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
539 : floatStations; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
540 |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
541 for (int i = 0, R = results.size(); i < R; i++) { |
7181
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
542 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
|
543 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
|
544 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
|
545 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
|
546 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
|
547 continue; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
548 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
549 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
550 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
|
551 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
552 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
|
553 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
|
554 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
555 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
556 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
|
557 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
558 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
559 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
560 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
561 return load; |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
562 } |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
563 |
805021c04861
issue1435: Add method to SedimentLoadFactory to fetch a SedimentLoad by id.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7180
diff
changeset
|
564 /** |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
565 * 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
|
566 * |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
567 * @param river the river |
6740
68c7b5811c4f
Cosmetics, docs, in range of issue1393.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6737
diff
changeset
|
568 * @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
|
569 * |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
570 * @return according sediment loads. |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
571 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
572 public static SedimentLoadLSData getSedimentLoadWithDataUncached( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
573 String river, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
574 String type, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
575 double startKm, |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
576 double endKm, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
577 int syear, |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
578 int eyear |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
579 ) { |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
580 log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached"); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
581 Session session = SessionHolder.HOLDER.get(); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
582 SQLQuery sqlQuery = null; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
583 |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
584 // Measurement stations: all, for float-stuff, for suspended stuff. |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
585 // Because they need fast sorted access, use TreeMaps. |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
586 // They map the starting validity range km to the station itself. |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
587 List<MeasurementStation> allStations = |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
588 RiverFactory.getRiver(river).getMeasurementStations(); |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
589 TreeMap<Double,MeasurementStation> floatStations = |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
590 new TreeMap<Double, MeasurementStation>(); |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
591 TreeMap<Double,MeasurementStation> suspStations = |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
592 new TreeMap<Double, MeasurementStation>(); |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
593 |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
594 // 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
|
595 for (MeasurementStation measurementStation: allStations) { |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
596 if (measurementStation.getMeasurementType() == null || |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
597 measurementStation.getRange() == null) { |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
598 continue; |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
599 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
600 if (measurementStation.getMeasurementType().equals("Schwebstoff")) { |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
601 suspStations.put( |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
602 measurementStation.getRange().getA().doubleValue(), |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
603 measurementStation); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
604 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
605 else if (measurementStation.getMeasurementType().equals("Geschiebe")) { |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
606 floatStations.put( |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
607 measurementStation.getRange().getA().doubleValue(), |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
608 measurementStation); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
609 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
610 } |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
611 |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
612 // Construct date constraint. |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
613 Calendar start = Calendar.getInstance(); |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
614 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
|
615 Calendar end = Calendar.getInstance(); |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
616 end.set(syear, 11, 30); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
617 |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
618 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
|
619 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
|
620 .addScalar("description", StandardBasicTypes.STRING) |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
621 .addScalar("year", StandardBasicTypes.DATE) |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
622 .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
|
623 .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
|
624 .addScalar("unit", StandardBasicTypes.STRING); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
625 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
626 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
627 sqlQuery.setDouble("endKm", endKm); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
628 sqlQuery.setDate("begin", start.getTime()); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
629 sqlQuery.setDate("end", end.getTime()); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
630 sqlQuery.setString("grain", "total"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
631 List<Object []> results = sqlQuery.list(); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
632 SedimentLoadLSData load = new SedimentLoadLSData(); |
6785
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
633 if (results.isEmpty()) { |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
634 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
|
635 } |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
636 else { |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
637 Object[] row = results.get(0); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
638 load = new SedimentLoadLSData( |
6948
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
639 (String) row[0], //description |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
640 (Date) row[1], //start |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
641 null, //end |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
642 false, //isEpoch |
d4108d6c4000
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6786
diff
changeset
|
643 (String) row[4]); //unit |
6785
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
644 } |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
645 load = getValues("coarse", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
646 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
|
647 load = getValues("sand", sqlQuery, load, floatStations); |
6da574f78d60
SedimentLoadFactory: Survive not completely defined sediment loads.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6755
diff
changeset
|
648 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
|
649 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
|
650 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
|
651 |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
652 return load; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
653 } |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
654 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
|
655 // 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
|
656 // dates. |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
657 Calendar toStart = Calendar.getInstance(); |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
658 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
|
659 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
|
660 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
|
661 // Set query parameters. |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
662 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
|
663 .addScalar("description", StandardBasicTypes.STRING) |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
664 .addScalar("startYear", StandardBasicTypes.DATE) |
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
665 .addScalar("load", StandardBasicTypes.DOUBLE) |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
666 .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
|
667 .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
|
668 .addScalar("unit", StandardBasicTypes.STRING); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
669 sqlQuery.setString("name", river); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
670 sqlQuery.setDouble("startKm", startKm); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
671 sqlQuery.setDouble("endKm", endKm); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
672 sqlQuery.setDate("sbegin", start.getTime()); |
4517
a5e4fae31089
Fixed SQL statements and parameters.
Raimund Renkert <rrenkert@intevation.de>
parents:
4434
diff
changeset
|
673 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
|
674 sqlQuery.setDate("ebegin", toStart.getTime()); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
675 sqlQuery.setDate("eend", toEnd.getTime()); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
676 sqlQuery.setString("grain", "total"); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
677 |
4546
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
678 List<Object[]> results = null; |
af1938d4e957
New field in sediment load object and calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4517
diff
changeset
|
679 results = sqlQuery.list(); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
680 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
681 SedimentLoadLSData 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
|
682 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
|
683 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
|
684 } |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
685 else { |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
686 Object[] row = results.get(0); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
687 load = new SedimentLoadLSData( |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
688 (String) row[0], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
689 (Date) row[1], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
690 (Date) row[4], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
691 true, |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
692 (String)row[5]); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
693 TDoubleArrayList kms = new TDoubleArrayList(); |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
694 for (int i = 0, R = results.size(); i < R; i++) { |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
695 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
|
696 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
|
697 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
|
698 } |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
699 } |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 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
|
706 return load; |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
707 } |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
708 return new SedimentLoadLSData(); |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
709 } |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
710 |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
711 protected static Range findMeasurementStationRange( |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
712 TreeMap<Double, MeasurementStation> stations, |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
713 double km |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
714 ) { |
6984
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
715 MeasurementStation station = stations.get(km); |
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
716 if (station == null) { |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
717 return null; |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
718 } |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
719 |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
720 double endKm; |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
721 |
6984
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
722 if (stations.ceilingEntry(km + 0.1d) != null) { |
77f48c104d23
Backed out changeset 6b9402377d07
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6970
diff
changeset
|
723 MeasurementStation nextStation = stations.ceilingEntry(km + 0.1d).getValue(); |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
724 endKm = nextStation.getRange().getA().doubleValue(); |
6966
328854c0467f
SedimentLoadFactory: Further code simplification.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6965
diff
changeset
|
725 } |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
726 else { |
6966
328854c0467f
SedimentLoadFactory: Further code simplification.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6965
diff
changeset
|
727 // TODO end-of-river instead of B. |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
728 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
|
729 } |
6967
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
730 |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
731 return new Range( |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
732 station.getRange().getA().doubleValue(), |
3a987e9af256
SedimentLoadFactory: Improved readability.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6966
diff
changeset
|
733 endKm); |
6964
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
734 } |
5662
7e3cde8b564c
Cosmetics, docs, vimlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
735 |
5789 | 736 /** |
737 * 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
|
738 * 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
|
739 * |
5789 | 740 * @param fraction value to set 'grain' parameter in query to. |
741 * @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
|
742 * @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
|
743 * 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
|
744 * @return param load or new load if null. |
5789 | 745 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
746 protected static SedimentLoadLSData getValues ( |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
747 String fraction, |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
748 SQLQuery query, |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
749 SedimentLoadLSData load, |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
750 TreeMap<Double, MeasurementStation> stations |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
751 ) { |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
752 query.setString("grain", fraction); |
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
753 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
|
754 |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
755 // 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
|
756 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
|
757 Object[] row = results.get(0); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
758 load = new SedimentLoadLSData( |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
759 (String) row[0], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
760 (Date) row[1], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
761 (Date) row[4], |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
762 true, |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
763 (String)row[5]); |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
764 } |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
765 |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
766 for (int i = 0, R = results.size(); i < R; i++) { |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
767 Object[] row = results.get(i); |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
768 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
|
769 Range range = findMeasurementStationRange(stations, km); |
5a348e3df0f8
SedimentLoadFactory: Extracted method to find range of matching
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6948
diff
changeset
|
770 if (range == null) { |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
771 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
|
772 continue; |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
773 } |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
774 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
|
775 |
4370
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
776 if (row[2] != null) { |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
777 v = ((Double)row[2]).doubleValue(); |
6a65e7ef43c0
Updated data object and factory for sediment load.
Raimund Renkert <rrenkert@intevation.de>
parents:
4296
diff
changeset
|
778 } |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
779 |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
780 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
|
781 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
782 |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
783 if (results.isEmpty()) { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
784 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
|
785 } |
6741
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
786 |
35f2d32b921d
issue1393: Survive when off-epochs no total data, but other.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6740
diff
changeset
|
787 return load; |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
788 } |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
789 |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
790 |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
791 /** 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
|
792 private static void setLoadFraction( |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
793 SedimentLoadLSData load, double km, double v, Range range, String fraction) { |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
794 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
|
795 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
|
796 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
797 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
|
798 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
|
799 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
800 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
|
801 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
|
802 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
803 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
|
804 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
|
805 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
806 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
|
807 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
|
808 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
809 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
|
810 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
|
811 } |
7430
7f438ee10be6
Fix total sediment load fetching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7305
diff
changeset
|
812 else if (fraction.equals("total")) { |
7f438ee10be6
Fix total sediment load fetching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7305
diff
changeset
|
813 load.setLoadTotal(km, v, range); |
7f438ee10be6
Fix total sediment load fetching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7305
diff
changeset
|
814 } |
7180
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
815 else { |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
816 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
|
817 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
818 } |
e0b6b6cf4708
issue1435: Minor refactoring that will come handy to load SedimentLoads
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7053
diff
changeset
|
819 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
820 public static SedimentLoadLSData getLoadUnknown( |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
821 String river, |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
822 String description, |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
823 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
|
824 ) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
825 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
|
826 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
|
827 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
828 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
|
829 log.debug("Cache not configured."); |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
830 return getSedimentLoadUnknownUncached(river, description, type); |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
831 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
832 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
833 StaticSedimentLoadCacheKey key = |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
834 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
|
835 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
836 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
|
837 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
838 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
|
839 log.debug("SedimentLoad found in cache"); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
840 return (SedimentLoadLSData)element.getValue(); |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
841 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
842 |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
843 SedimentLoadLSData values = |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
844 getSedimentLoadUnknownUncached(river, description, type); |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
845 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
846 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
|
847 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
|
848 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
|
849 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
|
850 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
851 return values; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
852 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
853 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
854 /** |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
855 * 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
|
856 * @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
|
857 * @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
|
858 * @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
|
859 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
860 public static SedimentLoadLSData getSedimentLoadUnknownUncached( |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
861 String river, |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
862 String description, |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
863 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
|
864 ) { |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
865 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
|
866 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
|
867 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
|
868 |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
869 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
|
870 .addScalar("description", StandardBasicTypes.STRING) |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
871 .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
|
872 .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
|
873 .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
|
874 .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
|
875 .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
|
876 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
|
877 sqlQuery.setString("descr", description); |
7819
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
878 if (type.equals("off_epoch")) { |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
879 sqlQuery.setInteger("type", 1); |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
880 } |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
881 else { |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
882 sqlQuery.setInteger("type", 0); |
b468dc65154a
Use the sediment yield kind to get data to avoid mixing epoch with off. epoch data.
Raimund Renkert <rrenkert@intevation.de>
parents:
7498
diff
changeset
|
883 } |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
884 List<Object []> results = sqlQuery.list(); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
885 SedimentLoadLSData load = new SedimentLoadLSData(); |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
886 if (results.isEmpty()) { |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
887 return new SedimentLoadLSData(); |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
888 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
889 Object[] row = results.get(0); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
890 load = new SedimentLoadLSData( |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
891 (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
|
892 (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
|
893 (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
|
894 false, |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
895 (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
|
896 |
7254
fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7248
diff
changeset
|
897 for (int i = 0, R = results.size(); i < R; i++) { |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
898 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
|
899 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
|
900 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
|
901 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
|
902 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
903 return load; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
904 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
905 |
6665
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
906 /** |
b7945db8a43b
issue1413: Only show unknown sediment loads of selected unit type.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6545
diff
changeset
|
907 * 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
|
908 * @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
|
909 * @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
|
910 * @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
|
911 */ |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
912 public static SedimentLoadLSData[] getSedimentLoadUnknown( |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
913 String river, |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
914 String unit, |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
915 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
|
916 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
|
917 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
|
918 .addScalar("description", StandardBasicTypes.STRING) |
6477
d1502b8dd091
'start' is a reserved word in Oracle
Tom Gottfried <tom@intevation.de>
parents:
6412
diff
changeset
|
919 .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
|
920 .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
|
921 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
|
922 sqlQuery.setString("unit", unit); |
6755
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
923 if (type.equals("off_epoch")) { |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
924 sqlQuery.setInteger("type", 1); |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
925 } |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
926 else { |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
927 sqlQuery.setInteger("type", 0); |
91c43293e538
issue1433: Filter loaded unknown sediment yields by kind.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6741
diff
changeset
|
928 } |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
929 List<Object[]> results = sqlQuery.list(); |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
930 SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()]; |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
931 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
|
932 for (Object[] row: results) { |
8024
963ede7b32bb
Renamed SedimentLoad to SedimentLoadLSData to make place for SedimentLoad in backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7819
diff
changeset
|
933 loads[counter] = new SedimentLoadLSData( |
6392
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
934 (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
|
935 counter++; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
936 } |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
937 return loads; |
9a0f8d532797
Load sedimentload fraction with sedimentload factory and add new facets to artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
6377
diff
changeset
|
938 } |
4296
3051bc28ac43
Added data object and factory for sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
939 } |
5662
7e3cde8b564c
Cosmetics, docs, vimlines.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
940 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |