Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/Gauge.java @ 9633:b0520a85739d
Nachtrag Pos. 19: query for most recent discharge table added
author | mschaefer |
---|---|
date | Thu, 17 Oct 2019 16:48:03 +0200 |
parents | bc9a45d2b1fa |
children |
comparison
equal
deleted
inserted
replaced
9632:9c07a33c2d62 | 9633:b0520a85739d |
---|---|
241 | 241 |
242 return results.isEmpty() ? null : (DischargeTable) results.get(0); | 242 return results.isEmpty() ? null : (DischargeTable) results.get(0); |
243 } | 243 } |
244 | 244 |
245 /** | 245 /** |
246 * Fetches from the database the most recent discharge table | |
247 */ | |
248 public DischargeTable fetchRecentDischargeTable() { | |
249 final Session session = SessionHolder.HOLDER.get(); | |
250 | |
251 final Query query = session.createQuery("FROM DischargeTable" // | |
252 + " WHERE (gauge = :gauge)" // | |
253 + " ORDER BY timeInterval.startTime DESC"); | |
254 | |
255 query.setParameter("gauge", this); | |
256 | |
257 final List<Object> results = query.list(); | |
258 | |
259 return results.isEmpty() ? null : (DischargeTable) results.get(0); | |
260 } | |
261 | |
262 /** | |
246 * Returns an array of [days, qs] necessary to create duration curves. | 263 * Returns an array of [days, qs] necessary to create duration curves. |
247 * | 264 * |
248 * @return a 2dim array of [days, qs] where days is an int[] and qs is | 265 * @return a 2dim array of [days, qs] where days is an int[] and qs is |
249 * an double[]. | 266 * an double[]. |
250 */ | 267 */ |
251 public Object[] fetchDurationCurveData() { | 268 public Object[] fetchDurationCurveData() { |
252 final Session session = SessionHolder.HOLDER.get(); | 269 final Session session = SessionHolder.HOLDER.get(); |
253 | 270 |
254 final Query query = session.createQuery("select cast(nmv.name as integer) as days, mv.value as q " + "from MainValue as mv " | 271 final Query query = session.createQuery("select cast(nmv.name as integer) as days, mv.value as q " // |
255 + "join mv.mainValue as nmv " + "join nmv.type mvt " + "where mvt.name = 'D' and mv.gauge.id = :gauge_id " + "order by days"); | 272 + "from MainValue as mv " // |
273 + "join mv.mainValue as nmv " // | |
274 + "join nmv.type mvt " // | |
275 + "where mvt.name = 'D' and mv.gauge.id = :gauge_id " + "order by days"); | |
256 | 276 |
257 query.setParameter("gauge_id", getId()); | 277 query.setParameter("gauge_id", getId()); |
258 | 278 |
259 final List<Object> results = query.list(); | 279 final List<Object> results = query.list(); |
260 final int[] days = new int[results.size()]; | 280 final int[] days = new int[results.size()]; |