annotate artifacts/src/main/java/org/dive4elements/river/artifacts/access/RiverAccess.java @ 8755:30b1ddadf275

(issue1801) Unify reference gauge finding code The basic way as described in the method comment of the determineRefGauge method is now used in the WINFOArtifact, MainValuesService and RiverUtils.getGauge method. RiverUtils.getGauge previously just returned the first gauge found. While this is now a behavior change I believe that it is always more correct then the undeterministic behavior of the previous implmenentation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 24 Jun 2015 14:07:26 +0200
parents e4606eae8ea5
children 8cc192731c7d 0a5239a1e46e
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: 5867
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: 5867
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: 4118
diff changeset
9 package org.dive4elements.river.artifacts.access;
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
11 import org.dive4elements.river.artifacts.D4EArtifact;
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
13 import org.dive4elements.river.artifacts.model.RiverFactory;
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
14
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
15 import org.dive4elements.river.model.River;
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
16
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import org.apache.log4j.Logger;
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
4118
116464587b51 Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3777
diff changeset
19 /** Access to river data of an artifact. */
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public class RiverAccess
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 extends Access
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7261
diff changeset
23 /** Private log. */
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 private static Logger log = Logger.getLogger(RiverAccess.class);
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
4118
116464587b51 Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3777
diff changeset
26 /** River name. */
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 protected String river;
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28
4118
116464587b51 Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3777
diff changeset
29
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 public RiverAccess() {
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 }
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
33 public RiverAccess(D4EArtifact artifact) {
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 super(artifact);
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 }
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36
4118
116464587b51 Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3777
diff changeset
37
116464587b51 Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3777
diff changeset
38 /** Get River name. */
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
39 public String getRiverName() {
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 if (river == null) {
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 river = getString("river");
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 }
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 if (log.isDebugEnabled()) {
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 log.debug("river: '" + river + "'");
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 return river;
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 }
7261
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
48
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
49 public River getRiver() {
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
50 getRiverName();
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
51
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
52 return (river != null)
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
53 ? RiverFactory.getRiver(river)
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
54 : null;
a56fe3bc6700 Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
55 }
3777
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 }
048a02e29808 Added base class RiverAccess to dense code to access the river name.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org