diff 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
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java	Thu Mar 28 12:38:06 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java	Thu Mar 28 12:39:14 2013 +0100
@@ -13,6 +13,7 @@
 import org.hibernate.Query;
 import org.hibernate.Session;
 import org.hibernate.annotations.Type;
+import org.hibernate.HibernateException;
 
 import com.vividsolutions.jts.geom.Polygon;
 
@@ -32,6 +33,8 @@
 
     private Polygon        geom;
 
+    private String         name;
+
 
     public Floodplain() {
     }
@@ -77,6 +80,42 @@
         this.geom = geom;
     }
 
+    @Column(name = "name")
+    public String getName() {
+        return name;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public static List<Floodplain> getFloodplains(String river, String name, int kind)
+    throws HibernateException {
+        Session session = SessionHolder.HOLDER.get();
+        Query query = session.createQuery(
+            "from Floodplain as fp where river.name =:river" +
+            " and kind.id =:kind" +
+            " and fp.name=:name");
+        query.setParameter("river", river);
+        query.setParameter("kind", kind);
+        query.setParameter("name", name);
+
+        List<Floodplain> list = query.list();
+        return list.isEmpty() ? null : list;
+    }
+
+    public static List<Floodplain> getFloodplains(String river, int kind)
+    throws HibernateException {
+        Session session = SessionHolder.HOLDER.get();
+        Query query = session.createQuery(
+            "from Floodplain where river.name =:river AND kind.id =:kind");
+        query.setParameter("river", river);
+        query.setParameter("kind", kind);
+
+        List<Floodplain> list = query.list();
+        return list.isEmpty() ? null : list;
+    }
 
     public static Floodplain getFloodplain(String river) {
         Session session = SessionHolder.HOLDER.get();

http://dive4elements.wald.intevation.org