annotate flys-client/src/main/java/de/intevation/flys/client/server/FixingsOverviewServiceImpl.java @ 5641:ec53bdeaaf76

Doc.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 10 Apr 2013 09:29:34 +0200
parents 653dd9d7f5d5
children
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
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 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
4
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
5 import de.intevation.artifacts.common.utils.XMLUtils;
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
6 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
7
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
8 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
9
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
10 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
11 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
12
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 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
14
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15 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
16
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
17 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
18 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
19
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
20 import de.intevation.flys.client.shared.model.FixingsOverviewInfo;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
21
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
22 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
23 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
24
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
25 import java.util.ArrayList;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
26 import java.util.List;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
27
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
28 import javax.xml.xpath.XPathConstants;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
29
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
30 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
31
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
32 import org.w3c.dom.Document;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
33 import org.w3c.dom.Element;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
34 import org.w3c.dom.NodeList;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
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
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
55
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
57 public FixingsOverviewInfo generateOverview(
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
58 String locale,
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 String uuid,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
60 String filter,
3376
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
61 boolean checkboxes,
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
62 String callback
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
63 )
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 throws ServerException
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 {
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
66 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
67
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
68 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
69 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
70 return null;
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
71 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
72
2916
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
73 boolean debug = log.isDebugEnabled();
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
74
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
75 if (debug) {
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
76 log.debug("JSON filter: ------------------");
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
77 log.debug(filter);
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
78 }
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
79
2493
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
2916
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
87 if (debug) {
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
88 log.debug("XML filter: ------------------");
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
89 log.debug(XMLUtils.toString(filterDoc));
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
90 }
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
91
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
92 try {
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
93 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
94 HttpClient client = new HttpClientImpl(url, locale);
2921
96d02c6f44a2 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2916
diff changeset
95 Document resultDoc =
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
96 client.callService(url, SERVICE_NAME, filterDoc);
2916
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
97
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
98 if (debug) {
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
99 log.debug("Result XML: -----------");
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
100 log.debug(XMLUtils.toString(resultDoc));
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
101 }
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
102
3376
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
103 FixingsOverviewInfo i = getInfo(
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
104 locale, resultDoc, uuid, checkboxes, callback);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
105 return i;
2493
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
106 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
107 catch (ConnectionException ce) {
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
108 log.error(ce);
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
109 }
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
110 return null;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
111 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
112
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
113
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
114 protected FixingsOverviewInfo getInfo(
3376
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
115 String locale,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
116 Document doc,
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
117 String uuid,
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
118 boolean checkboxes,
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
119 String callback
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
120 ) {
3376
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
121 // TODO: Find a more general solution.
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
122 locale = locale == null || locale.toLowerCase().startsWith("de")
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
123 ? "de"
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
124 : "en";
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
125
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
126 InputStream transform = getServletContext()
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
127 .getResourceAsStream(XSL_TRANSFORM);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
128
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
129 if (transform == null) {
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
130 log.warn("transform not found");
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
131 return null;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
132 }
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
133
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
134 String result = null;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
135 try {
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
136 XSLTransformer xformer = new XSLTransformer();
3376
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
137 xformer.addParameter("locale", locale);
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
138 xformer.addParameter("project-uuid", uuid);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
139 xformer.addParameter(
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
140 "render-checkboxes",
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
141 checkboxes ? Boolean.TRUE : Boolean.FALSE);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
142 xformer.addParameter("callback", callback);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
143 result = xformer.transform(doc, transform);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
144 }
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
145 finally {
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
146 try { transform.close(); }
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
147 catch (IOException ioe) {}
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
148 }
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
149
2916
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
150 if (log.isDebugEnabled()) {
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
151 log.debug("--------------------------------------");
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
152 log.debug(result);
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
153 log.debug("--------------------------------------");
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
154 }
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
155
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
156 int rid = -1;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
157 double from = -1;
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
158 double to = -1;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
159
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
160 String rid_str = XMLUtils.xpathString(doc, XPATH_RID, null);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
161 String river = XMLUtils.xpathString(doc, XPATH_RIVER, null);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
162 String from_str = XMLUtils.xpathString(doc, XPATH_RFROM, null);
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
163 String to_str = XMLUtils.xpathString(doc, XPATH_RTO, null);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
164
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
165 try {
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
166 rid = Integer.parseInt(rid_str);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
167 from = Double.parseDouble(from_str);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
168 to = Double.parseDouble(to_str);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
169 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
170 catch(NumberFormatException nfe) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
171 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
172 }
f905c936ffff Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2489
diff changeset
173
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
174 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
175 return new FixingsOverviewInfo(
3376
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
176 rid,
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
177 river,
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
178 from,
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
179 to,
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
180 fixEvents,
653dd9d7f5d5 FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2921
diff changeset
181 result);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
182 }
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<FixEvent> getFixEvents(Document doc) {
2916
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
186 List<FixEvent> list = new ArrayList<FixEvent>();
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
187
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
188 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
189 doc,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
190 XPATH_EVENT,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
191 XPathConstants.NODESET,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
192 null);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
193
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
194 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
195 log.warn("No events in Overview!");
2916
1f63e2ef03d2 Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2915
diff changeset
196 return list;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
197 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
198
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
199 for (int i = 0, E = events.getLength(); i < E; i++) {
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
200 Element n = (Element)events.item(i);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
201 List<Sector> sectors = getSectors(n);
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
202 String cid = n.getAttribute("cid");
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
203 String date = n.getAttribute("date");;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
204 String name = n.getAttribute("description");
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
205 list.add(new FixEvent( cid, date, name, sectors));
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
206 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
207 return list;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
208 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
209
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
210 protected List<Sector> getSectors(Element event) {
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
211 NodeList sectors = event.getElementsByTagName("sector");
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
212
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
213 if (sectors.getLength() == 0) {
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
214 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
215 return null;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
216 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
217
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
218 List<Sector> list = new ArrayList<Sector>();
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
219 for (int i = 0, S = sectors.getLength(); i < S; i++) {
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
220 Element n = (Element)sectors.item(i);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
221 int cls = -1;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
222 double from = -1;
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
223 double to = -1;
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
224 String cls_str = n.getAttribute("class");
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
225 String from_str = n.getAttribute("from");
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
226 String to_str = n.getAttribute("to");
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
227 try {
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
228 cls = Integer.parseInt(cls_str);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
229 from = Double.parseDouble(from_str);
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
230 to = Double.parseDouble(to_str);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
231 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
232 catch(NumberFormatException nfe) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
233 log.warn(nfe, nfe);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
234 }
2915
d20f16a430a9 Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2536
diff changeset
235 list.add(new Sector(cls, from, to));
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
236 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2493
diff changeset
237 return list;
2489
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238 }
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239 }
2a504b6d9a1b Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org