Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 7185:963b8bd54a63
SedimentLoadFactory: Added method to quickly get the description of a given load.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 27 Sep 2013 14:36:05 +0200 |
parents | 73d7886fa59e |
children | 1dff8e71c4d6 |
comparison
equal
deleted
inserted
replaced
7184:73d7886fa59e | 7185:963b8bd54a63 |
---|---|
51 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + | 51 " JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " + |
52 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + | 52 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + |
53 " WHERE r.name = :name " + | 53 " WHERE r.name = :name " + |
54 " AND ti.stop_time IS NULL " + | 54 " AND ti.stop_time IS NULL " + |
55 " AND syv.station BETWEEN :startKm AND :endKm"; | 55 " AND syv.station BETWEEN :startKm AND :endKm"; |
56 | |
57 /** Query to get description of single sediment_yield. */ | |
58 public static final String SQL_SELECT_SINGLE_BY_ID = | |
59 "SELECT DISTINCT " + | |
60 " sy.description AS description " + | |
61 " FROM sediment_yield sy " + | |
62 " WHERE sy.id = :id "; | |
56 | 63 |
57 /** Query to get description, name and time range for official | 64 /** Query to get description, name and time range for official |
58 * epoch-type sediment yields. */ | 65 * epoch-type sediment yields. */ |
59 public static final String SQL_SELECT_OFFEPOCHS = | 66 public static final String SQL_SELECT_OFFEPOCHS = |
60 "SELECT DISTINCT " + | 67 "SELECT DISTINCT " + |
267 element = new Element(key, values); | 274 element = new Element(key, values); |
268 cache.put(element); | 275 cache.put(element); |
269 } | 276 } |
270 return values; | 277 return values; |
271 } | 278 } |
279 | |
280 /** | |
281 * Get sediment load description. | |
282 * @param id the sediment yield by id. | |
283 * @return sediment yields description | |
284 */ | |
285 public static String getSedimentYieldDescription(int id) { | |
286 log.debug("SedimentLoadFactory.getSedimentYieldDescription"); | |
287 | |
288 Session session = SessionHolder.HOLDER.get(); | |
289 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_BY_ID) | |
290 .addScalar("description", StandardBasicTypes.STRING); | |
291 sqlQuery.setDouble("id", id); | |
292 | |
293 List<Object> results = sqlQuery.list(); | |
294 | |
295 return (String) results.get(0); | |
296 | |
297 } | |
298 | |
272 | 299 |
273 /** | 300 /** |
274 * Get sediment loads from db. | 301 * Get sediment loads from db. |
275 * @param river the river | 302 * @param river the river |
276 * @param type the sediment load type (year or epoch) | 303 * @param type the sediment load type (year or epoch) |