Mercurial > dive4elements > river
comparison flys-backend/src/main/java/org/dive4elements/river/model/HydrBoundary.java @ 5828:dfb26b03b179
Moved directories to org.dive4elements.river
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 11:53:11 +0200 |
parents | flys-backend/src/main/java/de/intevation/flys/model/HydrBoundary.java@87dab419b924 |
children | 18619c1e7c2a |
comparison
equal
deleted
inserted
replaced
5827:e308d4ecd35a | 5828:dfb26b03b179 |
---|---|
1 package de.intevation.flys.model; | |
2 | |
3 import java.io.Serializable; | |
4 import java.util.List; | |
5 | |
6 import javax.persistence.Column; | |
7 import javax.persistence.Entity; | |
8 import javax.persistence.GeneratedValue; | |
9 import javax.persistence.GenerationType; | |
10 import javax.persistence.Id; | |
11 import javax.persistence.JoinColumn; | |
12 import javax.persistence.OneToOne; | |
13 import javax.persistence.Table; | |
14 import javax.persistence.SequenceGenerator; | |
15 | |
16 import org.hibernate.Session; | |
17 import org.hibernate.Query; | |
18 import org.hibernate.annotations.Type; | |
19 | |
20 import com.vividsolutions.jts.geom.MultiLineString; | |
21 | |
22 import de.intevation.flys.backend.SessionHolder; | |
23 | |
24 | |
25 @Entity | |
26 @Table(name = "hydr_boundaries") | |
27 public class HydrBoundary | |
28 implements Serializable | |
29 { | |
30 private Integer id; | |
31 private SectieKind sectie; | |
32 private SobekKind sobek; | |
33 private String name; | |
34 private River river; | |
35 private MultiLineString geom; | |
36 private BoundaryKind kind; | |
37 | |
38 public HydrBoundary() { | |
39 } | |
40 | |
41 | |
42 @Id | |
43 @SequenceGenerator( | |
44 name = "SEQUENCE_HYDR_BOUNDARIES_ID_SEQ", | |
45 sequenceName = "HYDR_BOUNDARIES_ID_SEQ", | |
46 allocationSize = 1) | |
47 @GeneratedValue( | |
48 strategy = GenerationType.SEQUENCE, | |
49 generator = "SEQUENCE_HYDR_BOUNDARIES_ID_SEQ") | |
50 @Column(name = "id") | |
51 public Integer getId() { | |
52 return id; | |
53 } | |
54 | |
55 | |
56 public void setId(Integer id) { | |
57 this.id = id; | |
58 } | |
59 | |
60 @OneToOne | |
61 @JoinColumn(name = "river_id") | |
62 public River getRiver() { | |
63 return river; | |
64 } | |
65 | |
66 | |
67 public void setRiver(River river) { | |
68 this.river = river; | |
69 } | |
70 | |
71 | |
72 @Column(name = "name") | |
73 public String getName() { | |
74 return name; | |
75 } | |
76 | |
77 | |
78 public void setName(String name) { | |
79 this.name = name; | |
80 } | |
81 | |
82 | |
83 @Column(name = "geom") | |
84 @Type(type = "org.hibernatespatial.GeometryUserType") | |
85 public MultiLineString getGeom() { | |
86 return geom; | |
87 } | |
88 | |
89 | |
90 public void setGeom(MultiLineString geom) { | |
91 this.geom = geom; | |
92 } | |
93 | |
94 public static List<HydrBoundary> getHydrBoundaries(int riverId, String name, int kindId) { | |
95 Session session = SessionHolder.HOLDER.get(); | |
96 | |
97 Query query = session.createQuery( | |
98 "from HydrBoundary where river.id =:river_id and name=:name" + | |
99 " and kind.id=:kind_id"); | |
100 query.setParameter("river_id", riverId); | |
101 query.setParameter("name", name); | |
102 query.setParameter("kind_id", kindId); | |
103 | |
104 return query.list(); | |
105 } | |
106 | |
107 public static List<HydrBoundary> getHydrBoundaries(int riverId, String name) { | |
108 Session session = SessionHolder.HOLDER.get(); | |
109 | |
110 Query query = session.createQuery( | |
111 "from HydrBoundary where river.id =:river_id and name=:name"); | |
112 query.setParameter("river_id", riverId); | |
113 query.setParameter("name", name); | |
114 | |
115 return query.list(); | |
116 } | |
117 | |
118 /** | |
119 * Get sectie. | |
120 * | |
121 * @return sectie as SectieKind. | |
122 */ | |
123 @OneToOne | |
124 @JoinColumn(name = "sectie") | |
125 public SectieKind getSectie() | |
126 { | |
127 return sectie; | |
128 } | |
129 | |
130 /** | |
131 * Set sectie. | |
132 * | |
133 * @param sectie the value to set. | |
134 */ | |
135 public void setSectie(SectieKind sectie) | |
136 { | |
137 this.sectie = sectie; | |
138 } | |
139 | |
140 /** | |
141 * Get sobek. | |
142 * | |
143 * @return sobek as SobekKind. | |
144 */ | |
145 @OneToOne | |
146 @JoinColumn(name = "sobek") | |
147 public SobekKind getSobek() | |
148 { | |
149 return sobek; | |
150 } | |
151 | |
152 /** | |
153 * Set sobek. | |
154 * | |
155 * @param sobek the value to set. | |
156 */ | |
157 public void setSobek(SobekKind sobek) | |
158 { | |
159 this.sobek = sobek; | |
160 } | |
161 | |
162 /** | |
163 * Get kind. | |
164 * | |
165 * @return kind as BoundaryKind. | |
166 */ | |
167 @OneToOne | |
168 @JoinColumn(name = "kind") | |
169 public BoundaryKind getKind() | |
170 { | |
171 return kind; | |
172 } | |
173 | |
174 /** | |
175 * Set kind. | |
176 * | |
177 * @param kind the value to set. | |
178 */ | |
179 public void setKind(BoundaryKind kind) | |
180 { | |
181 this.kind = kind; | |
182 } | |
183 } | |
184 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |