Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/sq/StaticSQFactory.java @ 8545:c6723e5b6857
(issue1750) It is an error if there are more then two stations at the same range.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 13 Feb 2015 16:36:52 +0100 |
parents | 9a5b3079aad4 |
children | 958342db7a15 |
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:
5500
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.sq; |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 import java.math.BigDecimal; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 import java.util.Date; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import java.util.List; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import net.sf.ehcache.Cache; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 import net.sf.ehcache.Element; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 import org.apache.log4j.Logger; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 import org.hibernate.Query; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 import org.hibernate.Session; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5500
diff
changeset
|
22 import org.dive4elements.river.artifacts.cache.CacheFactory; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5500
diff
changeset
|
23 import org.dive4elements.river.backend.SessionHolder; |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 public class StaticSQFactory |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 private static final Logger log = |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 Logger.getLogger(StaticSQFactory.class); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 |
8543
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
31 public static final String SQL_STATIONS_AT_RANGE = |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
32 "SELECT "+ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
33 "ms.id AS ms_id " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
34 "FROM measurement_station ms " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
35 "JOIN ranges ra ON ra.id = ms.range_id " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
36 "JOIN rivers r ON r.id = ra.river_id " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
37 "WHERE r.name = :river AND " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
38 "ms.range_id = (SELECT range_id " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
39 "FROM measurement_station " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
40 "WHERE id = :ms_id)"; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
41 |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 public static final String SQL_SQ = |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 "SELECT " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 "sq.description AS description,"+ |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 "ti.start_time AS start_time," + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 "ti.stop_time AS stop_time, " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 "ms.name AS station_name, " + |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
48 "CASE WHEN r.km_up = 1 AND ra.b IS NOT NULL " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
49 "THEN ra.b " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
50 "ELSE ra.a " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
51 "END AS station_km, " + |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 "ms.measurement_type AS measurement_type, " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 "sqv.parameter AS parameter, " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 "sqv.a AS a, " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 "sqv.b AS b, " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 "sqv.qmax AS qmax " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 "FROM sq_relation sq " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 "JOIN time_intervals ti ON ti.id = sq.time_interval_id " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 "JOIN sq_relation_value sqv ON sqv.sq_relation_id = sq.id " + |
8412
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
60 "JOIN measurement_station ms " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
61 "ON sqv.measurement_station_id = ms.id " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
62 "JOIN ranges ra ON ra.id = ms.range_id " + |
17db08570637
SCHEMA CHANGE: removed superfluous columns station and river_id from measurement_stations and adapted other components accordingly.
Tom Gottfried <tom@intevation.de>
parents:
7236
diff
changeset
|
63 "JOIN rivers r ON r.id = ra.river_id "; |
7236
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
64 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
65 public static final String STATION_CLAUSE = |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 "WHERE " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 "r.name = :river " + |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 "AND ms.id = :ms_id "; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 |
7236
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
70 public static final String ID_CLAUSE = |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
71 "WHERE " + |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
72 "sqv.id = :dis_id "; |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 private StaticSQFactory() { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 |
8543
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
77 /** Get SQ relations for a measurement station's location. |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
78 * Returns all SQRelations for the location of the station and |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
79 * not just for the station. E.g. for a "Geschiebemessstelle" |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
80 * and a "Schwebstoffmesstelle" at the same place.*/ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
81 public static StaticSQContainer getSQRelationsForLocation( |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
82 String river, |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
83 int measurementStation |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
84 ) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
85 Session session = SessionHolder.HOLDER.get(); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
86 Query query = session.createSQLQuery(SQL_STATIONS_AT_RANGE) |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
87 .setParameter("river", river) |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
88 .setParameter("ms_id", measurementStation); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
89 /* Take the first container for the station requested. */ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
90 StaticSQContainer retval = getSQRelations(river, measurementStation); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
91 |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
92 /* And some others */ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
93 List<Integer> list = query.list(); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
94 if (list == null || list.isEmpty()) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
95 log.error("Did not even find one measurement station. Broken Query?"); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
96 return retval; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
97 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
98 |
8545
c6723e5b6857
(issue1750) It is an error if there are more then two stations at the same range.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8543
diff
changeset
|
99 if (list.size() > 2) { |
c6723e5b6857
(issue1750) It is an error if there are more then two stations at the same range.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8543
diff
changeset
|
100 log.error("More then two measurement stations found at the same range. Bad Data!"); |
c6723e5b6857
(issue1750) It is an error if there are more then two stations at the same range.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8543
diff
changeset
|
101 return retval; |
c6723e5b6857
(issue1750) It is an error if there are more then two stations at the same range.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8543
diff
changeset
|
102 } |
c6723e5b6857
(issue1750) It is an error if there are more then two stations at the same range.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8543
diff
changeset
|
103 |
8543
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
104 for (Integer stationId: list) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
105 log.debug("Collecting SQ Relations for: "+ stationId); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
106 if (stationId == measurementStation) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
107 /* Skip the same station */ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
108 continue; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
109 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
110 |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
111 StaticSQContainer additional = getSQRelations(river, stationId); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
112 if (additional == null || additional.getSQRelations() == null) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
113 continue; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
114 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
115 |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
116 if (retval == null || retval.getSQRelations() == null || retval.getSQRelations().isEmpty()) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
117 /* Old one is empty, just take the new one. */ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
118 retval = additional; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
119 continue; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
120 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
121 |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
122 for (StaticSQRelation rel: additional.getSQRelations()) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
123 /* Check if we already have one for this parameter. |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
124 * This is highly unlikely in the data scheme of things. */ |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
125 List<StaticSQRelation> old = retval.getRelationsByParameter( |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
126 rel.getParameter()); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
127 if (old != null || !old.isEmpty()) { |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
128 log.warn("Multiple SQ relation Parameters found for different " + |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
129 "measurement_stations at the same range. This should not happen."); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
130 continue; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
131 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
132 retval.addSQRelation(rel); |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
133 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
134 |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
135 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
136 return retval; |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
137 } |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
138 |
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
139 |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
140 public static StaticSQContainer getSQRelations( |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
141 String river, |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 int measurementStation |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
143 ) { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 Cache cache = CacheFactory.getCache(StaticSQCacheKey.CACHE_NAME); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
145 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
146 StaticSQCacheKey cacheKey; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
148 if (cache != null) { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
149 cacheKey = new StaticSQCacheKey(river, measurementStation); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
150 Element element = cache.get(cacheKey); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
151 if (element != null) { |
8543
9a5b3079aad4
(issue1750) Take Static SQ Relations based on a range and merge them together
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8412
diff
changeset
|
152 log.debug("Got static sq relations from cache"); |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
153 return (StaticSQContainer)element.getValue(); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
154 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
155 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
156 else { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 cacheKey = null; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
158 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
159 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
160 StaticSQContainer values = getUncached(river, measurementStation); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
161 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
162 if (values != null && cacheKey != null) { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
163 log.debug("Store static sq relations in cache."); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
164 Element element = new Element(cacheKey, values); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
165 cache.put(element); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
166 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
167 return values; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
168 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
169 |
7236
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
170 public static StaticSQContainer getDistinctRelation(int id) { |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
171 Session session = SessionHolder.HOLDER.get(); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
172 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
173 Query query = session.createSQLQuery(SQL_SQ + ID_CLAUSE) |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
174 .addScalar("description") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
175 .addScalar("start_time") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
176 .addScalar("stop_time") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
177 .addScalar("station_name") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
178 .addScalar("station_km") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
179 .addScalar("measurement_type") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
180 .addScalar("parameter") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
181 .addScalar("a") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
182 .addScalar("b") |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
183 .addScalar("qmax"); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
184 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
185 query.setParameter("dis_id", id); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
186 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
187 /* This could be done nicer with hibernate */ |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
188 List<Object []> list = query.list(); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
189 if (list.isEmpty()) { |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
190 log.debug("Query returened nothing"); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
191 return null; |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
192 } |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
193 Object [] row = list.get(0); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
194 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
195 StaticSQContainer sq = new StaticSQContainer(); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
196 sq.setDescription((String)list.get(0)[0]); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
197 sq.setStationName((String)list.get(0)[3]); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
198 sq.setKm(((BigDecimal)list.get(0)[4]).doubleValue()); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
199 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
200 StaticSQRelation relation = new StaticSQRelation(); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
201 relation.setStartTime((Date)row[1]); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
202 relation.setStopTime((Date)row[2]); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
203 relation.setType((String)row[5]); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
204 relation.setParameter((String)row[6]); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
205 relation.setA(((BigDecimal)row[7]).doubleValue()); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
206 relation.setB(((BigDecimal)row[8]).doubleValue()); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
207 relation.setQmax(((BigDecimal)row[9]).doubleValue()); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
208 sq.addSQRelation(relation); |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
209 |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
210 return sq; |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
211 } |
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
212 |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
213 private static StaticSQContainer getUncached( |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
214 String river, |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
215 int measurementStation |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
216 ) { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
217 Session session = SessionHolder.HOLDER.get(); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
218 |
7236
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
219 Query query = session.createSQLQuery(SQL_SQ + STATION_CLAUSE) |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
220 .addScalar("description") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
221 .addScalar("start_time") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
222 .addScalar("stop_time") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
223 .addScalar("station_name") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
224 .addScalar("station_km") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
225 .addScalar("measurement_type") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
226 .addScalar("parameter") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
227 .addScalar("a") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
228 .addScalar("b") |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
229 .addScalar("qmax"); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
230 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
231 query.setParameter("river", river); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
232 query.setParameter("ms_id", measurementStation); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
233 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
234 List<Object []> list = query.list(); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
235 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
236 if (list.isEmpty()) { |
7236
a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
Andre Heinecke <aheinecke@intevation.de>
parents:
5994
diff
changeset
|
237 log.debug("Query returened empty"); |
5500
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
238 return new StaticSQContainer(); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
239 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
240 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
241 StaticSQContainer sq = new StaticSQContainer(); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
242 sq.setDescription((String)list.get(0)[0]); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
243 sq.setStationName((String)list.get(0)[3]); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
244 sq.setKm(((BigDecimal)list.get(0)[4]).doubleValue()); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
245 |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
246 for (Object[] row : list) { |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
247 StaticSQRelation relation = new StaticSQRelation(); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
248 relation.setStartTime((Date)row[1]); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
249 relation.setStopTime((Date)row[2]); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
250 relation.setType((String)row[5]); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
251 relation.setParameter((String)row[6]); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
252 relation.setA(((BigDecimal)row[7]).doubleValue()); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
253 relation.setB(((BigDecimal)row[8]).doubleValue()); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
254 relation.setQmax(((BigDecimal)row[9]).doubleValue()); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
255 sq.addSQRelation(relation); |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
256 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
257 return sq; |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
258 } |
700ac898ab0b
Added Factory and model for static sq relations.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
259 } |