comparison backend/src/main/java/org/dive4elements/river/model/MeasurementStation.java @ 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 4c3ccf2b0304
children 17db08570637
comparison
equal deleted inserted replaced
6856:fbbba09ac6a8 6857:d5d717effa06
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the 5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.model; 9 package org.dive4elements.river.model;
10
11 import java.util.List;
10 12
11 import javax.persistence.Column; 13 import javax.persistence.Column;
12 import javax.persistence.Entity; 14 import javax.persistence.Entity;
13 import javax.persistence.GeneratedValue; 15 import javax.persistence.GeneratedValue;
14 import javax.persistence.GenerationType; 16 import javax.persistence.GenerationType;
16 import javax.persistence.JoinColumn; 18 import javax.persistence.JoinColumn;
17 import javax.persistence.OneToOne; 19 import javax.persistence.OneToOne;
18 import javax.persistence.SequenceGenerator; 20 import javax.persistence.SequenceGenerator;
19 import javax.persistence.Table; 21 import javax.persistence.Table;
20 22
23 import org.hibernate.Session;
24 import org.hibernate.Query;
25
26 import org.dive4elements.river.backend.SessionHolder;
21 27
22 @Entity 28 @Entity
23 @Table(name = "measurement_station") 29 @Table(name = "measurement_station")
24 public class MeasurementStation { 30 public class MeasurementStation {
25 31
174 } 180 }
175 181
176 public void setDescription(String description) { 182 public void setDescription(String description) {
177 this.description = description; 183 this.description = description;
178 } 184 }
185
186 public static List<MeasurementStation> getStationsAtKM(String river, Double river_km)
187 {
188 Session session = SessionHolder.HOLDER.get();
189
190 Query query = session.createQuery(
191 "from MeasurementStation as ms " +
192 "where ms.river.name = :river_name and ms.station = :river_km");
193 query.setParameter("river_name", river);
194 query.setParameter("river_km", river_km);
195
196 return query.list();
197 }
179 } 198 }

http://dive4elements.wald.intevation.org