changeset 2875:444e52222941

Added lower and upper km to functions that return bed height singles and epochs for a given river. flys-backend/trunk@4442 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 18 May 2012 12:31:26 +0000
parents 3bca80af6918
children d3438e271b3c a938b214b303
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java
diffstat 3 files changed, 54 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri May 18 11:34:17 2012 +0000
+++ b/flys-backend/ChangeLog	Fri May 18 12:31:26 2012 +0000
@@ -1,3 +1,10 @@
+2012-05-18  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/BedHeightEpoch.java,
+	  src/main/java/de/intevation/flys/model/BedHeightSingle.java: Added lower
+	  and upper km to function that returns all singles and epochs for a given
+	  river.
+
 2012-05-18  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/model/BedHeightSingleValue.java: Fixed
--- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java	Fri May 18 11:34:17 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpoch.java	Fri May 18 12:31:26 2012 +0000
@@ -163,7 +163,11 @@
     }
 
 
-    public static List<BedHeightEpoch> getBedHeightEpochs(River river) {
+    public static List<BedHeightEpoch> getBedHeightEpochs(
+        River  river,
+        double kmLo,
+        double kmHi
+    ) {
         Session session = SessionHolder.HOLDER.get();
 
         Query query = session.createQuery(
@@ -171,7 +175,24 @@
 
         query.setParameter("river", river);
 
-        return query.list();
+        // TODO Do km range filtering in SQL statement
+
+        List<BedHeightEpoch> epochs = query.list();
+        List<BedHeightEpoch> good   = new ArrayList<BedHeightEpoch>();
+
+        for (BedHeightEpoch e: epochs) {
+            OUTER:
+            for (BedHeightEpochValue value: e.getValues()) {
+                double station = value.getStation().doubleValue();
+
+                if (station >= kmLo && station <= kmHi) {
+                    good.add(e);
+                    continue OUTER;
+                }
+            }
+        }
+
+        return good;
     }
 
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java	Fri May 18 11:34:17 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java	Fri May 18 12:31:26 2012 +0000
@@ -2,6 +2,7 @@
 
 import java.io.Serializable;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.persistence.Entity;
@@ -223,7 +224,11 @@
     }
 
 
-    public static List<BedHeightSingle> getBedHeightSingles(River river) {
+    public static List<BedHeightSingle> getBedHeightSingles(
+        River  river,
+        double kmLo,
+        double kmHi
+    ) {
         Session session = SessionHolder.HOLDER.get();
 
         Query query = session.createQuery(
@@ -231,7 +236,24 @@
 
         query.setParameter("river", river);
 
-        return query.list();
+        // TODO Do km range filtering in SQL statement
+
+        List<BedHeightSingle> singles = query.list();
+        List<BedHeightSingle> good    = new ArrayList<BedHeightSingle>();
+
+        for (BedHeightSingle s: singles) {
+            OUTER:
+            for (BedHeightSingleValue value: s.getValues()) {
+                double station = value.getStation().doubleValue();
+
+                if (station >= kmLo && station <= kmHi) {
+                    good.add(s);
+                    continue OUTER;
+                }
+            }
+        }
+
+        return good;
     }
 
 

http://dive4elements.wald.intevation.org