annotate gwt-client/src/main/java/org/dive4elements/river/client/server/ChartOutputServiceImpl.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
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;
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
10
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 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
12 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
13 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
14 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
15
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 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
17
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
18 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
19 import org.apache.logging.log4j.LogManager;
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
20
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
21 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
22 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
23 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
24
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
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
26
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
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
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
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 /**
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 * This service is used to request a chart from the artifact server. The
7135
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
33 * response is directed directly to the output stream. This can be used
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
34 * to stream an image that is displayed in the UI afterwards.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
35 *
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
36 * Note that a chart output can also be a csv file.
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
37 *
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 * @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
39 */
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 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
41 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
42 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
43 private static final Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
44 LogManager.getLogger(ChartOutputServiceImpl.class);
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
45
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1344
diff changeset
46
7135
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
47 /** Handle a get, collectionOut. */
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
48 public void doGet(HttpServletRequest req, HttpServletResponse resp) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
49 log.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
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 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
52 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
53
2940
2867a0192aed Cosmetics, whitespaces, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2906
diff changeset
54 String url = getServletContext().getInitParameter("server-url");
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
55
7136
fd8b27cdf498 issue971: Let ChartOutputServiceImpl interprete an "encoding" parameter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7135
diff changeset
56 String uuid = req.getParameter("uuid");
fd8b27cdf498 issue971: Let ChartOutputServiceImpl interprete an "encoding" parameter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7135
diff changeset
57 String type = req.getParameter("type");
fd8b27cdf498 issue971: Let ChartOutputServiceImpl interprete an "encoding" parameter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7135
diff changeset
58 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
59
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
60 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
61
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
62 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
63 uuid, type, type,
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
64 ChartServiceHelper.getChartAttributes(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
65 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
66
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
67 HttpClient client = new HttpClientImpl(url, locale);
7136
fd8b27cdf498 issue971: Let ChartOutputServiceImpl interprete an "encoding" parameter.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7135
diff changeset
68
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
69 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
70
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
71 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
72 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
73 }
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
74 catch (IOException ioe) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
75 log.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
76 }
280
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
77 catch (Exception e) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
78 log.error(e, e);
280
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
79 }
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
80 }
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
81
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
82
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
83 protected Map<String, String> prepareChartAttributes(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
84 HttpServletRequest req
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
85 ) {
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
86 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
87
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
88 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
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 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
91 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
92 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
93 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
94 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
95 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
96 attr.put("format", req.getParameter("format"));
2906
1780841d79af Added navigation to fix analysis charts.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2391
diff changeset
97 attr.put("km", req.getParameter("currentKm"));
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
98
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
99 if (log.isDebugEnabled()) {
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
100 log.debug("====== ZOOM VALUES =======");
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
101 log.debug(" min x: " + req.getParameter("minx"));
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
102 log.debug(" max x: " + req.getParameter("maxx"));
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
103 log.debug(" min y: " + req.getParameter("miny"));
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7486
diff changeset
104 log.debug(" max y: " + req.getParameter("maxy"));
2391
3c8ae5605a51 Picked rev 4059,4071,4072,4073 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
105 }
3c8ae5605a51 Picked rev 4059,4071,4072,4073 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1587
diff changeset
106
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
107 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
108 }
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
109
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
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 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
112 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
113 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
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 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
116
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 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
118 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
119
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 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
121 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
122 }
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
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 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
125
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
126 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
127 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
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 }
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 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
133 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
134 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
135 }
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 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
137 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
138 }
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 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
140 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
141 }
1587
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
142 else if (format.equals("csv")) {
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
143 return ".csv";
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
144 }
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
145
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 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
147 }
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
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
149
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
150 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
151 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
152 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
153 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
154 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
155 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
156 }
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
157 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
158 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
159 }
1587
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
160 else if (format.equals("csv")) {
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
161 return "text/plain";
45cd2364adad Issue 466.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1425
diff changeset
162 }
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
163
51d4b51a51ed Added icons to export chart as PNG, PDF and SVG to the ChartToolbar.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 549
diff changeset
164 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
165 }
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
166 }
280
b493d606fdef Enabled the client to request charts in different sizes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 254
diff changeset
167 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org