changeset 2870:28526b0b0a90

Added DischargeZone.getDischargeZones() that returns all DischargeZones for a given river. flys-backend/trunk@4405 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 15 May 2012 07:06:31 +0000
parents e29781310140
children 5a89c2b05e6d
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/DischargeZone.java
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Thu May 10 11:52:37 2012 +0000
+++ b/flys-backend/ChangeLog	Tue May 15 07:06:31 2012 +0000
@@ -1,3 +1,9 @@
+2012-05-15  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/model/DischargeZone.java: Added a
+	  function getDischargeZones() that returns all DischargeZones for a given
+	  river.
+
 2012-05-10  Ingo Weinzierl <ingo@intevation.de>
 
 	* contrib/shpimporter/gauges.py: Search for field 'MPNAAM' and use its
--- a/flys-backend/src/main/java/de/intevation/flys/model/DischargeZone.java	Thu May 10 11:52:37 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/DischargeZone.java	Tue May 15 07:06:31 2012 +0000
@@ -2,6 +2,7 @@
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.List;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -13,8 +14,13 @@
 import javax.persistence.JoinColumn;
 import javax.persistence.OneToOne;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+
 import org.apache.log4j.Logger;
 
+import de.intevation.flys.backend.SessionHolder;
+
 
 @Entity
 @Table(name = "discharge_zone")
@@ -116,5 +122,17 @@
     public void setUpperDischarge(String upperDischarge) {
         this.upperDischarge = upperDischarge;
     }
+
+
+    public static List<DischargeZone> getDischargeZones(River river) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from DischargeZone where river=:river");
+
+        query.setParameter("river", river);
+
+        return query.list();
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org