[PATCH] Added meta infos for multi items to enable client to order the columns in a defined order
Wald Commits
scm-commit at wald.intevation.org
Tue Aug 5 18:04:03 CEST 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1407254625 -7200
# Node ID d77f53c1e5a170c6ac4676c924ff9f656eec6372
# Parent 86c1ff462fb5cc70d8e02e2a79265917422f2bb1
Added meta infos for multi items to enable client to order the columns in a defined order.
diff -r 86c1ff462fb5 -r d77f53c1e5a1 artifacts/src/main/java/org/dive4elements/river/artifacts/states/SoundingsSelect.java
--- 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
More information about the Dive4Elements-commits
mailing list