Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/FlowVelocityMeasurementFactory.java @ 6383:e26655a8f98d
SedimentLoadResult: Add getter for load.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 21 Jun 2013 11:42:35 +0200 |
parents | af13ceeba52a |
children | 602dac32a996 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4471
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.minfo; |
4463
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import java.util.List; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.Logger; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import org.hibernate.SQLQuery; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import org.hibernate.Session; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4471
diff
changeset
|
17 import org.dive4elements.river.model.FlowVelocityMeasurementValue; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4471
diff
changeset
|
18 import org.dive4elements.river.backend.SessionHolder; |
4463
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 public class FlowVelocityMeasurementFactory |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 { |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 /** Private logger to use here. */ |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 private static Logger log = Logger.getLogger(FlowVelocityMeasurementFactory.class); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 /** Query to get description and start year, given name and a km range. */ |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 public static final String SQL_SELECT_ONE = |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 "SELECT station, datetime, w, q, v, description " + |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 " FROM flow_velocity_measure_values" + |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 " WHERE id = :id"; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 private FlowVelocityMeasurementFactory() { |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 } |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 public static FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 getFlowVelocityMeasurement(int id) |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 { |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 log.debug("FlowVelocityMeasurementFactory.getFlowVelocityMeasurementValue"); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 Session session = SessionHolder.HOLDER.get(); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 SQLQuery sqlQuery = null; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 sqlQuery = session.createSQLQuery(SQL_SELECT_ONE); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 sqlQuery.setParameter("id", id); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 List<Object []> results = sqlQuery.list(); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 if (results.size() > 0) { |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 Object[] row = results.get(0); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 if (row == null || row.length < 6) { |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 return null; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 } |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 return FlowVelocityMeasurementValue.getUnmapped( |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 Double.parseDouble(row[0].toString()), |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 Double.parseDouble(row[2].toString()), |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 Double.valueOf(row[3].toString()), |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 Double.valueOf(row[4].toString()), null, row[5].toString()); |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 } |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 return null; |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 } |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 } |
3395f8c6b030
FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |