Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java @ 5379:61bf64b102bc mapgenfix
Merge with default branch
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 22 Mar 2013 11:25:54 +0100 |
parents | c7ce7c9e405e |
children |
comparison
equal
deleted
inserted
replaced
5175:cfc5540a4eec | 5379:61bf64b102bc |
---|---|
1 package de.intevation.flys.model; | 1 package de.intevation.flys.model; |
2 | 2 |
3 import de.intevation.flys.backend.SessionHolder; | |
4 | |
3 import java.io.Serializable; | 5 import java.io.Serializable; |
6 | |
4 import java.util.List; | 7 import java.util.List; |
5 | 8 |
9 import javax.persistence.Column; | |
6 import javax.persistence.Entity; | 10 import javax.persistence.Entity; |
11 import javax.persistence.GeneratedValue; | |
12 import javax.persistence.GenerationType; | |
7 import javax.persistence.Id; | 13 import javax.persistence.Id; |
8 import javax.persistence.Table; | |
9 import javax.persistence.GeneratedValue; | |
10 import javax.persistence.Column; | |
11 import javax.persistence.SequenceGenerator; | |
12 import javax.persistence.GenerationType; | |
13 import javax.persistence.JoinColumn; | 14 import javax.persistence.JoinColumn; |
14 import javax.persistence.OneToOne; | 15 import javax.persistence.OneToOne; |
15 | 16 import javax.persistence.SequenceGenerator; |
16 import org.hibernate.Session; | 17 import javax.persistence.Table; |
17 import org.hibernate.Query; | |
18 | 18 |
19 import org.apache.log4j.Logger; | 19 import org.apache.log4j.Logger; |
20 | 20 |
21 import de.intevation.flys.backend.SessionHolder; | 21 import org.hibernate.Query; |
22 import org.hibernate.Session; | |
22 | 23 |
23 | 24 |
24 @Entity | 25 @Entity |
25 @Table(name = "flow_velocity_model") | 26 @Table(name = "flow_velocity_model") |
26 public class FlowVelocityModel | 27 public class FlowVelocityModel |
29 private static Logger logger = Logger.getLogger(FlowVelocityModel.class); | 30 private static Logger logger = Logger.getLogger(FlowVelocityModel.class); |
30 | 31 |
31 | 32 |
32 private Integer id; | 33 private Integer id; |
33 | 34 |
34 private River river; | |
35 | |
36 private DischargeZone dischargeZone; | 35 private DischargeZone dischargeZone; |
37 | |
38 private List<FlowVelocityModelValue> values; | |
39 | 36 |
40 private String description; | 37 private String description; |
41 | 38 |
42 | 39 |
43 public FlowVelocityModel() { | 40 public FlowVelocityModel() { |
44 } | 41 } |
45 | 42 |
46 | 43 |
47 public FlowVelocityModel(River river, DischargeZone dischargeZone) { | 44 public FlowVelocityModel(DischargeZone dischargeZone) { |
48 this(river, dischargeZone, null); | 45 this(dischargeZone, null); |
49 } | 46 } |
50 | 47 |
51 | 48 |
52 public FlowVelocityModel( | 49 public FlowVelocityModel( |
53 River river, | |
54 DischargeZone dischargeZone, | 50 DischargeZone dischargeZone, |
55 String description | 51 String description |
56 ) { | 52 ) { |
57 this.river = river; | |
58 this.dischargeZone = dischargeZone; | 53 this.dischargeZone = dischargeZone; |
59 this.description = description; | 54 this.description = description; |
60 } | 55 } |
61 | 56 |
62 @Id | 57 @Id |
75 public void setId(Integer id) { | 70 public void setId(Integer id) { |
76 this.id = id; | 71 this.id = id; |
77 } | 72 } |
78 | 73 |
79 @OneToOne | 74 @OneToOne |
80 @JoinColumn(name = "river_id") | |
81 public River getRiver() { | |
82 return river; | |
83 } | |
84 | |
85 public void setRiver(River river) { | |
86 this.river = river; | |
87 } | |
88 | |
89 @OneToOne | |
90 @JoinColumn(name = "discharge_zone_id") | 75 @JoinColumn(name = "discharge_zone_id") |
91 public DischargeZone getDischargeZone() { | 76 public DischargeZone getDischargeZone() { |
92 return dischargeZone; | 77 return dischargeZone; |
93 } | 78 } |
94 | 79 |
104 public void setDescription(String description) { | 89 public void setDescription(String description) { |
105 this.description = description; | 90 this.description = description; |
106 } | 91 } |
107 | 92 |
108 | 93 |
109 public static List<FlowVelocityModel> getModels( | 94 public static List<FlowVelocityModel> getModels(DischargeZone zone) { |
110 River river, | 95 |
111 DischargeZone zone | |
112 ) { | |
113 Session session = SessionHolder.HOLDER.get(); | 96 Session session = SessionHolder.HOLDER.get(); |
114 | 97 |
115 Query query = session.createQuery( | 98 Query query = session.createQuery( |
116 "from FlowVelocityModel where river=:river and dischargeZone=:zone"); | 99 "from FlowVelocityModel where dischargeZone=:zone"); |
117 | 100 |
118 query.setParameter("river", river); | |
119 query.setParameter("zone", zone); | 101 query.setParameter("zone", zone); |
120 | 102 |
121 return query.list(); | 103 return query.list(); |
122 } | 104 } |
123 } | 105 } |