annotate flys-client/src/main/java/de/intevation/flys/client/server/WQInfoServiceImpl.java @ 3807:d73c43798a99 pre2.6-2011-11-04

merged flys-backend/pre2.6-2011-11-04
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:51 +0200
parents ab8eb2f544f2
children bc06a671ef60
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
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
13 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
14
245
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 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
16
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import de.intevation.artifacts.common.ArtifactNamespaceContext;
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 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
19
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 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
21 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
22 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
23
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.exceptions.ServerException;
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 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
26 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
27 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
28
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29
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 * @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
32 */
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 public class WQInfoServiceImpl
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 extends RemoteServiceServlet
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 implements WQInfoService
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
37 private static final Logger logger =
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
38 Logger.getLogger(WQInfoServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
39
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
40
245
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 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
42 "error_no_wqinfo_found";
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 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
45
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 public WQInfoObject[] getWQInfo(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 String url,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 String locale,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 String river,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 double from,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 double to)
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 throws ServerException
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
55 logger.info("WQInfoServiceImpl.getWQInfo");
245
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 Document doc = XMLUtils.newDocument();
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 doc,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 ArtifactNamespaceContext.NAMESPACE_URI,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 ArtifactNamespaceContext.NAMESPACE_PREFIX);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 Element mainvalues = ec.create("mainvalues");
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 Element riverEl = ec.create("river");
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 Element startEl = ec.create("start");
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 Element endEl = ec.create("end");
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 riverEl.setTextContent(river);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 startEl.setTextContent(Double.valueOf(from).toString());
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 endEl.setTextContent(Double.valueOf(to).toString());
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 mainvalues.appendChild(riverEl);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 mainvalues.appendChild(startEl);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 mainvalues.appendChild(endEl);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 doc.appendChild(mainvalues);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 HttpClient client = new HttpClientImpl(url, locale);
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 try {
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 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
83
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
84 logger.debug("Extract wq info objects now.");
245
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 WQInfoObject[] objects = extractWQInfoObjects(result);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 if (objects != null && objects.length > 0) {
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 return objects;
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 }
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 catch (ConnectionException ce) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
92 logger.error(ce, ce);
245
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
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 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
96 }
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
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 * 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
101 *
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 * @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
103 *
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 * @return a list of WQInfoObjects.
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 */
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 protected WQInfoObject[] extractWQInfoObjects(Document result)
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 throws ServerException
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 NodeList list = (NodeList) XMLUtils.xpath(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 result,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 XPATH_WQS,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 XPathConstants.NODESET,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 ArtifactNamespaceContext.INSTANCE);
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 if (list == null || list.getLength() == 0) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
116 logger.warn("No wq info found.");
245
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 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
119 }
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 int num = list.getLength();
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
122 logger.debug("Response contains " + num + " objects.");
245
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 List<WQInfoObject> objects =
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 new ArrayList<WQInfoObject>(num);
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 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
128 WQInfoObject obj = buildWQInfoObject(list.item(i));
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 if (obj != null) {
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 objects.add(obj);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 }
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
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
135 logger.debug("Retrieved " + objects.size() + " wq values");
245
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 return (WQInfoObject[])
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 objects.toArray(new WQInfoObject[num]);
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
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 /**
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143 * 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
144 * WQInfoObject with them.
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 *
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 * @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
147 *
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 * @return a valid WQInfoObject.
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 */
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 protected WQInfoObject buildWQInfoObject(Node node) {
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 String name = XMLUtils.xpathString(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 node, "@name", 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 String type = XMLUtils.xpathString(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 node, "@type", ArtifactNamespaceContext.INSTANCE);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157 String value = XMLUtils.xpathString(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 node, "@value", ArtifactNamespaceContext.INSTANCE);
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 if (name != null && type != null) {
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 try {
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163 return new WQInfoObjectImpl(
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 name,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 type,
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 new Double(value));
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 }
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 catch (NumberFormatException nfe) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
169 logger.warn(nfe.getLocalizedMessage());
245
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
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 245
diff changeset
173 logger.warn("Invalid wq info object found.");
245
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 return null;
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 }
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 }
1e73d5a4859c Added new WQ info service and data structures.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org