annotate flys-client/src/main/java/de/intevation/flys/client/server/ChartOutputServiceImpl.java @ 2497:a6c6f305546c

Removed superfluous imports. flys-client/trunk@4324 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 27 Apr 2012 15:57:11 +0000
parents c837669643ac
children 1780841d79af
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
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
10 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
11
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
12 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
13 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
14 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
15
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
16 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
17
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
18 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
19 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
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
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 /**
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 * 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
24 * 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
25 * 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
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 * @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
28 */
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 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
30 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
31 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
32 private static final Logger logger =
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
33 Logger.getLogger(ChartOutputServiceImpl.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
34
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
35
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
36 public void doGet(HttpServletRequest req, HttpServletResponse resp) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
37 logger.info("ChartOutputServiceImpl.doGet");
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
38
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
39 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
40 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
41
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
42 String url = getServletContext().getInitParameter("server-url");
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
43
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 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
45 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
46 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
47
1344
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
48 prepareHeader(req, resp);
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
49
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
50 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
51 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
52 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
53
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
54 HttpClient client = new HttpClientImpl(url, 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
55 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
56
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
57 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
58 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
59 }
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
60 catch (IOException ioe) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
61 logger.error(ioe, ioe);
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
62 }
280
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
63 catch (Exception e) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
64 logger.error(e, e);
280
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
65 }
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
66 }
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
67
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
68
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
69 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
70 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
71
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
72 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
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 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
75 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
76 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
77 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
78 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
79 attr.put("maxy", req.getParameter("maxy"));
1344
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
80 attr.put("format", req.getParameter("format"));
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
81
2429
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
82 if (logger.isDebugEnabled()) {
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
83 logger.debug("====== ZOOM VALUES =======");
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
84 logger.debug(" min x: " + req.getParameter("minx"));
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
85 logger.debug(" max x: " + req.getParameter("maxx"));
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
86 logger.debug(" min y: " + req.getParameter("miny"));
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
87 logger.debug(" max y: " + req.getParameter("maxy"));
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
88 }
c837669643ac Print debug messages for zoom values in ChartOutputServiceIMpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
89
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
90 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
91 }
1344
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
92
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
93
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
94 protected void prepareHeader(
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
95 HttpServletRequest req,
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
96 HttpServletResponse resp
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
97 ) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
98 String export = req.getParameter("export");
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
99
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
100 if (export != null && export.equals("true")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
101 String format = req.getParameter("format");
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
102
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
103 if (format == null || format.length() == 0) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
104 format = "png";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
105 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
106
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
107 String fn = "chart_export" + getFileExtension(format);
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
108
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
109 resp.setHeader("Content-Disposition", "attachment;filename=" + fn);
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
110 resp.setHeader("Content-Type", getMimeType(format));
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
111 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
112 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
113
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
114
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
115 protected String getFileExtension(String format) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
116 if (format.equals("png")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
117 return ".png";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
118 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
119 else if (format.equals("pdf")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
120 return ".pdf";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
121 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
122 else if (format.equals("svg")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
123 return ".svg";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
124 }
1587
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
125 else if (format.equals("csv")) {
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
126 return ".csv";
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
127 }
1344
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
128
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
129 return ".png";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
130 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
131
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
132
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
133 protected String getMimeType(String format) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
134 if (format.equals("png")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
135 return "image/png";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
136 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
137 else if (format.equals("pdf")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
138 return "application/pdf";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
139 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
140 else if (format.equals("svg")) {
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
141 return "svg+xml";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
142 }
1587
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
143 else if (format.equals("csv")) {
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
144 return "text/plain";
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
145 }
1344
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
146
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
147 return "image/png";
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
148 }
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
149 }
280
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
150 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org