Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/model/Wst.java @ 2794:3c26e16ae6c2
Fix or workaround flys/issue632, avoid NPE.
flys-backend/trunk@4112 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Mar 2012 12:15:40 +0000 |
parents | ab1e642e7c85 |
children | c41bb1293acb |
comparison
equal
deleted
inserted
replaced
2425:67f362883fe4 | 2794:3c26e16ae6c2 |
---|---|
40 private List<WstColumn> columns; | 40 private List<WstColumn> columns; |
41 | 41 |
42 | 42 |
43 public static final String SQL_SELECT_MINMAX = | 43 public static final String SQL_SELECT_MINMAX = |
44 "select min(q) as minQ, max(q) as maxQ from wst_q_values " + | 44 "select min(q) as minQ, max(q) as maxQ from wst_q_values " + |
45 "where wst_id = :wst and not (a > :km or b < :km)"; | 45 "where wst_id = :wst and not (a > :km or b < :km)"; |
46 | 46 |
47 public Wst() { | 47 public Wst() { |
48 } | 48 } |
49 | 49 |
50 public Wst(River river, String description) { | 50 public Wst(River river, String description) { |
195 sqlQuery.setInteger("wst", getId()); | 195 sqlQuery.setInteger("wst", getId()); |
196 sqlQuery.setDouble("km", km); | 196 sqlQuery.setDouble("km", km); |
197 | 197 |
198 List<Object[]> minmaxQ = sqlQuery.list(); | 198 List<Object[]> minmaxQ = sqlQuery.list(); |
199 | 199 |
200 | |
200 if (minmaxQ.isEmpty()) { | 201 if (minmaxQ.isEmpty()) { |
201 return null; | 202 return null; |
202 } | 203 } |
203 | 204 |
204 Object[] mm = minmaxQ.get(0); | 205 Object[] mm = minmaxQ.get(0); |
205 | 206 |
207 if (mm[0] == null || mm[1] == null) { | |
208 logger.warning ("No min/max Q for km " + km + " found."); | |
209 return null; | |
210 } | |
211 | |
206 return new double[] { (Double) mm[0], (Double) mm[1] }; | 212 return new double[] { (Double) mm[0], (Double) mm[1] }; |
207 } | 213 } |
208 } | 214 } |
209 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 215 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |