Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java @ 845:4db672cdacb2
Added outs/facet filters when creation new artifacts.
flys-client/trunk@2569 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 24 Aug 2011 16:06:48 +0000 |
parents | e74bf6bfeeb6 |
children | 51d4b51a51ed |
rev | line source |
---|---|
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.io.OutputStream; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.io.IOException; |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
5 import java.util.HashMap; |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
6 import java.util.Map; |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import javax.servlet.http.HttpServlet; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import javax.servlet.http.HttpServletRequest; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import javax.servlet.http.HttpServletResponse; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
213
7ea004d0ffbc
The ChartOutputTab calls the out() operation of a Collection now - no longer the out() of its first artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
78
diff
changeset
|
14 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
7ea004d0ffbc
The ChartOutputTab calls the out() operation of a Collection now - no longer the out() of its first artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
78
diff
changeset
|
15 |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.httpclient.http.HttpClient; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 /** |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 * This service is used to request a chart from the artifact server. The |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 * response is directed directly to the output stream, so the image that is |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * retrieved is displayed in the UI afterwards. |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 */ |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 public class ChartOutputServiceImpl |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 extends HttpServlet |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 { |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 public void doGet(HttpServletRequest req, HttpServletResponse resp) { |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 System.out.println("ChartOutputServiceImpl.doGet"); |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 try { |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 OutputStream out = resp.getOutputStream(); |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 String serverUrl = req.getParameter("server"); |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 String uuid = req.getParameter("uuid"); |
213
7ea004d0ffbc
The ChartOutputTab calls the out() operation of a Collection now - no longer the out() of its first artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
78
diff
changeset
|
38 String type = req.getParameter("type"); |
254
6838e4112eeb
Bugfix: the current locale string is used to fetch chart images now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
213
diff
changeset
|
39 String locale = req.getParameter("locale"); |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
213
7ea004d0ffbc
The ChartOutputTab calls the out() operation of a Collection now - no longer the out() of its first artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
78
diff
changeset
|
41 Document request = ClientProtocolUtils.newOutCollectionDocument( |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
42 uuid, type, type, |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
43 ChartServiceHelper.getChartAttributes(prepareChartAttributes(req))); |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
254
6838e4112eeb
Bugfix: the current locale string is used to fetch chart images now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
213
diff
changeset
|
45 HttpClient client = new HttpClientImpl(serverUrl, locale); |
213
7ea004d0ffbc
The ChartOutputTab calls the out() operation of a Collection now - no longer the out() of its first artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
78
diff
changeset
|
46 client.collectionOut(request, uuid, "chart", out); |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 out.close(); |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 out.flush(); |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 catch (IOException ioe) { |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
52 ioe.printStackTrace(); |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 System.err.println(ioe.getMessage()); |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 } |
280
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
55 catch (Exception e) { |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
56 e.printStackTrace(); |
280
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
57 System.err.println(e.getMessage()); |
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
58 } |
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
59 } |
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
60 |
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
61 |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
62 protected Map<String, String> prepareChartAttributes(HttpServletRequest req) { |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
63 Map<String, String> attr = new HashMap<String, String>(); |
280
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
64 |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
65 Map params = req.getParameterMap(); |
542
7c57149e8715
Append the x and y ranges determined after zooming with the ZoomboxControl to the attribute document used for the chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
432
diff
changeset
|
66 |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
67 attr.put("width", req.getParameter("width")); |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
68 attr.put("height", req.getParameter("height")); |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
69 attr.put("minx", req.getParameter("minx")); |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
70 attr.put("maxx", req.getParameter("maxx")); |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
71 attr.put("miny", req.getParameter("miny")); |
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
72 attr.put("maxy", req.getParameter("maxy")); |
542
7c57149e8715
Append the x and y ranges determined after zooming with the ZoomboxControl to the attribute document used for the chart creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
432
diff
changeset
|
73 |
549
e74bf6bfeeb6
Use the same code to create the attribute document for the chart creation in ChartOutputService and ChartInfoService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
542
diff
changeset
|
74 return attr; |
78
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
9ca5160cf080
Added a service that builds up requests to retrieve chart images. Use this service to display charts in the ChartOutputTab.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
280
b493d606fdef
Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
254
diff
changeset
|
77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |