diff flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java @ 5170:c1b60f8c3390

Made river mapfile generator more tolerant. * Ignores missing river axes. * Ignores invalid river axes. * Ignores invalid geometries.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 04 Mar 2013 17:11:31 +0100
parents d4fdd98a04f7
children 14d19313268a
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java	Mon Mar 04 17:08:14 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/RiverAxis.java	Mon Mar 04 17:11:31 2013 +0100
@@ -10,6 +10,7 @@
 import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
+import org.hibernate.HibernateException;
 import org.hibernate.Session;
 import org.hibernate.Query;
 import org.hibernate.annotations.Type;
@@ -100,21 +101,28 @@
     }
 
 
-    public static List<RiverAxis> getRiverAxis(String river) {
+    public static List<RiverAxis> getRiverAxis(String river)
+    throws RuntimeException {
         return getRiverAxis(river, KIND_CURRENT);
     }
 
-    public static List<RiverAxis> getRiverAxis(String river, int kind) {
+    public static List<RiverAxis> getRiverAxis(String river, int kind)
+    throws RuntimeException {
         Session session = SessionHolder.HOLDER.get();
-
         Query query = session.createQuery(
             "from RiverAxis where river.name =:river AND kind.id =:kind");
         query.setParameter("river", river);
         query.setParameter("kind", kind);
 
-        List<RiverAxis> list = query.list();
+        try {
+            List<RiverAxis> list = query.list();
+            return list.isEmpty() ? null : list;
+        }
+        catch (RuntimeException re) {
+            throw iae;
+        }
 
-        return list.isEmpty() ? null : list;
+
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org