changeset 8070:d77f53c1e5a1

Added meta infos for multi items to enable client to order the columns in a defined order.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 05 Aug 2014 18:03:45 +0200
parents 86c1ff462fb5
children 6e6506ec0ae0
files artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java
diffstat 1 files changed, 28 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java	Tue Aug 05 16:34:04 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java	Tue Aug 05 18:03:45 2014 +0200
@@ -10,20 +10,17 @@
 
 import java.text.NumberFormat;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.log4j.Logger;
-
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
-
 import org.dive4elements.artifacts.common.model.KVP;
 import org.dive4elements.artifacts.common.utils.XMLUtils;
 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
-
 import org.dive4elements.river.model.BedHeightSingle;
 import org.dive4elements.river.model.River;
-
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.utils.Formatter;
@@ -57,6 +54,8 @@
         try {
             creator.addAttr(select, "type", "multiattribute", true);
 
+            appendMeta(creator, select);
+
             getOptions(artifact, name, context, creator, select);
         }
         catch (IllegalArgumentException iae) {
@@ -64,6 +63,26 @@
         }
     }
 
+    private static Element order(ElementCreator creator, String name, String order) {
+        Element element = creator.create(name);
+        creator.addAttr(element, "order", order, false);
+        return element;
+    }
+
+    private void appendMeta(ElementCreator creator, Element select) {
+
+        Element meta = creator.create("meta");
+
+        meta.appendChild(order(creator, "year",           "0"));
+        meta.appendChild(order(creator, "value",          "1"));
+        meta.appendChild(order(creator, "analyzed_range", "2"));
+        meta.appendChild(order(creator, "label",          "3"));
+        meta.appendChild(order(creator, "minfo_type",     "4"));
+
+        select.appendChild(meta);
+
+    }
+
     protected KVP<String, String>[] getOptions(
         Artifact artifact,
         String   parameterName,
@@ -87,10 +106,9 @@
         double kmLo = Math.min(lo, hi);
         double kmHi = Math.max(lo, hi);
 
-        List<KVP<String, String>> kvp = new ArrayList<KVP<String, String>>();
-
         appendSingles(river, kmLo, kmHi, creator, select, context);
 
+        List<KVP<String, String>> kvp = Collections.<KVP<String, String>>emptyList();
         return kvp.toArray(new KVP[kvp.size()]);
     }
 
@@ -132,8 +150,10 @@
                 select.appendChild(item);
             }
         }
-        logger.debug("appended singles");
-        logger.debug(XMLUtils.toString(select));
+        if (logger.isDebugEnabled()) {
+            logger.debug("appended singles");
+            logger.debug(XMLUtils.toString(select));
+        }
     }
 
     @Override

http://dive4elements.wald.intevation.org