Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/model/Gauge.java @ 9633:b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
author | mschaefer |
---|---|
date | Thu, 17 Oct 2019 16:48:03 +0200 |
parents | bc9a45d2b1fa |
children |
rev | line source |
---|---|
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5970
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5992
4c3ccf2b0304
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5970
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
9 package org.dive4elements.river.model; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
11 import java.io.Serializable; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import java.math.BigDecimal; |
203
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
13 import java.util.List; |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
14 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
15 import javax.persistence.Column; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
16 import javax.persistence.Entity; |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
17 import javax.persistence.GeneratedValue; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
18 import javax.persistence.GenerationType; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
19 import javax.persistence.Id; |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
20 import javax.persistence.JoinColumn; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
21 import javax.persistence.OneToMany; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
22 import javax.persistence.OneToOne; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
23 import javax.persistence.SequenceGenerator; |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
24 import javax.persistence.Table; |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
25 |
5969
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
26 import org.apache.log4j.Logger; |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
27 import org.dive4elements.river.backend.SessionHolder; |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
28 import org.hibernate.Query; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
29 import org.hibernate.Session; |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
30 |
5374 | 31 /** Database-mapped Gauge with all info about it. */ |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
32 @Entity |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
33 @Table(name = "gauges") |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
34 public class Gauge implements Serializable, Comparable<Gauge> { |
5969
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
35 private static final Logger log = Logger.getLogger(Gauge.class); |
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
36 |
2385
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
37 public static final int MASTER_DISCHARGE_TABLE = 0; |
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
38 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
39 private Integer id; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
40 private String name; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
41 private River river; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 private BigDecimal station; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 private BigDecimal aeo; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 private BigDecimal datum; |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
45 private Long officialNumber; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
46 private Range range; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
203
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
48 private List<DischargeTable> dischargeTables; |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
49 |
1233
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
50 /** MainValues at this Gauge. */ |
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
51 protected List<MainValue> mainValues; |
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
52 |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 public Gauge() { |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
56 public Gauge(final String name, final River river, final BigDecimal station, final BigDecimal aeo, final BigDecimal datum, final Long officialNumber, |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
57 final Range range) { |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
58 this.name = name; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
59 this.river = river; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
60 this.station = station; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
61 this.aeo = aeo; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
62 this.datum = datum; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
63 this.officialNumber = officialNumber; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
64 this.range = range; |
192
f1fce41347ea
Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
65 } |
f1fce41347ea
Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
174
diff
changeset
|
66 |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
67 @Id |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
68 @SequenceGenerator(name = "SEQUENCE_GAUGES_ID_SEQ", sequenceName = "GAUGES_ID_SEQ", allocationSize = 1) |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
69 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_GAUGES_ID_SEQ") |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
70 @Column(name = "id") |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
71 public Integer getId() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
72 return this.id; |
171
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
73 } |
4a83e14f40f9
Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
168
diff
changeset
|
74 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
75 public void setId(final Integer id) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 this.id = id; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 |
193
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
79 @OneToOne |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
80 @JoinColumn(name = "river_id") |
193
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
81 public River getRiver() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
82 return this.river; |
193
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
83 } |
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
84 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
85 public void setRiver(final River river) { |
193
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
86 this.river = river; |
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
87 } |
31c48d54f09d
Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
192
diff
changeset
|
88 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
89 @Column(name = "name") |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
90 public String getName() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
91 return this.name; |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
92 } |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
93 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
94 public void setName(final String name) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 this.name = name; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
98 @Column(name = "station") // FIXME: type mapping needed |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
99 public BigDecimal getStation() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
100 return this.station; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
103 public void setStation(final BigDecimal station) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 this.station = station; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
107 @Column(name = "aeo") // FIXME: type mapping needed |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
108 public BigDecimal getAeo() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
109 return this.aeo; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
112 public void setAeo(final BigDecimal aeo) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 this.aeo = aeo; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
116 @Column(name = "datum") // FIXME: type mapping needed |
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
117 public BigDecimal getDatum() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
118 return this.datum; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
121 public void setDatum(final BigDecimal datum) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 this.datum = datum; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 |
2371
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
125 @Column(name = "official_number") |
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
126 public Long getOfficialNumber() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
127 return this.officialNumber; |
2371
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
128 } |
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
129 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
130 public void setOfficialNumber(final Long officialNumber) { |
2371
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
131 this.officialNumber = officialNumber; |
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
132 } |
fe89d6cf55fb
Added support for official gauge numbers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1233
diff
changeset
|
133 |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
172
diff
changeset
|
134 @OneToOne |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
135 @JoinColumn(name = "range_id") |
172
605320b7df94
Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
171
diff
changeset
|
136 public Range getRange() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
137 return this.range; |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
140 public void setRange(final Range range) { |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 this.range = range; |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 } |
203
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
143 |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
144 @OneToMany |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
145 @JoinColumn(name = "gauge_id") |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
146 public List<DischargeTable> getDischargeTables() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
147 return this.dischargeTables; |
203
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
148 } |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
149 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
150 public void setDischargeTables(final List<DischargeTable> dischargeTables) { |
203
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
151 this.dischargeTables = dischargeTables; |
bfee0e05b4e7
Added an one to many relation to the discharge tables of a gauge.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
193
diff
changeset
|
152 } |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
153 |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
154 /** |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
155 * Returns min and max W values of this gauge. |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
156 * |
1233
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
157 * @return the min and max W value of this gauge [min,max]. |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
158 */ |
6327
447ed3dee890
Backend: removed scale factor from min/max value determination of gauge Ws.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5992
diff
changeset
|
159 public double[] determineMinMaxW() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
160 final Session session = SessionHolder.HOLDER.get(); |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
161 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
162 final DischargeTable dischargeTable = fetchMasterDischargeTable(); |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
163 |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
164 if (dischargeTable == null) { |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
165 return null; |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
166 } |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
167 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
168 final Query query = session.createQuery("select min(w) as min, max(w) as max from DischargeTableValue " + "where table_id =:table"); |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
169 query.setParameter("table", dischargeTable.getId()); |
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
170 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
171 final List<?> results = query.list(); |
5969
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
172 if (results.isEmpty()) { |
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
173 log.error("No values in discharge table found."); |
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
174 return null; |
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
175 } |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
176 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
177 final Object[] result = (Object[]) results.get(0); |
5969
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
178 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
179 final BigDecimal a = (BigDecimal) result[0]; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
180 final BigDecimal b = (BigDecimal) result[1]; |
5969
abe5fe3d2d17
Fixed NPE problem in fetching extram from discharge curves.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5844
diff
changeset
|
181 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
182 return a != null && b != null ? new double[] { a.doubleValue(), b.doubleValue() } : null; |
468
8d76556c9616
Added methods to retrieve the min and max W and Q values of a Wst and Gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
203
diff
changeset
|
183 } |
1233
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
184 |
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
185 @OneToMany |
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
186 @JoinColumn(name = "gauge_id") |
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
187 public List<MainValue> getMainValues() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
188 return this.mainValues; |
1233
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
189 } |
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
190 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
191 public void setMainValues(final List<MainValue> mainValues) { |
1233
5a3109b8475f
Mapping and Accessors for MainValues of Gauge, by Sascha L. Teichmann.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
480
diff
changeset
|
192 this.mainValues = mainValues; |
2381
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
193 } |
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
194 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
195 public static Gauge getGaugeByOfficialNumber(final long number) { |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
196 final Session session = SessionHolder.HOLDER.get(); |
2381
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
197 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
198 final Query query = session.createQuery("from Gauge where officialNumber=:number"); |
2381
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
199 |
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
200 query.setParameter("number", number); |
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
201 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
202 final List<Gauge> results = query.list(); |
2381
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
203 |
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
204 return results.isEmpty() ? null : results.get(0); |
aa777d1aba38
Added a function Gauge.getGaugeByOfficialNumber() that returns a Gauge based on its official number.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2371
diff
changeset
|
205 } |
2385
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
206 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
207 public static Gauge getGaugeByOfficialNumber(final long number, final String river_name) { |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
208 final Session session = SessionHolder.HOLDER.get(); |
6838
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
209 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
210 final Query query = session.createQuery("from Gauge as gau " + "where gau.officialNumber=:number and gau.river.name=:river_name"); |
6838
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
211 |
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
212 query.setParameter("number", number); |
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
213 query.setParameter("river_name", river_name); |
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
214 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
215 final List<Gauge> results = query.list(); |
6838
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
216 |
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
217 return results.isEmpty() ? null : results.get(0); |
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
218 } |
a895eb07a7dc
(issue1353) Add method to model to gauge by number and river name
Andre Heinecke <aheinecke@intevation.de>
parents:
6327
diff
changeset
|
219 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
220 public static Gauge getGaugeByNameAndRiver(final String gauge_name, final River river) { |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
221 final Session session = SessionHolder.HOLDER.get(); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
222 |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
223 final Query query = session.createQuery("from Gauge as gau " + "where gau.name=:name and gau.river=:river"); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
224 |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
225 query.setParameter("name", gauge_name); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
226 query.setParameter("river", river); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
227 |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
228 final List<Gauge> results = query.list(); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
229 |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
230 return results.isEmpty() ? null : results.get(0); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
231 } |
2385
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
232 |
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
233 public DischargeTable fetchMasterDischargeTable() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
234 final Session session = SessionHolder.HOLDER.get(); |
2385
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
235 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
236 final Query query = session.createQuery("from DischargeTable " + "where kind = 0 " + "and gauge = :gauge"); |
8482
0c22ef71d154
Use explicit query to avoid hibernate connection leak.
Tom Gottfried <tom@intevation.de>
parents:
6838
diff
changeset
|
237 |
0c22ef71d154
Use explicit query to avoid hibernate connection leak.
Tom Gottfried <tom@intevation.de>
parents:
6838
diff
changeset
|
238 query.setParameter("gauge", this); |
0c22ef71d154
Use explicit query to avoid hibernate connection leak.
Tom Gottfried <tom@intevation.de>
parents:
6838
diff
changeset
|
239 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
240 final List<Object> results = query.list(); |
8482
0c22ef71d154
Use explicit query to avoid hibernate connection leak.
Tom Gottfried <tom@intevation.de>
parents:
6838
diff
changeset
|
241 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
242 return results.isEmpty() ? null : (DischargeTable) results.get(0); |
2385
83abe19d4f40
Added a method Gauge.fetchMasterDischargeTable() to retrieve the discharge table with kind = 0.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2381
diff
changeset
|
243 } |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
244 |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
245 /** |
9633
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
246 * Fetches from the database the most recent discharge table |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
247 */ |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
248 public DischargeTable fetchRecentDischargeTable() { |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
249 final Session session = SessionHolder.HOLDER.get(); |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
250 |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
251 final Query query = session.createQuery("FROM DischargeTable" // |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
252 + " WHERE (gauge = :gauge)" // |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
253 + " ORDER BY timeInterval.startTime DESC"); |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
254 |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
255 query.setParameter("gauge", this); |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
256 |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
257 final List<Object> results = query.list(); |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
258 |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
259 return results.isEmpty() ? null : (DischargeTable) results.get(0); |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
260 } |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
261 |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
262 /** |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
263 * Returns an array of [days, qs] necessary to create duration curves. |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
264 * |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
265 * @return a 2dim array of [days, qs] where days is an int[] and qs is |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
266 * an double[]. |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
267 */ |
3688
8d38ee2de514
Rename method to satisfy hibernate
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3686
diff
changeset
|
268 public Object[] fetchDurationCurveData() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
269 final Session session = SessionHolder.HOLDER.get(); |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
270 |
9633
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
271 final Query query = session.createQuery("select cast(nmv.name as integer) as days, mv.value as q " // |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
272 + "from MainValue as mv " // |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
273 + "join mv.mainValue as nmv " // |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
274 + "join nmv.type mvt " // |
b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
mschaefer
parents:
9404
diff
changeset
|
275 + "where mvt.name = 'D' and mv.gauge.id = :gauge_id " + "order by days"); |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
276 |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
277 query.setParameter("gauge_id", getId()); |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
278 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
279 final List<Object> results = query.list(); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
280 final int[] days = new int[results.size()]; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
281 final double[] qs = new double[results.size()]; |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
282 |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
283 int idx = 0; |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
284 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
285 for (final Object obj : results) { |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
286 final Object[] arr = (Object[]) obj; |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
287 |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
288 try { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
289 final int day = ((Integer) arr[0]).intValue(); |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
290 final double q = ((BigDecimal) arr[1]).doubleValue(); |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
291 |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
292 days[idx] = day; |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
293 qs[idx++] = q; |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
294 } |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
295 catch (final NumberFormatException nfe) { |
3686
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
296 } |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
297 } |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
298 |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
299 return new Object[] { days, qs }; |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
300 } |
c959444ff395
Add getDurationCurveData method to Gauge class
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3343
diff
changeset
|
301 |
3789
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
302 /** |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
303 * Calculates the maximum and minimum W and Q values |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
304 * |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
305 * @return the MaxMinWQ object representing the calculated values |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
306 */ |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
307 public MinMaxWQ fetchMaxMinWQ() { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
308 final Session session = SessionHolder.HOLDER.get(); |
3789
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
309 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
310 final Query query = session.createQuery("select max(mv.value) as max, min(mv.value) as min " + "from MainValue as mv " + "join mv.mainValue as nmv " |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
311 + "join nmv.type mvt " + "where mvt.name in ('W', 'Q') " + "and mv.gauge.id = :gauge_id " + "group by mvt.name order by mvt.name"); |
3789
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
312 |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
313 query.setParameter("gauge_id", getId()); |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
314 |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
315 final List<Object> results = query.list(); |
3790
6546c0bbc6f9
Backend: 'Pegelinfo' needs min/max Q, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3789
diff
changeset
|
316 if (results.isEmpty()) { |
3789
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
317 // No values found |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
318 return new MinMaxWQ(); |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
319 } |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
320 |
3790
6546c0bbc6f9
Backend: 'Pegelinfo' needs min/max Q, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3789
diff
changeset
|
321 Object[] arr = (Object[]) results.get(0); |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
322 final BigDecimal maxw = (BigDecimal) arr[0]; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
323 final BigDecimal minw = (BigDecimal) arr[1]; |
3789
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
324 BigDecimal maxq = null; |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
325 BigDecimal minq = null; |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
326 |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
327 if (results.size() > 1) { |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
328 arr = (Object[]) results.get(1); |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
329 maxq = (BigDecimal) arr[0]; |
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
330 minq = (BigDecimal) arr[1]; |
3789
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
331 } |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
332 |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
333 return new MinMaxWQ(minw, maxw, minq, maxq); |
9f92c42b7a81
Add method fetchMinMaxWQ to Gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
3788
diff
changeset
|
334 } |
4174
eaf83d4ae6b1
Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3947
diff
changeset
|
335 |
eaf83d4ae6b1
Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3947
diff
changeset
|
336 @Override |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
8856
diff
changeset
|
337 public int compareTo(final Gauge o) { |
4174
eaf83d4ae6b1
Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3947
diff
changeset
|
338 return getName().compareTo(o.getName()); |
eaf83d4ae6b1
Sorted gauges for reference gauge selection in historical discharge calculation based on their name.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3947
diff
changeset
|
339 } |
167
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
340 } |
15d515fe15f5
Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
341 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |