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