annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/FlowVelocityMeasurementFactory.java @ 9726:0a5239a1e46e 3.2.x

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Wed, 02 Mar 2022 10:26:50 +0100
parents 5e38e2924c07
children
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
6944
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
11 import java.util.Date;
4463
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import java.util.List;
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
14 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
15 import org.apache.logging.log4j.LogManager;
4463
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import org.hibernate.SQLQuery;
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.hibernate.Session;
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
6944
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
19 import org.hibernate.type.StandardBasicTypes;
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4471
diff changeset
21 import org.dive4elements.river.model.FlowVelocityMeasurementValue;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4471
diff changeset
22 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
23
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 public class FlowVelocityMeasurementFactory
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6945
diff changeset
27 /** Private log to use here. */
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
28 private static Logger log = LogManager.getLogger(
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
29 FlowVelocityMeasurementFactory.class);
4463
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31 /** 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
32 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
33 "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
34 " 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
35 " WHERE id = :id";
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
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 private FlowVelocityMeasurementFactory() {
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
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 public static FlowVelocityMeasurementValue.FastFlowVelocityMeasurementValue
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 getFlowVelocityMeasurement(int id)
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 {
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 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
46 SQLQuery sqlQuery = null;
6944
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
47 sqlQuery = session.createSQLQuery(SQL_SELECT_ONE)
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
48 .addScalar("station", StandardBasicTypes.DOUBLE)
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
49 .addScalar("datetime", StandardBasicTypes.DATE)
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
50 .addScalar("w", StandardBasicTypes.DOUBLE)
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
51 .addScalar("q", StandardBasicTypes.DOUBLE)
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
52 .addScalar("v", StandardBasicTypes.DOUBLE)
602dac32a996 issue957: Better name for flowvelocity measured values facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
53 .addScalar("description", StandardBasicTypes.STRING);
4463
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 sqlQuery.setParameter("id", id);
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 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
57 if (results.size() > 0) {
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 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
59 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
60 return null;
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 }
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 return FlowVelocityMeasurementValue.getUnmapped(
6945
735346b3e438 Let hibernate do the parsing/casting.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6944
diff changeset
63 (Double) row[0],
735346b3e438 Let hibernate do the parsing/casting.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6944
diff changeset
64 (Double) row[2],
735346b3e438 Let hibernate do the parsing/casting.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6944
diff changeset
65 (Double) row[3],
735346b3e438 Let hibernate do the parsing/casting.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6944
diff changeset
66 (Double) row[4],
735346b3e438 Let hibernate do the parsing/casting.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6944
diff changeset
67 (Date) row[1],
735346b3e438 Let hibernate do the parsing/casting.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6944
diff changeset
68 (String) row[5]);
4463
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 }
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 return null;
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 }
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 }
3395f8c6b030 FlowVelocityMeasurementFactory: New, do the query to fetch measured flow velocities.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org