annotate flys-backend/src/main/java/de/intevation/flys/model/Gauge.java @ 468:8d76556c9616

Added methods to retrieve the min and max W and Q values of a Wst and Gauge. flys-backend/trunk@1705 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 15 Apr 2011 13:45:06 +0000
parents bfee0e05b4e7
children 46bb2b9e0bdc
rev   line source
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.model;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.math.BigDecimal;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import java.io.Serializable;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
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
7 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
8
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
9 import javax.persistence.Entity;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
10 import javax.persistence.Id;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
11 import javax.persistence.Table;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
12 import javax.persistence.GeneratedValue;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
13 import javax.persistence.Column;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
14 import javax.persistence.SequenceGenerator;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
15 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
16 import javax.persistence.JoinColumn;
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
17 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
18 import javax.persistence.OneToMany;
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
19
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
20 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
21 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
22
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
23 import de.intevation.flys.backend.SessionHolder;
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
24
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
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
26 @Entity
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
27 @Table(name = "gauges")
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 public class Gauge
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 implements Serializable
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 {
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
31 private Integer id;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 private String name;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 private River river;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 private BigDecimal station;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 private BigDecimal aeo;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 private BigDecimal datum;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 private Range range;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
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
39 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
40
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public Gauge() {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
192
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
44 public Gauge(
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
45 String name,
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
46 River river,
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
47 BigDecimal station,
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
48 BigDecimal aeo,
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
49 BigDecimal datum,
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
50 Range range
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
51 ) {
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
52 this.name = name;
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
53 this.river = river;
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
54 this.station = station;
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
55 this.aeo = aeo;
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
56 this.datum = datum;
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
57 this.range = range;
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
58 }
f1fce41347ea Added missing ImportGauge.getPeer() method
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 174
diff changeset
59
171
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
60 @Id
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
61 @SequenceGenerator(
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
62 name = "SEQUENCE_GAUGES_ID_SEQ",
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
63 sequenceName = "GAUGES_ID_SEQ",
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
64 allocationSize = 1)
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
65 @GeneratedValue(
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
66 strategy = GenerationType.SEQUENCE,
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
67 generator = "SEQUENCE_GAUGES_ID_SEQ")
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
68 @Column(name = "id")
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
69 public Integer getId() {
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
70 return id;
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
71 }
4a83e14f40f9 Added entity and id annotations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 168
diff changeset
72
168
86a1bd9cc50e More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 167
diff changeset
73 public void setId(Integer id) {
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 this.id = id;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76
193
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
77 @OneToOne
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
78 @JoinColumn(name = "river_id" )
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
79 public River getRiver() {
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
80 return river;
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
81 }
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
82
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
83 public void setRiver(River river) {
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
84 this.river = river;
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
85 }
31c48d54f09d Add forgotten column river_id in Gauges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 192
diff changeset
86
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
87 @Column(name = "name")
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
88 public String getName() {
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
89 return name;
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
90 }
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
91
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 public void setName(String name) {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 this.name = name;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
96 @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
97 public BigDecimal getStation() {
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
98 return station;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 public void setStation(BigDecimal station) {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 this.station = station;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
105 @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
106 public BigDecimal getAeo() {
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
107 return aeo;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 public void setAeo(BigDecimal aeo) {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 this.aeo = aeo;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113
172
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
114 @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
115 public BigDecimal getDatum() {
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
116 return datum;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 public void setDatum(BigDecimal datum) {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 this.datum = datum;
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
174
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
123 @OneToOne
249390dd24e7 Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 172
diff changeset
124 @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
125 public Range getRange() {
605320b7df94 Added column annotations for simple fields. TODO: foreign keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 171
diff changeset
126 return range;
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 public void setRange(Range range) {
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 this.range = range;
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 }
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
132
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
133 @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
134 @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
135 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
136 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
137 }
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
138
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
139 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
140 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
141 }
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
142
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
143
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
144 /**
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
145 * 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
146 *
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
147 * @return the min and max W value of this gauge [min,max].
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
148 */
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
149 public double[] determineMinMaxW() {
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
150 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
151
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
152 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
153 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
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 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
156 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
157 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
158 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
159 }
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
160 }
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
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
162 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
163 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
164 }
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
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 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
167 "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
168 "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
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
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
171 List results = query.list();
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
172 Object[] result = (Object[]) results.get(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
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 return result != 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
175 ? new double[] {
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 ((BigDecimal) result[0]).doubleValue(),
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
177 ((BigDecimal) result[1]).doubleValue() }
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
178 : 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
179 }
167
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
180 }
15d515fe15f5 Added POJOs to be mapped to schema.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org