Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/services/MainValuesService.java @ 5863:4897a58c8746
River artifacts: Added new copyright headers.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 28 Apr 2013 14:40:59 +0200 |
parents | 5aa05a7a34b7 |
children | 35b2d86c3fb5 |
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 * |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
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 |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
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; |
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
|
14 |
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
|
15 import org.w3c.dom.Document; |
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
|
16 import org.w3c.dom.Element; |
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
|
17 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
18 import org.dive4elements.artifacts.CallMeta; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
19 import org.dive4elements.artifacts.GlobalContext; |
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 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
21 import org.dive4elements.artifacts.common.ArtifactNamespaceContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
22 import org.dive4elements.artifacts.common.utils.XMLUtils; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
23 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
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
|
24 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
25 import org.dive4elements.river.model.Gauge; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
26 import org.dive4elements.river.model.MainValue; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
27 import org.dive4elements.river.model.MainValueType; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
28 import org.dive4elements.river.model.NamedMainValue; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
29 import org.dive4elements.river.model.Range; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
30 import org.dive4elements.river.model.River; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
31 |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3734
diff
changeset
|
32 import org.dive4elements.river.artifacts.model.RiverFactory; |
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 |
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
|
34 |
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
|
35 /** |
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
|
36 * 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
|
37 * 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
|
38 * |
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 * @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
|
40 */ |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
41 public class MainValuesService extends FLYSService { |
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
|
42 |
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
|
43 /** The logger that is used by this service.*/ |
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
|
44 private static Logger logger = Logger.getLogger(MainValuesService.class); |
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
|
45 |
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
|
46 |
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 /** The XPath that points to the river definition of the incoming request.*/ |
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 public static final String XPATH_RIVER = "/art:mainvalues/art:river/text()"; |
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 /** The XPath that points to the start definition of the incoming request.*/ |
444
932a5e3c7fa1
ISSUE-72 Repaired broken XPath expression in MainValuesService to extract start and end kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
331
diff
changeset
|
51 public static final String XPATH_START = "/art:mainvalues/art:start/text()"; |
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
|
52 |
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 /** The XPath that points to the end definition of the incoming request.*/ |
444
932a5e3c7fa1
ISSUE-72 Repaired broken XPath expression in MainValuesService to extract start and end kilometer.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
331
diff
changeset
|
54 public static final String XPATH_END = "/art:mainvalues/art:end/text()"; |
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
|
55 |
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
|
56 /** |
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
|
57 * The default constructor. |
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 public MainValuesService() { |
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
|
60 } |
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 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
62 private static final Document error(String msg) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
63 logger.debug(msg); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
64 return XMLUtils.newDocument(); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
65 } |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
66 |
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
|
67 |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
68 @Override |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
69 public Document doProcess( |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
70 Document data, |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
71 GlobalContext context, |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
72 CallMeta callMeta |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
73 ) { |
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 logger.debug("MainValuesService.process"); |
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
|
75 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
76 River river = getRequestedRiver(data); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
77 if (river == null) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
78 return error("no river found."); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
79 } |
1659
ad54896ec369
Write gauge determined in MainValuesService to log.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1631
diff
changeset
|
80 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
81 double[] minmax = getRequestedStartEnd(data, river); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
82 Gauge gauge = river.determineGauge(minmax[0], minmax[1]); |
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
|
83 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
84 if (gauge == null) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
85 return error("no gauge 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
|
86 } |
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
|
87 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
88 List<MainValue> mainValues = getMainValues(river, gauge); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
89 |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
90 return buildDocument(river, gauge, mainValues, context); |
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
|
91 } |
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
|
92 |
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
|
93 |
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
|
94 /** |
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
|
95 * This method extracts the river from the incoming request. If no 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
|
96 * string was found or no river is found in the database based on this |
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
|
97 * string a NullPointerException is thrown. |
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
|
98 * |
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
|
99 * @param data The incoming request data. |
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
|
100 * |
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
|
101 * @return the River object. |
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
|
102 */ |
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
|
103 protected River getRequestedRiver(Document data) |
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
|
104 throws NullPointerException |
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
|
105 { |
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
|
106 logger.debug("MainValuesService.getRiver"); |
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
|
107 |
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
|
108 String riverStr = XMLUtils.xpathString( |
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
|
109 data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE); |
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
|
110 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
111 return riverStr != null && (riverStr = riverStr.trim()).length() > 0 |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
112 ? RiverFactory.getRiver(riverStr) |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
113 : null; |
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
|
114 } |
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
|
115 |
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
|
116 |
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
|
117 /** |
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
|
118 * This method extracts the start and end point from incoming request |
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
|
119 * document and returns both values in an array. If no start and end strings |
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
|
120 * are found in the document, the min/max values of the <i>river</i> are |
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
|
121 * returned. |
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
|
122 * |
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
|
123 * @param data The incoming request data. |
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
|
124 * @param river The river of the request. |
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
|
125 * |
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
|
126 * @return the start and end point. |
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
|
127 */ |
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
|
128 protected double[] getRequestedStartEnd(Document data, River 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
|
129 logger.debug("MainValuesService.getStartEnd"); |
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
|
130 |
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
|
131 String startStr = XMLUtils.xpathString( |
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
|
132 data, XPATH_START, ArtifactNamespaceContext.INSTANCE); |
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
|
133 |
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
|
134 String endStr = XMLUtils.xpathString( |
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
|
135 data, XPATH_END, ArtifactNamespaceContext.INSTANCE); |
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
|
136 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
137 if (startStr == null || endStr == null) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
138 return river.determineMinMaxDistance(); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
139 } |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
140 |
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
|
141 try { |
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
|
142 double start = Double.parseDouble(startStr); |
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
|
143 double end = Double.parseDouble(endStr); |
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
|
144 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
145 if (logger.isDebugEnabled()) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
146 logger.debug("Found start: " + start); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
147 logger.debug("Found end: " + end); |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
148 } |
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
|
149 |
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
|
150 return new double[] { start, end }; |
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
|
151 } |
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
|
152 catch (NumberFormatException nfe) { |
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
|
153 logger.warn(nfe, nfe); |
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
|
154 return river.determineMinMaxDistance(); |
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
|
155 } |
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
|
156 } |
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
|
157 |
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
|
158 |
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
|
159 /** |
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
|
160 * 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
|
161 * 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
|
162 * |
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
|
163 * @param river 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
|
164 * @param gauge The gauge. |
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
|
165 * |
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
|
166 * @return a document that includes the main values of the specified 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
|
167 * at the specified gauge. |
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
|
168 */ |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
169 protected List<MainValue> getMainValues(River river, Gauge gauge) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
170 |
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
|
171 if (logger.isDebugEnabled()) { |
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
|
172 logger.debug("MainValuesService.buildMainValues"); |
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
|
173 logger.debug("River: " + river.getName()); |
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
|
174 logger.debug("Gauge: " + gauge.getName()); |
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
|
175 } |
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
|
176 |
3734
0c217de0d84b
Modify every second theme to differ from default theme (#835)
Christian Lins <christian.lins@intevation.de>
parents:
3728
diff
changeset
|
177 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
|
178 |
3728
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
179 if (logger.isDebugEnabled()) { |
d03e65378b9f
Removed obsolete code. Removed NPE as regular flow control.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1659
diff
changeset
|
180 logger.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
|
181 } |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
182 |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
183 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
|
184 } |
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
|
185 |
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
|
186 |
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
|
187 protected Document buildDocument( |
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
|
188 River 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
|
189 Gauge gauge, |
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
|
190 List<MainValue> mainValues, |
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
|
191 Object context) |
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
|
192 { |
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
|
193 logger.debug("MainValuesService.buildDocument"); |
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
|
194 |
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
|
195 Document doc = XMLUtils.newDocument(); |
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
|
196 |
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
|
197 ElementCreator cr = new ElementCreator( |
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
|
198 doc, |
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
|
199 ArtifactNamespaceContext.NAMESPACE_URI, |
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
|
200 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
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
|
201 |
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
|
202 Element rootEl = cr.create("service"); |
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
|
203 cr.addAttr(rootEl, "name", "mainvalues"); |
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
|
204 |
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
|
205 doc.appendChild(rootEl); |
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
|
206 |
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
|
207 appendMetaInformation(doc, rootEl, river, gauge, context); |
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
|
208 appendMainValues(doc, rootEl, mainValues, context); |
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
|
209 |
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
|
210 return doc; |
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
|
211 } |
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
|
212 |
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
|
213 |
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
|
214 /** |
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
|
215 * This method appends some meta information to the result document. |
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
|
216 * Currently, the river's and gauge's names and the gauge's range are |
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
|
217 * appended. |
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
|
218 * |
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
|
219 * @param root The root element of the result document. |
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
|
220 * @param river 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
|
221 * @param gauge The gauge. |
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
|
222 * @param context The context object. |
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
|
223 */ |
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
|
224 protected void appendMetaInformation( |
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
|
225 Document doc, |
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
|
226 Element root, |
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
|
227 River 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
|
228 Gauge gauge, |
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
|
229 Object context) |
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
|
230 { |
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
|
231 logger.debug("MainValuesService.appendMetaInformation"); |
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
|
232 |
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
|
233 ElementCreator cr = new ElementCreator( |
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
|
234 doc, |
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
|
235 ArtifactNamespaceContext.NAMESPACE_URI, |
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
|
236 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
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
|
237 |
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
|
238 Range range = gauge.getRange(); |
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
|
239 |
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
|
240 Element riverEl = cr.create("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
|
241 cr.addAttr(riverEl, "name", river.getName()); |
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
|
242 |
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
|
243 Element gaugeEl = cr.create("gauge"); |
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
|
244 cr.addAttr(gaugeEl, "name", gauge.getName()); |
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
|
245 cr.addAttr(gaugeEl, "from", range.getA().toString()); |
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
|
246 cr.addAttr(gaugeEl, "to", range.getB().toString()); |
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
|
247 |
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
|
248 root.appendChild(riverEl); |
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
|
249 root.appendChild(gaugeEl); |
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
|
250 } |
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
|
251 |
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
|
252 |
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
|
253 protected void appendMainValues( |
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
|
254 Document doc, |
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
|
255 Element root, |
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
|
256 List<MainValue> mainValues, |
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
|
257 Object context) |
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
|
258 { |
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
|
259 logger.debug("MainValuesService.appendMainValues"); |
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
|
260 |
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
|
261 ElementCreator cr = new ElementCreator( |
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
|
262 doc, |
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
|
263 ArtifactNamespaceContext.NAMESPACE_URI, |
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
|
264 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
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
|
265 |
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
|
266 Element list = cr.create("mainvalues"); |
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
|
267 |
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
|
268 for (MainValue mainValue: mainValues) { |
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
|
269 Element newEl = buildMainValueElement(doc, mainValue, context); |
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
|
270 |
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
|
271 if (newEl != null) { |
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
|
272 list.appendChild(newEl); |
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
|
273 } |
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
|
274 } |
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
|
275 |
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
|
276 root.appendChild(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
|
277 } |
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
|
278 |
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
|
279 |
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
|
280 /** |
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
|
281 * This method builds a concrete mainvalue element. This element consists 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
|
282 * three attributes: the value, its name and its type. |
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
|
283 * |
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
|
284 * @param doc The owner document. |
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
|
285 * @param mainValue The mainvalue. |
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
|
286 * @param context The context object. |
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
|
287 * |
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
|
288 * @return a mainvalue element. |
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
|
289 */ |
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
|
290 protected Element buildMainValueElement( |
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
|
291 Document doc, |
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
|
292 MainValue mainValue, |
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
|
293 Object context) |
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
|
294 { |
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
|
295 ElementCreator cr = new ElementCreator( |
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
|
296 doc, |
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
|
297 ArtifactNamespaceContext.NAMESPACE_URI, |
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
|
298 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
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
|
299 |
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
|
300 NamedMainValue namedMainValue = mainValue.getMainValue(); |
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
|
301 MainValueType mainValueType = namedMainValue.getType(); |
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
|
302 |
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
|
303 Element el = cr.create("mainvalue"); |
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
|
304 |
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
|
305 cr.addAttr(el, "value", mainValue.getValue().toString()); |
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
|
306 cr.addAttr(el, "name", namedMainValue.getName()); |
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
|
307 cr.addAttr(el, "type", mainValueType.getName()); |
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
|
308 |
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
|
309 return el; |
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
|
310 } |
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
|
311 } |
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
|
312 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |