annotate flys-client/src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java @ 2526:a911e2968cb1

Changed some data types in states and filter and added new preprocessing state to ui provider factory. flys-client/trunk@4415 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 15 May 2012 15:33:43 +0000
parents 87ac5c532523
children 256b458cc7ea
rev   line source
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
3 import java.util.List;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
4 import java.util.ArrayList;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
5
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
6 import org.w3c.dom.Document;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
7 import org.w3c.dom.Node;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
8 import org.w3c.dom.NodeList;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
9
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
10 import javax.xml.xpath.XPathConstants;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
11
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
14 import de.intevation.artifacts.common.utils.XMLUtils;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
15
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
16 import de.intevation.artifacts.common.utils.XSLTransformer;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
17
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
18 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
19
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
20 import de.intevation.artifacts.httpclient.http.HttpClient;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
21 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
22
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 import de.intevation.flys.client.client.services.FixingsOverviewService;
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.client.shared.exceptions.ServerException;
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
27 import de.intevation.flys.client.shared.model.FixingsOverviewInfo;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
28 import de.intevation.flys.client.shared.model.FixingsOverviewInfo.FixEvent;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
29 import de.intevation.flys.client.shared.model.FixingsOverviewInfo.Sector;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
30
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
31 import java.io.IOException;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
32 import java.io.InputStream;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
33
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
34 import org.apache.log4j.Logger;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
35
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public class FixingsOverviewServiceImpl
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 extends RemoteServiceServlet
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 implements FixingsOverviewService
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 {
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
40 private static final Logger log =
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
41 Logger.getLogger(FixingsOverviewServiceImpl.class);
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
42
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
43 public static final String SERVICE_NAME = "fixings-overview";
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
44
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
45 public static final String XSL_TRANSFORM =
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
46 "/WEB-INF/stylesheets/fixoverview2html.xsl";
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
47
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
48 protected static final String XPATH_RID = "/fixings/river/@rid";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
49 protected static final String XPATH_RIVER = "/fixings/river/@name";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
50 protected static final String XPATH_RFROM = "/fixings/river/@from";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
51 protected static final String XPATH_RTO = "/fixings/river/@to";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
52
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
53 protected static final String XPATH_EVENT = "/fixings/events/event";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
54 protected static final String XPATH_SECTORS = "sector";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
55
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
56 protected static final String XPATH_CID = "@cid";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
57 protected static final String XPATH_DATE = "@date";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
58 protected static final String XPATH_NAME = "@name";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
59 protected static final String XPATH_CLS = "@class";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
60 protected static final String XPATH_FROM = "@from";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
61 protected static final String XPATH_TO = "@to";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
62
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
64 public FixingsOverviewInfo generateOverview(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
65 String locale,
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 String uuid,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
67 String filter,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
68 boolean checkboxes,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
69 String callback
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
70 )
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 throws ServerException
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 {
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
73 log.info("FixingsOverviewServiceImpl.doGet");
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
74
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
75 if (filter == null || filter.length() == 0) {
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
76 log.warn("Missing 'filter' parameter.");
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
77 return null;
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
78 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
79
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
80 Document filterDoc = XMLUtils.jsonToXML(filter);
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
81
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
82 if (filterDoc == null) {
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
83 log.warn("Creating filter document failed.");
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
84 return null;
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
85 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
86
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
87 /* filterDoc = XMLUtils.newDocument();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
88 ElementCreator ec = new ElementCreator(filterDoc, null, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
89 Element f = ec.create("fixings");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
90 Element r = ec.create("river");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
91 r.setAttribute("name", "Saar");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
92 f.appendChild(r);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
93 filterDoc.appendChild(f);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
94 */
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
95 try {
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
96 String url = getServletContext().getInitParameter("server-url");
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
97 HttpClient client = new HttpClientImpl(url, locale);
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
98 Document resultDoc =
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
99 client.callService(url, SERVICE_NAME, filterDoc);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
100 FixingsOverviewInfo i = getInfo(resultDoc, uuid, checkboxes, callback);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
101 return i;
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
102 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
103 catch (ConnectionException ce) {
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
104 log.error(ce);
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
105 }
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
106 return null;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
107 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
108
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
109
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
110 protected FixingsOverviewInfo getInfo(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
111 Document doc,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
112 String uuid,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
113 boolean checkboxes,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
114 String callback
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
115 ) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
116 InputStream transform =
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
117 getServletContext().getResourceAsStream(XSL_TRANSFORM);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
118 XSLTransformer xformer = new XSLTransformer();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
119 xformer.addParameter("project-uuid", uuid);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
120 xformer.addParameter(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
121 "render-checkboxes", checkboxes ? Boolean.TRUE : Boolean.FALSE);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
122 xformer.addParameter("callback", callback);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
123 String result = xformer.transform(doc, transform);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
124
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
125 try { transform.close(); }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
126 catch (IOException ioe) {}
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
127
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
128 int rid = -1;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
129 double from = -1;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
130 double to = -1;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
131 String rid_str = XMLUtils.xpathString(doc, XPATH_RID, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
132 String river = XMLUtils.xpathString(doc, XPATH_RIVER, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
133 String from_str = XMLUtils.xpathString(doc, XPATH_RFROM, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
134 String to_str = XMLUtils.xpathString(doc, XPATH_RTO, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
135 try {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
136 rid = Integer.valueOf(rid_str).intValue();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
137 from = Double.valueOf(from_str).doubleValue();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
138 to = Double.valueOf(to_str).doubleValue();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
139 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
140 catch(NumberFormatException nfe) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
141 log.warn(nfe, nfe);
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
142 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
143
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
144 List<FixEvent> fixEvents = getFixEvents(doc);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
145 return new FixingsOverviewInfo(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
146 rid,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
147 river,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
148 from,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
149 to,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
150 fixEvents,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
151 result);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
152 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
153
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
154
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
155 protected List<FixEvent> getFixEvents(Document doc) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
156 NodeList events = (NodeList) XMLUtils.xpath(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
157 doc,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
158 XPATH_EVENT,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
159 XPathConstants.NODESET,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
160 null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
161
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
162 if (events == null || events.getLength() == 0) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
163 log.warn("No events in Overview!");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
164 return null;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
165 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
166
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
167 List<FixEvent> list =
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
168 new ArrayList<FixEvent>();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
169 for (int i = 0; i < events.getLength(); i++) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
170 Node n = events.item(i);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
171 List<Sector> sectors = getSectors(n);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
172 String cid = XMLUtils.xpathString(n, XPATH_CID, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
173 log.debug("'" + cid + "'");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
174 String date = XMLUtils.xpathString(n, XPATH_DATE, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
175 String name = XMLUtils.xpathString(n, XPATH_NAME, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
176 list.add(new FixEvent(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
177 cid,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
178 date,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
179 name,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
180 sectors));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
181 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
182 return list;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
183 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
184
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
185 protected List<Sector> getSectors(Node event) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
186 NodeList sectors = (NodeList) XMLUtils.xpath(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
187 event,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
188 XPATH_SECTORS,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
189 XPathConstants.NODESET,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
190 null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
191 if (sectors == null || sectors.getLength() == 0) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
192 log.warn("No Sectors in Event!");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
193 return null;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
194 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
195
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
196 List<Sector> list =
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
197 new ArrayList<Sector>();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
198 for (int i = 0; i < sectors.getLength(); i++) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
199 Node n = sectors.item(i);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
200 int cls = -1;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
201 double from = -1;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
202 double to = -1;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
203 String cls_str = XMLUtils.xpathString(n, XPATH_CLS, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
204 String from_str = XMLUtils.xpathString(n, XPATH_FROM, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
205 String to_str = XMLUtils.xpathString(n, XPATH_TO, null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
206 try {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
207 cls = Integer.valueOf(cls_str).intValue();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
208 from = Double.valueOf(from_str).doubleValue();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
209 to = Double.valueOf(to_str).doubleValue();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
210 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
211 catch(NumberFormatException nfe) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
212 log.warn(nfe, nfe);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
213 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
214 list.add(new Sector(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
215 cls,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
216 from,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
217 to));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
218 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
219 return list;
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220 }
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221 }
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org