changeset 6857:d5d717effa06

(issue1347) Add measurement station getter for location
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 19 Aug 2013 11:34:47 +0200
parents fbbba09ac6a8
children b5e2d18cc341
files backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java	Mon Aug 19 10:35:27 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java	Mon Aug 19 11:34:47 2013 +0200
@@ -8,6 +8,8 @@
 
 package org.dive4elements.river.model;
 
+import java.util.List;
+
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -18,6 +20,10 @@
 import javax.persistence.SequenceGenerator;
 import javax.persistence.Table;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import org.dive4elements.river.backend.SessionHolder;
 
 @Entity
 @Table(name = "measurement_station")
@@ -176,4 +182,17 @@
     public void setDescription(String description) {
         this.description = description;
     }
+
+    public static List<MeasurementStation> getStationsAtKM(String river, Double river_km)
+    {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from MeasurementStation as ms " +
+            "where ms.river.name = :river_name and ms.station = :river_km");
+        query.setParameter("river_name", river);
+        query.setParameter("river_km", river_km);
+
+        return query.list();
+    }
 }

http://dive4elements.wald.intevation.org