diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java @ 1159:fb5a7ff9feb8

Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part. flys-artifacts/trunk@2695 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 12 Sep 2011 06:23:48 +0000
parents 8da5f5a9ed3c
children 28154920e0b3
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Mon Sep 12 04:20:48 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java	Mon Sep 12 06:23:48 2011 +0000
@@ -18,6 +18,7 @@
 import de.intevation.artifacts.CallMeta;
 
 import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
 import de.intevation.artifactdatabase.ProtocolUtils;
 
@@ -58,7 +59,7 @@
         CallContext context,
         String      uuid)
     {
-        XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
+        ElementCreator creator = new ElementCreator(
             document,
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
@@ -80,48 +81,58 @@
         FLYSArtifact     flys = (FLYSArtifact) artifact;
 
         while (iter.hasNext()) {
-            String    name = iter.next();
-            StateData data = getData(flys, name);
-
-            String value = (data != null) ? (String) data.getValue() : null;
-
-            if (value == null) {
-                continue;
-            }
-
-            logger.debug("Append element '" + name + "' (" + value + ")");
-
-            Element dataElement = creator.create("data");
-            creator.addAttr(dataElement, "name", name, true);
-            creator.addAttr(dataElement, "type", data.getType(), true);
-
-            Element itemElement = creator.create("item");
-            creator.addAttr(itemElement, "value", value, true);
-
-            String attrValue = "";
-            try {
-                // XXX A better way to format the output would be to use the
-                // 'type' value of the data objects.
-                double doubleVal = Double.valueOf(value);
-                Locale         l = Resources.getLocale(meta);
-                NumberFormat  nf = NumberFormat.getInstance(l);
-
-                attrValue = nf.format(doubleVal);
-            }
-            catch (NumberFormatException nfe) {
-                attrValue = Resources.getMsg(meta, value, value);
-            }
-
-            creator.addAttr(itemElement, "label", attrValue, true);
-
-            dataElement.appendChild(itemElement);
-            ui.appendChild(dataElement);
+            String name = iter.next();
+            appendStaticData(flys, meta, creator, ui, name);
         }
 
         return ui;
     }
 
 
+    protected void appendStaticData(
+        FLYSArtifact   flys,
+        CallMeta       meta,
+        ElementCreator creator,
+        Element        ui,
+        String         name
+    ) {
+        StateData data  = getData(flys, name);
+        String    value = (data != null) ? (String) data.getValue() : null;
+
+        if (value == null) {
+            return;
+        }
+
+        logger.debug("Append element '" + name + "' (" + value + ")");
+
+        Element dataElement = creator.create("data");
+        creator.addAttr(dataElement, "name", name, true);
+        creator.addAttr(dataElement, "type", data.getType(), true);
+
+        Element itemElement = creator.create("item");
+        creator.addAttr(itemElement, "value", value, true);
+
+        String attrValue = "";
+        try {
+            // XXX A better way to format the output would be to use the
+            // 'type' value of the data objects.
+            double doubleVal = Double.valueOf(value);
+            Locale         l = Resources.getLocale(meta);
+            NumberFormat  nf = NumberFormat.getInstance(l);
+
+            attrValue = nf.format(doubleVal);
+        }
+        catch (NumberFormatException nfe) {
+            attrValue = Resources.getMsg(meta, value, value);
+        }
+
+        creator.addAttr(itemElement, "label", attrValue, true);
+
+        dataElement.appendChild(itemElement);
+        ui.appendChild(dataElement);
+    }
+
+
     public Element describe(
         Artifact    artifact,
         Document    document,
@@ -129,7 +140,7 @@
         CallContext context,
         String      uuid)
     {
-        XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
+        ElementCreator creator = new ElementCreator(
             document,
             ArtifactNamespaceContext.NAMESPACE_URI,
             ArtifactNamespaceContext.NAMESPACE_PREFIX);
@@ -205,7 +216,7 @@
      * @return the root node of the item list.
      */
     protected Element createData(
-        XMLUtils.ElementCreator cr,
+        ElementCreator cr,
         Artifact    artifact,
         StateData   data,
         CallContext context)
@@ -238,7 +249,7 @@
      * @return a list of items.
      */
     protected Element[] createItems(
-        XMLUtils.ElementCreator cr,
+        ElementCreator cr,
         Artifact    artifact,
         String      name,
         CallContext context

http://dive4elements.wald.intevation.org