Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java @ 5496:23d8f2700b38
Add support for multiple floodplains and add them to the datacage accordingly
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 28 Mar 2013 12:39:14 +0100 |
parents | 88e3473a3846 |
children |
comparison
equal
deleted
inserted
replaced
5495:1488227b97b7 | 5496:23d8f2700b38 |
---|---|
11 import javax.persistence.Table; | 11 import javax.persistence.Table; |
12 | 12 |
13 import org.hibernate.Query; | 13 import org.hibernate.Query; |
14 import org.hibernate.Session; | 14 import org.hibernate.Session; |
15 import org.hibernate.annotations.Type; | 15 import org.hibernate.annotations.Type; |
16 import org.hibernate.HibernateException; | |
16 | 17 |
17 import com.vividsolutions.jts.geom.Polygon; | 18 import com.vividsolutions.jts.geom.Polygon; |
18 | 19 |
19 import de.intevation.flys.backend.SessionHolder; | 20 import de.intevation.flys.backend.SessionHolder; |
20 | 21 |
29 private FloodplainKind kind; | 30 private FloodplainKind kind; |
30 | 31 |
31 private River river; | 32 private River river; |
32 | 33 |
33 private Polygon geom; | 34 private Polygon geom; |
35 | |
36 private String name; | |
34 | 37 |
35 | 38 |
36 public Floodplain() { | 39 public Floodplain() { |
37 } | 40 } |
38 | 41 |
75 | 78 |
76 public void setGeom(Polygon geom) { | 79 public void setGeom(Polygon geom) { |
77 this.geom = geom; | 80 this.geom = geom; |
78 } | 81 } |
79 | 82 |
83 @Column(name = "name") | |
84 public String getName() { | |
85 return name; | |
86 } | |
87 | |
88 | |
89 public void setName(String name) { | |
90 this.name = name; | |
91 } | |
92 | |
93 public static List<Floodplain> getFloodplains(String river, String name, int kind) | |
94 throws HibernateException { | |
95 Session session = SessionHolder.HOLDER.get(); | |
96 Query query = session.createQuery( | |
97 "from Floodplain as fp where river.name =:river" + | |
98 " and kind.id =:kind" + | |
99 " and fp.name=:name"); | |
100 query.setParameter("river", river); | |
101 query.setParameter("kind", kind); | |
102 query.setParameter("name", name); | |
103 | |
104 List<Floodplain> list = query.list(); | |
105 return list.isEmpty() ? null : list; | |
106 } | |
107 | |
108 public static List<Floodplain> getFloodplains(String river, int kind) | |
109 throws HibernateException { | |
110 Session session = SessionHolder.HOLDER.get(); | |
111 Query query = session.createQuery( | |
112 "from Floodplain where river.name =:river AND kind.id =:kind"); | |
113 query.setParameter("river", river); | |
114 query.setParameter("kind", kind); | |
115 | |
116 List<Floodplain> list = query.list(); | |
117 return list.isEmpty() ? null : list; | |
118 } | |
80 | 119 |
81 public static Floodplain getFloodplain(String river) { | 120 public static Floodplain getFloodplain(String river) { |
82 Session session = SessionHolder.HOLDER.get(); | 121 Session session = SessionHolder.HOLDER.get(); |
83 | 122 |
84 // kind_id 0 -> Offical | 123 // kind_id 0 -> Offical |