diff flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5477:ae60bb7b8085

Add proper handling of multiple river_axes for datacage and rivermapfile
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 27 Mar 2013 18:31:31 +0100
parents 9d36ddf7dbd3
children
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java	Wed Mar 27 17:49:46 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java	Wed Mar 27 18:31:31 2013 +0100
@@ -34,6 +34,7 @@
     private Integer    id;
     private AxisKind   kind;
     private River      river;
+    private String     name;
     private MultiLineString geom;
 
     public static final int KIND_UNKOWN = 0;
@@ -67,6 +68,15 @@
         this.river = river;
     }
 
+    @Column(name = "name")
+    public String getName() {
+        return name;
+    }
+
+
+    public void setName(String name) {
+        this.name = name;
+    }
 
     /**
      * Get kind.
@@ -106,6 +116,21 @@
         return getRiverAxis(river, KIND_CURRENT);
     }
 
+    public static List<RiverAxis> getRiverAxis(String river, String name, int kind)
+    throws HibernateException {
+        Session session = SessionHolder.HOLDER.get();
+        Query query = session.createQuery(
+            "from RiverAxis as ax where river.name =:river" +
+            " and kind.id =:kind" +
+            " and ax.name=:name");
+        query.setParameter("river", river);
+        query.setParameter("kind", kind);
+        query.setParameter("name", name);
+
+        List<RiverAxis> list = query.list();
+        return list.isEmpty() ? null : list;
+    }
+
     public static List<RiverAxis> getRiverAxis(String river, int kind)
     throws HibernateException {
         Session session = SessionHolder.HOLDER.get();

http://dive4elements.wald.intevation.org