comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 2877:f0a67bc0e777 2.7

merged flys-backend/2.7
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:31 +0200
parents 61cb16549eb1
children 6b1ca6ec4e3c
comparison
equal deleted inserted replaced
2793:6310b1582f2d 2877:f0a67bc0e777
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.Id;
9 import javax.persistence.JoinColumn;
10 import javax.persistence.OneToOne;
11 import javax.persistence.Table;
12
13 import org.hibernate.Session;
14 import org.hibernate.Query;
15 import org.hibernate.annotations.Type;
16
17 import com.vividsolutions.jts.geom.LineString;
18
19 import de.intevation.flys.backend.SessionHolder;
20
21
22 /**
23 * There is a modeling problem with the RiverAxis. The initial idea was, that a
24 * river can have a riveraxis that consist of exact one geometry. Now, it has
25 * turned out, that a single geometry is not enough for a riveraxis (arm of a
26 * river, inflows, ...). As workaround, we now expect, that a river can just
27 * have a single riveraxis.
28 */
29 @Entity
30 @Table(name = "river_axes")
31 public class RiverAxis
32 implements Serializable
33 {
34 private Integer id;
35 private Integer kind;
36 private River river;
37 private LineString geom;
38
39 public RiverAxis() {
40 }
41
42
43 @Id
44 @Column(name = "id")
45 public Integer getId() {
46 return id;
47 }
48
49
50 public void setId(Integer id) {
51 this.id = id;
52 }
53
54
55 @OneToOne
56 @JoinColumn(name = "river_id")
57 public River getRiver() {
58 return river;
59 }
60
61
62 public void setRiver(River river) {
63 this.river = river;
64 }
65
66
67 @Column(name = "kind")
68 public Integer getKind() {
69 return kind;
70 }
71
72
73 public void setKind(Integer kind) {
74 this.kind = kind;
75 }
76
77
78 @Column(name = "geom")
79 @Type(type = "org.hibernatespatial.GeometryUserType")
80 public LineString getGeom() {
81 return geom;
82 }
83
84
85 public void setGeom(LineString geom) {
86 this.geom = geom;
87 }
88
89
90 public static List<RiverAxis> getRiverAxis(String river) {
91 Session session = SessionHolder.HOLDER.get();
92
93 Query query = session.createQuery(
94 "from RiverAxis where river.name =:river");
95 query.setParameter("river", river);
96
97 List<RiverAxis> list = query.list();
98
99 return list.isEmpty() ? null : list;
100 }
101 }
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org