Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/GaugeInfoService.java @ 3404:d7b065b88f10
Simplified code.
flys-artifacts/trunk@5056 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 09:11:56 +0000 |
parents | fb7975828ffa |
children | f1f798b5f14a |
rev | line source |
---|---|
2599
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.w3c.dom.Document; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Element; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.apache.log4j.Logger; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.common.utils.XMLUtils; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.CallMeta; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.GlobalContext; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.flys.model.Gauge; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.model.Range; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.model.River; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.artifacts.model.RiverFactory; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 /** |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 */ |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public class GaugeInfoService extends FLYSService { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 interface Filter { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 boolean apply(Gauge gauge); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 protected class ReferenceNumberFilter implements Filter { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 private long refNr; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 public ReferenceNumberFilter(long refNr) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 this.refNr = refNr; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 @Override |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 public boolean apply(Gauge gauge) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 logger.debug("Test gauge '" + gauge.getName() + "'"); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 if (gauge != null && gauge.getOfficialNumber() == refNr) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 return true; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 else { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 return false; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 } // end of ReferenceNumberFilter class |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 /** The logger that is used by this service.*/ |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 private static Logger logger = Logger.getLogger(GaugeInfoService.class); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 public static final String XPATH_RIVERNAME = "/art:river/@name"; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 public static final String XPATH_REFERENCE_NR |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 = "/art:river/art:filter/art:gauge/text()"; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 public GaugeInfoService() { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 @Override |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 public Document doProcess( |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 Document data, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 GlobalContext context, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 CallMeta callMeta |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 ) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 logger.debug("GaugeInfoService.process"); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 // XXX REMOVE THIS |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 logger.debug(XMLUtils.toString(data)); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 River river = getRiverFromRequest(data); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 List<Filter> filters = getFilters(data); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 List<Gauge> allGauges = river.getGauges(); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 List<Gauge> filtered = new ArrayList<Gauge>(); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 for (Gauge g: allGauges) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 for (Filter f: filters) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 if (f.apply(g)) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 filtered.add(g); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 return buildInfoDocument(filtered); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 protected River getRiverFromRequest(Document data) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 String rivername = XMLUtils.xpathString( |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 data, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 XPATH_RIVERNAME, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 ArtifactNamespaceContext.INSTANCE); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 logger.debug("Return Gauge info for River '" + rivername + "'"); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 return rivername != null ? RiverFactory.getRiver(rivername) : null; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 protected List<Filter> getFilters(Document data) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 List<Filter> filters = new ArrayList<Filter>(); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 String refNr = XMLUtils.xpathString( |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 data, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 XPATH_REFERENCE_NR, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 ArtifactNamespaceContext.INSTANCE); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 if (refNr != null && refNr.length() > 0) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 try { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 filters.add(new ReferenceNumberFilter(Long.valueOf(refNr))); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 catch (NumberFormatException nfe) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 logger.warn(nfe, nfe); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 return filters; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 protected Document buildInfoDocument(List<Gauge> gauges) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 Document doc = XMLUtils.newDocument(); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 ElementCreator cr = new ElementCreator( |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 doc, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 ArtifactNamespaceContext.NAMESPACE_URI, |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 Element service = cr.create("service"); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 logger.debug("Append " + gauges.size() + " gauges to info doc."); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 for (Gauge g: gauges) { |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 Range r = g.getRange(); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 Element el = cr.create("gauge"); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 cr.addAttr(el, "name", g.getName()); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 cr.addAttr(el, "lower", String.valueOf(r.getA().doubleValue())); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 cr.addAttr(el, "upper", String.valueOf(r.getB().doubleValue())); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 service.appendChild(el); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 doc.appendChild(service); |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 return doc; |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 } |
fb7975828ffa
#544 Added a service that allows querying gauge information.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |