Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-backend/src/main/java/org/dive4elements/river/model/FlowVelocityModel.java@18619c1e7c2a |
children | 4dd33b86dc61 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.model; | |
2 | |
3 import org.dive4elements.river.backend.SessionHolder; | |
4 | |
5 import java.io.Serializable; | |
6 | |
7 import java.util.List; | |
8 | |
9 import javax.persistence.Column; | |
10 import javax.persistence.Entity; | |
11 import javax.persistence.GeneratedValue; | |
12 import javax.persistence.GenerationType; | |
13 import javax.persistence.Id; | |
14 import javax.persistence.JoinColumn; | |
15 import javax.persistence.OneToOne; | |
16 import javax.persistence.SequenceGenerator; | |
17 import javax.persistence.Table; | |
18 | |
19 import org.apache.log4j.Logger; | |
20 | |
21 import org.hibernate.Query; | |
22 import org.hibernate.Session; | |
23 | |
24 | |
25 @Entity | |
26 @Table(name = "flow_velocity_model") | |
27 public class FlowVelocityModel | |
28 implements Serializable | |
29 { | |
30 private static Logger logger = Logger.getLogger(FlowVelocityModel.class); | |
31 | |
32 | |
33 private Integer id; | |
34 | |
35 private DischargeZone dischargeZone; | |
36 | |
37 private String description; | |
38 | |
39 | |
40 public FlowVelocityModel() { | |
41 } | |
42 | |
43 | |
44 public FlowVelocityModel(DischargeZone dischargeZone) { | |
45 this(dischargeZone, null); | |
46 } | |
47 | |
48 | |
49 public FlowVelocityModel( | |
50 DischargeZone dischargeZone, | |
51 String description | |
52 ) { | |
53 this.dischargeZone = dischargeZone; | |
54 this.description = description; | |
55 } | |
56 | |
57 @Id | |
58 @SequenceGenerator( | |
59 name = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ", | |
60 sequenceName = "FLOW_VELOCITY_MODEL_ID_SEQ", | |
61 allocationSize = 1) | |
62 @GeneratedValue( | |
63 strategy = GenerationType.SEQUENCE, | |
64 generator = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ") | |
65 @Column(name = "id") | |
66 public Integer getId() { | |
67 return id; | |
68 } | |
69 | |
70 public void setId(Integer id) { | |
71 this.id = id; | |
72 } | |
73 | |
74 @OneToOne | |
75 @JoinColumn(name = "discharge_zone_id") | |
76 public DischargeZone getDischargeZone() { | |
77 return dischargeZone; | |
78 } | |
79 | |
80 public void setDischargeZone(DischargeZone dischargeZone) { | |
81 this.dischargeZone = dischargeZone; | |
82 } | |
83 | |
84 @Column(name = "description") | |
85 public String getDescription() { | |
86 return description; | |
87 } | |
88 | |
89 public void setDescription(String description) { | |
90 this.description = description; | |
91 } | |
92 | |
93 | |
94 public static List<FlowVelocityModel> getModels(DischargeZone zone) { | |
95 | |
96 Session session = SessionHolder.HOLDER.get(); | |
97 | |
98 Query query = session.createQuery( | |
99 "from FlowVelocityModel where dischargeZone=:zone"); | |
100 | |
101 query.setParameter("zone", zone); | |
102 | |
103 return query.list(); | |
104 } | |
105 } | |
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |