Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 8033:5e3f4b4fcb28
New way to loaded sediment loads from database and cache it. The data structure a way more straight forward. TODO: Implement calculation on this basis.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 15 Jul 2014 12:47:52 +0200 |
parents | 963ede7b32bb |
children | 5f28aa1be795 |
comparison
equal
deleted
inserted
replaced
8032:fd3a24336e6a | 8033:5e3f4b4fcb28 |
---|---|
241 } | 241 } |
242 | 242 |
243 SedimentLoadLSData[] values = | 243 SedimentLoadLSData[] values = |
244 getSedimentLoadsUncached(river, type, startKm, endKm); | 244 getSedimentLoadsUncached(river, type, startKm, endKm); |
245 | 245 |
246 if (values != null && key != null) { | 246 if (values != null) { |
247 log.debug("Store static sediment load values in cache."); | 247 log.debug("Store static sediment load values in cache."); |
248 element = new Element(key, values); | 248 element = new Element(key, values); |
249 cache.put(element); | 249 cache.put(element); |
250 } | 250 } |
251 return values; | 251 return values; |
294 startKm, | 294 startKm, |
295 endKm, | 295 endKm, |
296 syear, | 296 syear, |
297 eyear); | 297 eyear); |
298 | 298 |
299 if (values != null && key != null) { | 299 if (values != null) { |
300 log.debug("Store sediment loads in cache."); | 300 log.debug("Store sediment loads in cache."); |
301 element = new Element(key, values); | 301 element = new Element(key, values); |
302 cache.put(element); | 302 cache.put(element); |
303 } | 303 } |
304 return values; | 304 return values; |
314 | 314 |
315 Session session = SessionHolder.HOLDER.get(); | 315 Session session = SessionHolder.HOLDER.get(); |
316 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_TIMES_BY_ID) | 316 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_TIMES_BY_ID) |
317 .addScalar("starttime", StandardBasicTypes.DATE) | 317 .addScalar("starttime", StandardBasicTypes.DATE) |
318 .addScalar("stoptime", StandardBasicTypes.DATE); | 318 .addScalar("stoptime", StandardBasicTypes.DATE); |
319 sqlQuery.setDouble("id", id); | 319 sqlQuery.setInteger("id", id); |
320 | 320 |
321 List<Object[]> results = sqlQuery.list(); | 321 List<Object[]> results = sqlQuery.list(); |
322 Object[] row = results.get(0); | 322 Object[] row = results.get(0); |
323 | 323 |
324 return new Date[] {(Date)row[0], (Date) row[1]}; | 324 return new Date[] {(Date)row[0], (Date) row[1]}; |