Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/BedHeight.java @ 9245:f5cff8708531
bedheight datasource for salix.historical
author | gernotbelger |
---|---|
date | Wed, 11 Jul 2018 14:45:01 +0200 |
parents | 8642a76f22be |
children | c08d5cfa4981 |
comparison
equal
deleted
inserted
replaced
9244:b9505aa78cdd | 9245:f5cff8708531 |
---|---|
205 } | 205 } |
206 | 206 |
207 public static List<BedHeight> getBedHeights(final River river, final double kmLo, final double kmHi) { | 207 public static List<BedHeight> getBedHeights(final River river, final double kmLo, final double kmHi) { |
208 final Session session = SessionHolder.HOLDER.get(); | 208 final Session session = SessionHolder.HOLDER.get(); |
209 | 209 |
210 final Query query = session.createQuery("from BedHeight" | 210 final Query query = session.createQuery("from BedHeight" + " where river=:river" + " and id in (select bedHeight.id from BedHeightValue" |
211 + " where river=:river" | 211 + " where station between :kmfrom and :kmto" + " group by bedHeight.id)"); |
212 + " and id in (select bedHeight.id from BedHeightValue" | |
213 + " where station between :kmfrom and :kmto" | |
214 + " group by bedHeight.id)"); | |
215 | 212 |
216 query.setParameter("river", river); | 213 query.setParameter("river", river); |
217 query.setParameter("kmfrom", kmLo); | 214 query.setParameter("kmfrom", kmLo); |
218 query.setParameter("kmto", kmHi); | 215 query.setParameter("kmto", kmHi); |
219 | 216 |
236 | 233 |
237 public static BedHeight getBedHeightByDescription(final River river, final String description, final double startKm, final double endKm) { | 234 public static BedHeight getBedHeightByDescription(final River river, final String description, final double startKm, final double endKm) { |
238 | 235 |
239 final Session session = SessionHolder.HOLDER.get(); | 236 final Session session = SessionHolder.HOLDER.get(); |
240 | 237 |
241 final Query query = session.createQuery("FROM BedHeight" | 238 final Query query = session.createQuery("FROM BedHeight" + " WHERE (TRIM(description)=:description) AND river=:river" |
242 + " WHERE (TRIM(description)=:description) AND river=:river" | 239 + " AND id IN (SELECT bedHeight.id FROM BedHeightValue" + " WHERE station BETWEEN :kmfrom AND :kmto" + " GROUP BY bedHeight.id)"); |
243 + " AND id IN (SELECT bedHeight.id FROM BedHeightValue" | |
244 + " WHERE station BETWEEN :kmfrom AND :kmto" | |
245 + " GROUP BY bedHeight.id)"); | |
246 query.setParameter("river", river); | 240 query.setParameter("river", river); |
247 query.setParameter("description", description); | 241 query.setParameter("description", description); |
248 query.setParameter("kmfrom", startKm); | 242 query.setParameter("kmfrom", startKm); |
249 query.setParameter("kmto", endKm); | 243 query.setParameter("kmto", endKm); |
250 | 244 |
251 final List<BedHeight> singles = query.list(); | 245 final List<BedHeight> singles = query.list(); |
252 | 246 |
253 return ((singles != null) && !singles.isEmpty()) ? singles.get(0) : null; | 247 return ((singles != null) && !singles.isEmpty()) ? singles.get(0) : null; |
254 } | 248 } |
249 | |
250 public static List<BedHeight> getBedHeightEpochs(final River river, final double startKm, final double endKm) { | |
251 | |
252 final Session session = SessionHolder.HOLDER.get(); | |
253 final String description = "epoch"; | |
254 final Query query = session.createQuery("FROM BedHeight" + " WHERE lower(description) LIKE :description AND " + "river=:river" | |
255 + " AND id IN (SELECT bedHeight.id FROM BedHeightValue" + " WHERE station BETWEEN :kmfrom AND :kmto" + " GROUP BY bedHeight.id)"); | |
256 query.setParameter("river", river); | |
257 query.setParameter("description", "%" + description + "%"); | |
258 query.setParameter("kmfrom", startKm); | |
259 query.setParameter("kmto", endKm); | |
260 | |
261 final List<BedHeight> singles = query.list(); | |
262 | |
263 return ((singles != null) && !singles.isEmpty()) ? singles : null; | |
264 } | |
265 | |
266 public static List<BedHeight> getBedHeightYear(final River river, final double startKm, final double endKm) { | |
267 | |
268 final Session session = SessionHolder.HOLDER.get(); | |
269 final String description = "epoch"; | |
270 final Query query = session.createQuery("FROM BedHeight" + " WHERE lower(description) NOT LIKE :description AND " + "river=:river" | |
271 + " AND id IN (SELECT bedHeight.id FROM BedHeightValue" + " WHERE station BETWEEN :kmfrom AND :kmto" + " GROUP BY bedHeight.id)"); | |
272 query.setParameter("river", river); | |
273 query.setParameter("description", "%" + description + "%"); | |
274 query.setParameter("kmfrom", startKm); | |
275 query.setParameter("kmto", endKm); | |
276 | |
277 final List<BedHeight> singles = query.list(); | |
278 | |
279 return ((singles != null) && !singles.isEmpty()) ? singles : null; | |
280 } | |
255 } | 281 } |