diff gwt-client/src/main/java/org/dive4elements/river/client/server/ChartServiceHelper.java @ 9104:07d51fd4864c

Added metadata subtitle to all chart export
author gernotbelger
date Tue, 29 May 2018 11:35:44 +0200
parents 238fc722f87a
children 4809e23ffd27
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/ChartServiceHelper.java	Tue May 29 11:02:56 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/ChartServiceHelper.java	Tue May 29 11:35:44 2018 +0200
@@ -62,6 +62,7 @@
 
         appendChartSize(req, attributes, ec);
         appendFormat(req, attributes, ec);
+        appendExport(req, attributes, ec);
         appendXRange(req, attributes, ec);
         appendYRange(req, attributes, ec);
         appendCurrentKm(req, attributes, ec);
@@ -174,7 +175,7 @@
      * @param doc The attribute document used to adjust chart settings.
      * @param ec The ElementCreator that might be used to create new Elements.
      */
-    protected static void appendFormat(
+    private static void appendFormat(
         Map<String, String> req,
         Element             attributes,
         ElementCreator      ec
@@ -193,6 +194,26 @@
         attributes.appendChild(format);
     }
 
+    /**
+     * This method extracts the export string from request object and appends
+     * those format - if existing - to the attribute document used to adjust
+     * the chart settings.
+     *
+     * @param req The request object that might contain the chart export flag.
+     * @param doc The attribute document used to adjust chart settings.
+     * @param ec The ElementCreator that might be used to create new Elements.
+     */
+    private static void appendExport( final Map<String, String> req, final Element attributes, final ElementCreator ec ) {
+        
+        final String exportStr = req.get("export");
+        if (exportStr == null || exportStr.isEmpty()) 
+            return;
+        
+        final Element format = ec.create("export");
+        ec.addAttr(format, "value", exportStr, true);
+        
+        attributes.appendChild(format);
+    }
 
     /**
      * This method extracts the current km for the chart from request object and

http://dive4elements.wald.intevation.org