changeset 2873:1894e0471eac

Added functions to retrieve bed height single and epoch values based on its owner and km range. flys-backend/trunk@4439 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 18 May 2012 11:30:26 +0000
parents bcfdaa3a5bfc
children 3bca80af6918
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpochValue.java flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingleValue.java
diffstat 3 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri May 18 07:01:47 2012 +0000
+++ b/flys-backend/ChangeLog	Fri May 18 11:30:26 2012 +0000
@@ -1,3 +1,10 @@
+2012-05-18  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/BedHeightSingleValue.java,
+	   src/main/java/de/intevation/flys/model/BedHeightEpochValue.java: Added
+	   functions to retrieve single and epoch values based on its owner and km
+	   range.
+
 2012-05-18  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/model/BedHeightEpoch.java,
--- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpochValue.java	Fri May 18 07:01:47 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightEpochValue.java	Fri May 18 11:30:26 2012 +0000
@@ -1,5 +1,7 @@
 package de.intevation.flys.model;
 
+import java.util.List;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 
@@ -15,6 +17,11 @@
 
 import org.apache.log4j.Logger;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import de.intevation.flys.backend.SessionHolder;
+
 
 @Entity
 @Table(name = "bed_height_epoch_values")
@@ -89,5 +96,24 @@
     public void setHeight(BigDecimal height) {
         this.height = height;
     }
+
+
+    public static List<BedHeightEpochValue> getBedHeightEpochValues(
+        BedHeightEpoch epoch,
+        double kmLo,
+        double kmHi
+    ) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from BedHeightEpochValue where bedHeight=:epoch " +
+            "   and station >= :kmLo and station <= :kmHi");
+
+        query.setParameter("epoch", epoch);
+        query.setParameter("kmLo", new BigDecimal(kmLo));
+        query.setParameter("kmHi", new BigDecimal(kmHi));
+
+        return query.list();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingleValue.java	Fri May 18 07:01:47 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingleValue.java	Fri May 18 11:30:26 2012 +0000
@@ -1,5 +1,7 @@
 package de.intevation.flys.model;
 
+import java.util.List;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 
@@ -15,6 +17,11 @@
 
 import org.apache.log4j.Logger;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import de.intevation.flys.backend.SessionHolder;
+
 
 @Entity
 @Table(name = "bed_height_single_values")
@@ -137,5 +144,24 @@
     public void setWidth(BigDecimal width) {
         this.width = width;
     }
+
+
+    public static List<BedHeightSingleValue> getBedHeightEpochValues(
+        BedHeightSingle single,
+        double kmLo,
+        double kmHi
+    ) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from BedHeightSingleValue where bedHeight=:single " +
+            "   and station >= :kmLo and station <= :kmHi");
+
+        query.setParameter("single", single);
+        query.setParameter("kmLo", new BigDecimal(kmLo));
+        query.setParameter("kmHi", new BigDecimal(kmHi));
+
+        return query.list();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org