Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/server/FixingsOverviewServiceImpl.java @ 9726:0a5239a1e46e 3.2.x
Upgrade to Log4j 2
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 02 Mar 2022 10:26:50 +0100 |
parents | 0f3dad5d74a2 |
children |
rev | line source |
---|---|
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
9 package org.dive4elements.river.client.server; |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 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
|
12 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
13 import org.dive4elements.artifacts.common.utils.XMLUtils; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
14 import org.dive4elements.artifacts.common.utils.XSLTransformer; |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
15 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
16 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
18 import org.dive4elements.artifacts.httpclient.http.HttpClient; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
19 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
20 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
21 import org.dive4elements.river.client.client.services.FixingsOverviewService; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
22 |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
23 import org.dive4elements.river.client.shared.exceptions.ServerException; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
24 |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
25 import org.dive4elements.river.client.shared.model.FixingsOverviewInfo.FixEvent; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
26 import org.dive4elements.river.client.shared.model.FixingsOverviewInfo.Sector; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
27 |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
28 import org.dive4elements.river.client.shared.model.FixingsOverviewInfo; |
2915
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 java.io.IOException; |
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.InputStream; |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
32 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
33 import java.util.ArrayList; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
34 import java.util.List; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
35 |
9726 | 36 import org.apache.logging.log4j.Logger; |
37 import org.apache.logging.log4j.LogManager; | |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
38 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
39 import org.w3c.dom.Document; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
40 import org.w3c.dom.Element; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
41 import org.w3c.dom.NodeList; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
42 |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public class FixingsOverviewServiceImpl |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 extends RemoteServiceServlet |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 implements FixingsOverviewService |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 { |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
47 private static final Logger log = |
9726 | 48 LogManager.getLogger(FixingsOverviewServiceImpl.class); |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
49 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
50 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
|
51 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
52 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
|
53 "/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
|
54 |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
55 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
|
56 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
|
57 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
|
58 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
|
59 |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 @Override |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
61 public FixingsOverviewInfo generateOverview( |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
62 String locale, |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 String uuid, |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
64 String filter, |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
65 boolean checkboxes, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
66 String callback |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
67 ) |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 throws ServerException |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 { |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
70 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
|
71 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
72 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
|
73 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
|
74 return null; |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
75 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
76 |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
77 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
|
78 |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
79 if (debug) { |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
80 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
|
81 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
|
82 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
83 |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
84 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
|
85 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
86 if (filterDoc == null) { |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
87 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
|
88 return null; |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
89 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
90 |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
91 if (debug) { |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
92 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
|
93 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
|
94 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
95 |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
96 try { |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
97 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
|
98 HttpClient client = new HttpClientImpl(url, locale); |
2921
96d02c6f44a2
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2916
diff
changeset
|
99 Document resultDoc = |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
100 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
|
101 |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
102 if (debug) { |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
103 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
|
104 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
|
105 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
106 |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
107 FixingsOverviewInfo i = getInfo( |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
108 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
|
109 return i; |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
110 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
111 catch (ConnectionException ce) { |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
112 log.error(ce); |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
113 } |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
114 return null; |
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 |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
117 |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
118 protected FixingsOverviewInfo getInfo( |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
119 String locale, |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
120 Document doc, |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
121 String uuid, |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
122 boolean checkboxes, |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
123 String callback |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
124 ) { |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
125 // TODO: Find a more general solution. |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
126 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
|
127 ? "de" |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
128 : "en"; |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
129 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
130 InputStream transform = getServletContext() |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
131 .getResourceAsStream(XSL_TRANSFORM); |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
132 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
133 if (transform == null) { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
134 log.warn("transform not found"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
135 return null; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
136 } |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
137 |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
138 String result = null; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
139 try { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
140 XSLTransformer xformer = new XSLTransformer(); |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
141 xformer.addParameter("locale", locale); |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
142 xformer.addParameter("project-uuid", uuid); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
143 xformer.addParameter( |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
144 "render-checkboxes", |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
145 checkboxes ? Boolean.TRUE : Boolean.FALSE); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
146 xformer.addParameter("callback", callback); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
147 result = xformer.transform(doc, transform); |
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 finally { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
150 try { transform.close(); } |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
151 catch (IOException ioe) {} |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
152 } |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
153 |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
154 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
|
155 log.debug("--------------------------------------"); |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
156 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
|
157 log.debug("--------------------------------------"); |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
158 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
159 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
160 int rid = -1; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
161 double from = -1; |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
162 double to = -1; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
163 |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 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
|
168 |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
169 try { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
170 rid = Integer.parseInt(rid_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
171 from = Double.parseDouble(from_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
172 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
|
173 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
174 catch(NumberFormatException nfe) { |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
175 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
|
176 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
177 |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
178 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
|
179 return new FixingsOverviewInfo( |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
180 rid, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
181 river, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
182 from, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
183 to, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
184 fixEvents, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
185 result); |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
186 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
187 |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
188 |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
189 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
|
190 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
|
191 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
192 NodeList events = doc.getElementsByTagName("event"); |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
193 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
194 int E = events.getLength(); |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
195 |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
196 if (E == 0) { |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
197 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
|
198 return list; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
199 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
200 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
201 for (int i = 0; i < E; i++) { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
202 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
|
203 List<Sector> sectors = getSectors(n); |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
204 String cid = n.getAttribute("cid"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
205 String date = n.getAttribute("date");; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
206 String name = n.getAttribute("description"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
207 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
|
208 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
209 return list; |
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 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
212 protected List<Sector> getSectors(Element event) { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
213 NodeList sectors = event.getElementsByTagName("sector"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
214 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
215 int S = sectors.getLength(); |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
216 |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
217 if (S == 0) { |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
218 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
|
219 return null; |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
220 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
221 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
222 List<Sector> list = new ArrayList<Sector>(S); |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
223 for (int i = 0; i < S; i++) { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
224 Element n = (Element)sectors.item(i); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
225 int cls = -1; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
226 double from = -1; |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
227 double to = -1; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
228 String cls_str = n.getAttribute("class"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
229 String from_str = n.getAttribute("from"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
230 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
|
231 try { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
232 cls = Integer.parseInt(cls_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
233 from = Double.parseDouble(from_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
234 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
|
235 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
236 catch(NumberFormatException nfe) { |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
237 log.warn(nfe, nfe); |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
238 } |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
239 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
|
240 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
241 return list; |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
242 } |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
243 } |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
244 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |