[PATCH 2 of 4] (issue1347) Add measurement station getter for location

Wald Commits scm-commit at wald.intevation.org
Mon Aug 19 11:41:38 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1376904887 -7200
# Node ID d5d717effa06db5f2f024ddcbd3fb2694dca4f55
# Parent  fbbba09ac6a802f4c98b5fe420bef38104c3af95
(issue1347) Add measurement station getter for location

diff -r fbbba09ac6a8 -r d5d717effa06 backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java
--- 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();
+    }
 }


More information about the Dive4elements-commits mailing list