Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/River.java @ 764:e09f00ecb915
river model: Added method to find gauge by a position lying in its range.
flys-backend/trunk@2160 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 18 Jun 2011 20:13:31 +0000 |
parents | c19d4c643526 |
children | 5572d051347e |
comparison
equal
deleted
inserted
replaced
763:8076f6a689d0 | 764:e09f00ecb915 |
---|---|
114 query.setParameter("b", new BigDecimal(b)); | 114 query.setParameter("b", new BigDecimal(b)); |
115 | 115 |
116 return query.list(); | 116 return query.list(); |
117 } | 117 } |
118 | 118 |
119 public Gauge determineGaugeByPosition(double p) { | |
120 Session session = SessionHolder.HOLDER.get(); | |
121 Query query = session.createQuery( | |
122 "from Gauge where river=:river " + | |
123 "and :p between range.a and range.b"); | |
124 query.setParameter("river", this); | |
125 query.setParameter("p", new BigDecimal(p)); | |
126 List<Gauge> gauges = query.list(); | |
127 return gauges.isEmpty() ? null : gauges.get(0); | |
128 } | |
129 | |
119 public Gauge determineGaugeByStation(double a, double b) { | 130 public Gauge determineGaugeByStation(double a, double b) { |
120 | 131 |
121 if (a > b) { double t = a; a = b; b = t; } | 132 if (a > b) { double t = a; a = b; b = t; } |
122 | 133 |
123 Session session = SessionHolder.HOLDER.get(); | 134 Session session = SessionHolder.HOLDER.get(); |