Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java @ 2875:444e52222941
Added lower and upper km to functions that return bed height singles and epochs for a given river.
flys-backend/trunk@4442 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 May 2012 12:31:26 +0000 |
parents | bcfdaa3a5bfc |
children | b9a99fcc78c3 |
comparison
equal
deleted
inserted
replaced
2874:3bca80af6918 | 2875:444e52222941 |
---|---|
1 package de.intevation.flys.model; | 1 package de.intevation.flys.model; |
2 | 2 |
3 import java.io.Serializable; | 3 import java.io.Serializable; |
4 | 4 |
5 import java.util.ArrayList; | |
5 import java.util.List; | 6 import java.util.List; |
6 | 7 |
7 import javax.persistence.Entity; | 8 import javax.persistence.Entity; |
8 import javax.persistence.Id; | 9 import javax.persistence.Id; |
9 import javax.persistence.Table; | 10 import javax.persistence.Table; |
221 public void setValues(List<BedHeightSingleValue> values) { | 222 public void setValues(List<BedHeightSingleValue> values) { |
222 this.values = values; | 223 this.values = values; |
223 } | 224 } |
224 | 225 |
225 | 226 |
226 public static List<BedHeightSingle> getBedHeightSingles(River river) { | 227 public static List<BedHeightSingle> getBedHeightSingles( |
228 River river, | |
229 double kmLo, | |
230 double kmHi | |
231 ) { | |
227 Session session = SessionHolder.HOLDER.get(); | 232 Session session = SessionHolder.HOLDER.get(); |
228 | 233 |
229 Query query = session.createQuery( | 234 Query query = session.createQuery( |
230 "from BedHeightSingle where river=:river"); | 235 "from BedHeightSingle where river=:river"); |
231 | 236 |
232 query.setParameter("river", river); | 237 query.setParameter("river", river); |
233 | 238 |
234 return query.list(); | 239 // TODO Do km range filtering in SQL statement |
240 | |
241 List<BedHeightSingle> singles = query.list(); | |
242 List<BedHeightSingle> good = new ArrayList<BedHeightSingle>(); | |
243 | |
244 for (BedHeightSingle s: singles) { | |
245 OUTER: | |
246 for (BedHeightSingleValue value: s.getValues()) { | |
247 double station = value.getStation().doubleValue(); | |
248 | |
249 if (station >= kmLo && station <= kmHi) { | |
250 good.add(s); | |
251 continue OUTER; | |
252 } | |
253 } | |
254 } | |
255 | |
256 return good; | |
235 } | 257 } |
236 | 258 |
237 | 259 |
238 public static BedHeightSingle getBedHeightSingleById(int id) { | 260 public static BedHeightSingle getBedHeightSingleById(int id) { |
239 Session session = SessionHolder.HOLDER.get(); | 261 Session session = SessionHolder.HOLDER.get(); |