[Dive4elements-commits] [PATCH 4 of 5] Do ordering in the data dictionary and replace "null" strings with empty strings

Wald Commits scm-commit at wald.intevation.org
Fri Apr 12 13:02:16 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1365764326 -7200
# Node ID 413798463dfe823f3c2c6cb028178207f45d9344
# Parent  f8409fbe3b888b477342faaae48dbbd3e9d8ed75
Do ordering in the data dictionary and replace "null" strings with empty strings

diff -r f8409fbe3b88 -r 413798463dfe flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
--- 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);
             }
         }


More information about the Dive4elements-commits mailing list