Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java @ 9404:bc9a45d2b1fa
common time range for gauges incl. error messages
author | gernotbelger |
---|---|
date | Wed, 15 Aug 2018 13:59:09 +0200 |
parents | 82c67b859aa7 |
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:
5868
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:
5868
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:
3734
diff
changeset
|
9 package org.dive4elements.river.artifacts.services; |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.util.List; |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import org.apache.log4j.Logger; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
14 import org.dive4elements.artifacts.CallMeta; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
15 import org.dive4elements.artifacts.GlobalContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
16 import org.dive4elements.river.model.Gauge; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
17 import org.dive4elements.river.model.MainValue; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
18 import org.dive4elements.river.model.River; |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
19 import org.w3c.dom.Document; |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 /** |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 * This service returns the main values of a river's gauge based on the start |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * and end point of the river. |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 */ |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
27 public class MainValuesService extends AbstractMainValuesService { |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
29 private static final long serialVersionUID = 1L; |
7555
74e9768098a0
issue1542: Let MainValues have localized dates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
7553
diff
changeset
|
30 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
31 /** The log that is used by this service. */ |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
32 private static Logger log = Logger.getLogger(MainValuesService.class); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
34 @Override |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
35 public Document doProcess(final Document data, final GlobalContext context, final CallMeta callMeta) { |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
36 try { |
9404
bc9a45d2b1fa
common time range for gauges incl. error messages
gernotbelger
parents:
9288
diff
changeset
|
37 final River river = getRequestedRiver(data, "/art:mainvalues/art:river/text()"); |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
38 final Gauge gauge = getRequestedGauge(data, river); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
40 final List<MainValue> mainValues = getMainValues(river, gauge); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
42 return buildDocument(river, gauge, mainValues, context); |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
43 } |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
44 catch (final MainValuesServiceException e) { |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
45 e.printStackTrace(); |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
46 return error(e.getMessage()); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 /** |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * This method creates the result document that includes the main values of |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 * the specified <i>gauge</i>. |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 * |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
54 * @param river |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
55 * The river. |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
56 * @param gauge |
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
57 * The gauge. |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 * |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 * @return a document that includes the main values of the specified river |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
60 * at the specified gauge. |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 */ |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
62 protected List<MainValue> getMainValues(final River river, final Gauge gauge) { |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
63 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7639
diff
changeset
|
64 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7639
diff
changeset
|
65 log.debug("MainValuesService.buildMainValues"); |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7639
diff
changeset
|
66 log.debug("River: " + river.getName()); |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7639
diff
changeset
|
67 log.debug("Gauge: " + gauge.getName()); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
70 final List<MainValue> mainValues = gauge.getMainValues(); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7639
diff
changeset
|
72 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7639
diff
changeset
|
73 log.debug(mainValues.size() + " main values found."); |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
75 |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
76 return mainValues; |
331
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 } |
9288
82c67b859aa7
bundu.bezugswst worklflow incl. service impl for mainValues to be calculated
gernotbelger
parents:
8856
diff
changeset
|
78 } |