Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/server/FixingsOverviewServiceImpl.java @ 7036:e25ef8376c14
issue971: Change CSV column separator to ";".
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 18 Sep 2013 12:25:05 +0200 |
parents | 0f3dad5d74a2 |
children | 0a5239a1e46e |
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 |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
36 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
|
37 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
38 import org.w3c.dom.Document; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
39 import org.w3c.dom.Element; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
40 import org.w3c.dom.NodeList; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
41 |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 public class FixingsOverviewServiceImpl |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 extends RemoteServiceServlet |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 implements FixingsOverviewService |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 { |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
46 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
|
47 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
|
48 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
49 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
|
50 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
51 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
|
52 "/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
|
53 |
2505
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_RID = "/fixings/river/@rid"; |
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_RIVER = "/fixings/river/@name"; |
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_RFROM = "/fixings/river/@from"; |
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_RTO = "/fixings/river/@to"; |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
58 |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 @Override |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
60 public FixingsOverviewInfo generateOverview( |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
61 String locale, |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 String uuid, |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
63 String filter, |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
64 boolean checkboxes, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
65 String callback |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
66 ) |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 throws ServerException |
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 { |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
69 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
|
70 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
71 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
|
72 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
|
73 return null; |
2493
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 |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
76 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
|
77 |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
78 if (debug) { |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
79 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
|
80 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
|
81 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
82 |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
83 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
|
84 |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
85 if (filterDoc == null) { |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
86 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
|
87 return null; |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
88 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
89 |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
90 if (debug) { |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
91 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
|
92 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
|
93 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
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); |
2921
96d02c6f44a2
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2916
diff
changeset
|
98 Document resultDoc = |
2493
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); |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
100 |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
101 if (debug) { |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
102 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
|
103 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
|
104 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
105 |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
106 FixingsOverviewInfo i = getInfo( |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
107 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
|
108 return i; |
2493
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
109 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
110 catch (ConnectionException ce) { |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
111 log.error(ce); |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
112 } |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
113 return null; |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
114 } |
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 protected FixingsOverviewInfo getInfo( |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
118 String locale, |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
119 Document doc, |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
120 String uuid, |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
121 boolean checkboxes, |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
122 String callback |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
123 ) { |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
124 // TODO: Find a more general solution. |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
125 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
|
126 ? "de" |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
127 : "en"; |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
128 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
129 InputStream transform = getServletContext() |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
130 .getResourceAsStream(XSL_TRANSFORM); |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
131 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
132 if (transform == null) { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
133 log.warn("transform not found"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
134 return null; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
135 } |
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 String result = null; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
138 try { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
139 XSLTransformer xformer = new XSLTransformer(); |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
140 xformer.addParameter("locale", locale); |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
141 xformer.addParameter("project-uuid", uuid); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
142 xformer.addParameter( |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
143 "render-checkboxes", |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
144 checkboxes ? Boolean.TRUE : Boolean.FALSE); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
145 xformer.addParameter("callback", callback); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
146 result = xformer.transform(doc, transform); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
147 } |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
148 finally { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
149 try { transform.close(); } |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
150 catch (IOException ioe) {} |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
151 } |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
152 |
2916
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
153 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
|
154 log.debug("--------------------------------------"); |
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(result); |
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("--------------------------------------"); |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
157 } |
1f63e2ef03d2
Added more debug output about the transmitted fix overview documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2915
diff
changeset
|
158 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
159 int rid = -1; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
160 double from = -1; |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
161 double to = -1; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
162 |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 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
|
167 |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
168 try { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
169 rid = Integer.parseInt(rid_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
170 from = Double.parseDouble(from_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
171 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
|
172 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
173 catch(NumberFormatException nfe) { |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
174 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
|
175 } |
f905c936ffff
Added the XSL transformation to generate the fixings overview.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2489
diff
changeset
|
176 |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
177 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
|
178 return new FixingsOverviewInfo( |
3376
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
179 rid, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
180 river, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
181 from, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
182 to, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
183 fixEvents, |
653dd9d7f5d5
FixA: Introduce i18n to overview transformation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2921
diff
changeset
|
184 result); |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
185 } |
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 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
|
189 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
|
190 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
191 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
|
192 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
193 int E = events.getLength(); |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
194 |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
195 if (E == 0) { |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
196 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
|
197 return list; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
198 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
199 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
200 for (int i = 0; i < E; i++) { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
201 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
|
202 List<Sector> sectors = getSectors(n); |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
203 String cid = n.getAttribute("cid"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
204 String date = n.getAttribute("date");; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
205 String name = n.getAttribute("description"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
206 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
|
207 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
208 return list; |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
209 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
210 |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
211 protected List<Sector> getSectors(Element event) { |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
212 NodeList sectors = event.getElementsByTagName("sector"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
213 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
214 int S = sectors.getLength(); |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
215 |
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
216 if (S == 0) { |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
217 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
|
218 return null; |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
219 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
220 |
6867
0f3dad5d74a2
Client: Removed an XPath eval and simplified a loop.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
221 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
|
222 for (int i = 0; i < S; i++) { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
223 Element n = (Element)sectors.item(i); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
224 int cls = -1; |
2505
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
225 double from = -1; |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
226 double to = -1; |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
227 String cls_str = n.getAttribute("class"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
228 String from_str = n.getAttribute("from"); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
229 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
|
230 try { |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
231 cls = Integer.parseInt(cls_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
232 from = Double.parseDouble(from_str); |
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
233 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
|
234 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
235 catch(NumberFormatException nfe) { |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
236 log.warn(nfe, nfe); |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
237 } |
2915
d20f16a430a9
Removed some XPath misuse.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2536
diff
changeset
|
238 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
|
239 } |
87ac5c532523
First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2493
diff
changeset
|
240 return list; |
2489
2a504b6d9a1b
Added stub for fixings overview service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
241 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |