Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MainValuesService.java @ 3114:6c91e05a5f51
Fix issue681.
flys-artifacts/trunk@4713 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 19 Jun 2012 21:51:11 +0000 |
parents | ad54896ec369 |
children | d03e65378b9f |
rev | line source |
---|---|
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
|
1 package de.intevation.flys.artifacts.services; |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 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
|
4 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 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
|
6 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 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
|
8 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
|
9 |
5a2df8677b3e
Added a service 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 import de.intevation.artifacts.CallMeta; |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
11 import de.intevation.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
|
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 de.intevation.artifacts.common.ArtifactNamespaceContext; |
5a2df8677b3e
Added a service 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 import de.intevation.artifacts.common.utils.XMLUtils; |
5a2df8677b3e
Added a service 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 de.intevation.artifacts.common.utils.XMLUtils.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
|
16 |
5a2df8677b3e
Added a service 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 import de.intevation.flys.model.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
|
18 import de.intevation.flys.model.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
|
19 import de.intevation.flys.model.MainValueType; |
5a2df8677b3e
Added a service 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 import de.intevation.flys.model.NamedMainValue; |
5a2df8677b3e
Added a service 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 import de.intevation.flys.model.Range; |
5a2df8677b3e
Added a service 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 import de.intevation.flys.model.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
|
23 |
5a2df8677b3e
Added a service 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 import de.intevation.flys.artifacts.model.MainValuesFactory; |
5a2df8677b3e
Added a service 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 import de.intevation.flys.artifacts.model.RiverFactory; |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
5a2df8677b3e
Added a service 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 /** |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * 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
|
30 * 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
|
31 * |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 * @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
|
33 */ |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
34 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
|
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 /** 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
|
37 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
|
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 |
5a2df8677b3e
Added a service 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 /** 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
|
41 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
|
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 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
|
44 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
|
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 /** 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
|
47 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
|
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 * 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
|
51 */ |
5a2df8677b3e
Added a service 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 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
|
53 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
5a2df8677b3e
Added a service 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 |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
56 @Override |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
57 public Document doProcess( |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
58 Document data, |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
59 GlobalContext context, |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
60 CallMeta callMeta |
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
444
diff
changeset
|
61 ) { |
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
|
62 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
|
63 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 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
|
65 River river = getRequestedRiver(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
|
66 double[] minmax = getRequestedStartEnd(data, 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
|
67 Gauge gauge = river.determineGauge(minmax[0], minmax[1]); |
5a2df8677b3e
Added a service 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 |
1659
ad54896ec369
Write gauge determined in MainValuesService to log.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1631
diff
changeset
|
69 logger.debug("Found gauge: " + gauge.getName()); |
ad54896ec369
Write gauge determined in MainValuesService to log.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1631
diff
changeset
|
70 |
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 List<MainValue> mainValues = getMainValues(river, 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
|
72 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 return buildDocument(river, gauge, 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
|
74 } |
5a2df8677b3e
Added a service 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 catch (NullPointerException npe) { |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 logger.error("Could not process 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
|
77 logger.error(npe, npe); |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 return 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
|
80 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 /** |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 * 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
|
86 * 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
|
87 * 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
|
88 * |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 * @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
|
90 * |
5a2df8677b3e
Added a service 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 * @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
|
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 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
|
94 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
|
95 { |
5a2df8677b3e
Added a service 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 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
|
97 |
5a2df8677b3e
Added a service 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 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
|
99 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
|
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 if (riverStr == null || riverStr.trim().length() == 0) { |
5a2df8677b3e
Added a service 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 throw new NullPointerException("No river found in 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
|
103 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service 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 River river = RiverFactory.getRiver(riverStr); |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service 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 if (river == 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
|
108 throw new NullPointerException("No such river found: " + riverStr); |
5a2df8677b3e
Added a service 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 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 return 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
|
112 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 |
5a2df8677b3e
Added a service 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 * 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
|
117 * 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
|
118 * 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
|
119 * 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
|
120 * |
5a2df8677b3e
Added a service 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 * @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
|
122 * @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
|
123 * |
5a2df8677b3e
Added a service 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 * @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
|
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 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
|
127 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
|
128 |
5a2df8677b3e
Added a service 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 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
|
130 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
|
131 |
5a2df8677b3e
Added a service 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 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
|
133 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
|
134 |
5a2df8677b3e
Added a service 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 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
|
136 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
|
137 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
|
138 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 logger.debug("Found start: " + 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
|
140 logger.debug("Found end: " + 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
|
141 |
5a2df8677b3e
Added a service 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 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
|
143 } |
5a2df8677b3e
Added a service 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 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
|
145 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
|
146 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 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
|
148 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service 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 /** |
5a2df8677b3e
Added a service 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 * 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
|
154 * 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
|
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 * @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
|
157 * @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
|
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 * @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
|
160 * 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
|
161 */ |
5a2df8677b3e
Added a service 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 protected List<MainValue> getMainValues(River river, 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
|
163 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
|
164 { |
5a2df8677b3e
Added a service 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 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
|
166 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
|
167 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
|
168 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
|
169 } |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
171 List<MainValue> mainValues = MainValuesFactory.getMainValues(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
|
172 |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
173 if (mainValues == null || mainValues.isEmpty()) { |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
174 throw new NullPointerException("No 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
|
175 } |
1631
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
176 |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
177 logger.debug(mainValues.size() + " main values found."); |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
178 |
26e19cdaed5e
Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
966
diff
changeset
|
179 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
|
180 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 |
5a2df8677b3e
Added a service that returns the MainValues of a Gauge based on a river name and a stationing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 { |
5a2df8677b3e
Added a service 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 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
|
190 |
5a2df8677b3e
Added a service 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 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
|
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 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
|
194 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
|
195 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
|
196 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
|
197 |
5a2df8677b3e
Added a service 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 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
|
199 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
|
200 |
5a2df8677b3e
Added a service 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 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
|
202 |
5a2df8677b3e
Added a service 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 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
|
204 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
|
205 |
5a2df8677b3e
Added a service 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 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
|
207 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service 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 /** |
5a2df8677b3e
Added a service 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 * 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
|
212 * 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
|
213 * 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
|
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 * @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
|
216 * @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
|
217 * @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
|
218 * @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
|
219 */ |
5a2df8677b3e
Added a service 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 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 { |
5a2df8677b3e
Added a service 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 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
|
228 |
5a2df8677b3e
Added a service 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 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
|
230 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
|
231 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
|
232 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
|
233 |
5a2df8677b3e
Added a service 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 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
|
235 |
5a2df8677b3e
Added a service 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 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
|
237 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
|
238 |
5a2df8677b3e
Added a service 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 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
|
240 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
|
241 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
|
242 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
|
243 |
5a2df8677b3e
Added a service 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 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
|
245 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
|
246 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service 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 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
|
250 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
|
251 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
|
252 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
|
253 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
|
254 { |
5a2df8677b3e
Added a service 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 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
|
256 |
5a2df8677b3e
Added a service 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 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
|
258 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
|
259 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
|
260 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
|
261 |
5a2df8677b3e
Added a service 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 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
|
263 |
5a2df8677b3e
Added a service 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 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
|
265 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
|
266 |
5a2df8677b3e
Added a service 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 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
|
268 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
|
269 } |
5a2df8677b3e
Added a service 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 |
5a2df8677b3e
Added a service 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 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
|
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 /** |
5a2df8677b3e
Added a service 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 * 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
|
278 * 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
|
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 * @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
|
281 * @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
|
282 * @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
|
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 * @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
|
285 */ |
5a2df8677b3e
Added a service 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 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
|
287 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
|
288 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
|
289 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
|
290 { |
5a2df8677b3e
Added a service 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 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
|
292 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
|
293 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
|
294 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
|
295 |
5a2df8677b3e
Added a service 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 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
|
297 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
|
298 |
5a2df8677b3e
Added a service 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 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
|
300 |
5a2df8677b3e
Added a service 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 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
|
302 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
|
303 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
|
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 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
|
306 } |
5a2df8677b3e
Added a service 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 } |
5a2df8677b3e
Added a service 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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |