changeset 5677:413798463dfe

Do ordering in the data dictionary and replace "null" strings with empty strings
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 12 Apr 2013 12:58:46 +0200
parents f8409fbe3b88
children 57803a199856
files flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
diffstat 1 files changed, 22 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Fri Apr 12 12:57:57 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Fri Apr 12 12:58:46 2013 +0200
@@ -266,21 +266,34 @@
         Map<String, Object> data = new HashMap<String, Object>();
         List<Object> payload = new ArrayList<Object>();
         data.put("data", payload);
-        Enumeration<String> paramNames = req.getParameterNames();
-        while (paramNames.hasMoreElements()) {
-            String paramName = paramNames.nextElement();
-            if (paramName.startsWith("mapfish-data-")) {
-                // You can add mapfish-data variables that will be mapped
+        Enumeration paramNames = req.getParameterNames();
+        List<String> params = Collections.list(paramNames);
+        Collections.sort(params);
+        for (String paramName : params) {
+            if (paramName.startsWith("mapfish_data_")) {
+                // You can add mapfish_data variables that will be mapped
                 // to a info value pairs to provide meta data for the map
+                // The the info part starts with a number for sorting that
+                // number will be stripped
                 String paramValue = req.getParameter(paramName);
-                if (paramValue != null && !paramValue.isEmpty()) {
-                    Map<String, Object> data3 = new HashMap<String, Object>();
+                Map<String, Object> data3 = new HashMap<String, Object>();
+                int order = 0;
+                try {
+                    order = Integer.parseInt(paramName.substring(13, 14));
+                    data3.put("info", paramName.substring(14));
+                } catch (NumberFormatException nfe) {
                     data3.put("info", paramName.substring(13));
-                    data3.put("value", paramValue);
                     payload.add(data3);
                 }
-            } else if (paramName.startsWith("mapfish-")) {
+                if (paramValue.equals("null"))
+                    data3.put("value", "");
+                else
+                    data3.put("value", paramValue);
+                payload.add(data3);
+            } else if (paramName.startsWith("mapfish_")) {
                 String paramValue = req.getParameter(paramName);
+                if (paramValue.equals("null")
+                    paramValue = "";
                 pageSpecs.put(paramName.substring(8), paramValue);
             }
         }

http://dive4elements.wald.intevation.org