comparison flys-backend/src/main/java/de/intevation/flys/model/FlowVelocityModel.java @ 3471:e4250c6e1538 2.8.1

merged flys-backend/2.8.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:40 +0200
parents 5a89c2b05e6d
children c7ce7c9e405e
comparison
equal deleted inserted replaced
3468:f37e7e8907cb 3471:e4250c6e1538
1 package de.intevation.flys.model;
2
3 import java.io.Serializable;
4 import java.util.List;
5
6 import javax.persistence.Entity;
7 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.OneToOne;
15
16 import org.hibernate.Session;
17 import org.hibernate.Query;
18
19 import org.apache.log4j.Logger;
20
21 import de.intevation.flys.backend.SessionHolder;
22
23
24 @Entity
25 @Table(name = "flow_velocity_model")
26 public class FlowVelocityModel
27 implements Serializable
28 {
29 private static Logger logger = Logger.getLogger(FlowVelocityModel.class);
30
31
32 private Integer id;
33
34 private River river;
35
36 private DischargeZone dischargeZone;
37
38 private List<FlowVelocityModelValue> values;
39
40 private String description;
41
42
43 public FlowVelocityModel() {
44 }
45
46
47 public FlowVelocityModel(River river, DischargeZone dischargeZone) {
48 this(river, dischargeZone, null);
49 }
50
51
52 public FlowVelocityModel(
53 River river,
54 DischargeZone dischargeZone,
55 String description
56 ) {
57 this.river = river;
58 this.dischargeZone = dischargeZone;
59 this.description = description;
60 }
61
62 @Id
63 @SequenceGenerator(
64 name = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ",
65 sequenceName = "FLOW_VELOCITY_MODEL_ID_SEQ",
66 allocationSize = 1)
67 @GeneratedValue(
68 strategy = GenerationType.SEQUENCE,
69 generator = "SEQUENCE_FLOW_VELOCITY_MODEL_ID_SEQ")
70 @Column(name = "id")
71 public Integer getId() {
72 return id;
73 }
74
75 public void setId(Integer id) {
76 this.id = id;
77 }
78
79 @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")
91 public DischargeZone getDischargeZone() {
92 return dischargeZone;
93 }
94
95 public void setDischargeZone(DischargeZone dischargeZone) {
96 this.dischargeZone = dischargeZone;
97 }
98
99 @Column(name = "description")
100 public String getDescription() {
101 return description;
102 }
103
104 public void setDescription(String description) {
105 this.description = description;
106 }
107
108
109 public static List<FlowVelocityModel> getModels(
110 River river,
111 DischargeZone zone
112 ) {
113 Session session = SessionHolder.HOLDER.get();
114
115 Query query = session.createQuery(
116 "from FlowVelocityModel where river=:river and dischargeZone=:zone");
117
118 query.setParameter("river", river);
119 query.setParameter("zone", zone);
120
121 return query.list();
122 }
123 }
124 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org