Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java @ 290:a6f56ed9238b
Tagged RELEASE 2.3 of flys-client.
flys-client/tags/2.3@1930 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 17 May 2011 07:51:26 +0000 |
parents | 1e73d5a4859c |
children | ab8eb2f544f2 |
rev | line source |
---|---|
245
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import javax.xml.xpath.XPathConstants; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Element; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Node; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import org.w3c.dom.NodeList; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.common.utils.XMLUtils; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.httpclient.http.HttpClient; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.client.shared.exceptions.ServerException; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.client.services.WQInfoService; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.model.WQInfoObject; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.shared.model.WQInfoObjectImpl; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 /** |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 */ |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 public class WQInfoServiceImpl |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 extends RemoteServiceServlet |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 implements WQInfoService |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 public static final String ERROR_NO_WQINFO_FOUND = |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 "error_no_wqinfo_found"; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 public static final String XPATH_WQS = "art:service/art:mainvalues/art:mainvalue"; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 public WQInfoObject[] getWQInfo( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 String url, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 String locale, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 String river, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 double from, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 double to) |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 throws ServerException |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 System.out.println("WQInfoServiceImpl.getWQInfo"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 Document doc = XMLUtils.newDocument(); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 doc, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 ArtifactNamespaceContext.NAMESPACE_URI, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 Element mainvalues = ec.create("mainvalues"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 Element riverEl = ec.create("river"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 Element startEl = ec.create("start"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 Element endEl = ec.create("end"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 riverEl.setTextContent(river); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 startEl.setTextContent(Double.valueOf(from).toString()); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 endEl.setTextContent(Double.valueOf(to).toString()); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 mainvalues.appendChild(riverEl); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 mainvalues.appendChild(startEl); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 mainvalues.appendChild(endEl); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 doc.appendChild(mainvalues); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
73 HttpClient client = new HttpClientImpl(url, locale); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
75 try { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
76 Document result = client.callService(url, "mainvalues", doc); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
77 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
78 System.out.println("Extract wq info objects now."); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
79 WQInfoObject[] objects = extractWQInfoObjects(result); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
80 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
81 if (objects != null && objects.length > 0) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
82 return objects; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
83 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 catch (ConnectionException ce) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 System.err.println(ce.getLocalizedMessage()); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 throw new ServerException(ERROR_NO_WQINFO_FOUND); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 /** |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 * Extracts all wq info objects from <i>result</i> document. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 * @param result The document retrieved by the server. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 * @return a list of WQInfoObjects. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 */ |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 protected WQInfoObject[] extractWQInfoObjects(Document result) |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 throws ServerException |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 NodeList list = (NodeList) XMLUtils.xpath( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 result, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 XPATH_WQS, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 XPathConstants.NODESET, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
109 if (list == null || list.getLength() == 0) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 System.err.println("No wq info found."); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 throw new ServerException(ERROR_NO_WQINFO_FOUND); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 int num = list.getLength(); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 System.out.println("Response contains " + num + " objects."); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 List<WQInfoObject> objects = |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 new ArrayList<WQInfoObject>(num); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 for (int i = 0; i < num; i++) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 WQInfoObject obj = buildWQInfoObject(list.item(i)); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 if (obj != null) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 objects.add(obj); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 System.out.println("Retrieved " + objects.size() + " wq values"); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 return (WQInfoObject[]) |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
132 objects.toArray(new WQInfoObject[num]); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 /** |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 * Extracts information for a single wq info object and intializes an |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
138 * WQInfoObject with them. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 * @param node The node that contains the information. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 * |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 * @return a valid WQInfoObject. |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 */ |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
144 protected WQInfoObject buildWQInfoObject(Node node) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 String name = XMLUtils.xpathString( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 node, "@name", ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 String type = XMLUtils.xpathString( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 node, "@type", ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
150 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
151 String value = XMLUtils.xpathString( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 node, "@value", ArtifactNamespaceContext.INSTANCE); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
153 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 if (name != null && type != null) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 try { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 return new WQInfoObjectImpl( |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 name, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
159 type, |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
160 new Double(value)); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
161 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 catch (NumberFormatException nfe) { |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
163 System.err.println(nfe.getLocalizedMessage()); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
164 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
167 System.err.println("Invalid wq info object found."); |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
168 |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
169 return null; |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
170 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
171 } |
1e73d5a4859c
Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
172 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |