comparison flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 2375:61cb16549eb1

Modified the signature of RiverAxis.getRiverAxis() which now returns a list of RiverAxis objects instead of a single instance. flys-backend/trunk@3592 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 05 Jan 2012 10:42:20 +0000
parents 22eea1c9e907
children 6b1ca6ec4e3c
comparison
equal deleted inserted replaced
2374:ab1e642e7c85 2375:61cb16549eb1
17 import com.vividsolutions.jts.geom.LineString; 17 import com.vividsolutions.jts.geom.LineString;
18 18
19 import de.intevation.flys.backend.SessionHolder; 19 import de.intevation.flys.backend.SessionHolder;
20 20
21 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 */
22 @Entity 29 @Entity
23 @Table(name = "river_axes") 30 @Table(name = "river_axes")
24 public class RiverAxis 31 public class RiverAxis
25 implements Serializable 32 implements Serializable
26 { 33 {
78 public void setGeom(LineString geom) { 85 public void setGeom(LineString geom) {
79 this.geom = geom; 86 this.geom = geom;
80 } 87 }
81 88
82 89
83 public static RiverAxis getRiverAxis(String river) { 90 public static List<RiverAxis> getRiverAxis(String river) {
84 Session session = SessionHolder.HOLDER.get(); 91 Session session = SessionHolder.HOLDER.get();
85 92
86 Query query = session.createQuery( 93 Query query = session.createQuery(
87 "from RiverAxis where river.name =:river"); 94 "from RiverAxis where river.name =:river");
88 query.setParameter("river", river); 95 query.setParameter("river", river);
89 96
90 List<RiverAxis> list = query.list(); 97 List<RiverAxis> list = query.list();
91 98
92 return list.isEmpty() ? null : list.get(0); 99 return list.isEmpty() ? null : list;
93 } 100 }
94 } 101 }
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org