Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/FlowVelocityMeasurementFactory.java @ 5831:bd047b71ab37
Repaired internal references
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:06:39 +0200 |
parents | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/FlowVelocityMeasurementFactory.java@4e4226d99b49 |
children |
comparison
equal
deleted
inserted
replaced
5830:160f53ee0870 | 5831:bd047b71ab37 |
---|---|
1 package org.dive4elements.river.artifacts.model.minfo; | |
2 | |
3 import java.util.List; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 import org.hibernate.SQLQuery; | |
7 import org.hibernate.Session; | |
8 | |
9 import org.dive4elements.river.model.FlowVelocityMeasurementValue; | |
10 import org.dive4elements.river.backend.SessionHolder; | |
11 | |
12 | |
13 public class FlowVelocityMeasurementFactory | |
14 { | |
15 /** Private logger to use here. */ | |
16 private static Logger log = Logger.getLogger(FlowVelocityMeasurementFactory.class); | |
17 | |
18 /** Query to get description and start year, given name and a km range. */ | |
19 public static final String SQL_SELECT_ONE = | |
20 "SELECT station, datetime, w, q, v, description " + | |
21 " FROM flow_velocity_measure_values" + | |
22 " WHERE id = :id"; | |
23 | |
24 | |
25 private FlowVelocityMeasurementFactory() { | |
26 } | |
27 | |
28 | |
29 public static FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue | |
30 getFlowVelocityMeasurement(int id) | |
31 { | |
32 log.debug("FlowVelocityMeasurementFactory.getFlowVelocityMeasurementValue"); | |
33 Session session = SessionHolder.HOLDER.get(); | |
34 SQLQuery sqlQuery = null; | |
35 sqlQuery = session.createSQLQuery(SQL_SELECT_ONE); | |
36 sqlQuery.setParameter("id", id); | |
37 | |
38 List<Object []> results = sqlQuery.list(); | |
39 if (results.size() > 0) { | |
40 Object[] row = results.get(0); | |
41 if (row == null || row.length < 6) { | |
42 return null; | |
43 } | |
44 return FlowVelocityMeasurementValue.getUnmapped( | |
45 Double.parseDouble(row[0].toString()), | |
46 Double.parseDouble(row[2].toString()), | |
47 Double.valueOf(row[3].toString()), | |
48 Double.valueOf(row[4].toString()), null, row[5].toString()); | |
49 } | |
50 return null; | |
51 } | |
52 } | |
53 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |