changeset 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 fbe18ad4caff
children efe1b8545f5c
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java
diffstat 3 files changed, 79 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Sep 12 04:20:48 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Sep 12 06:23:48 2011 +0000
@@ -1,3 +1,13 @@
+2011-09-12  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java:
+	  Sourced the code to append a concrete data item to the static DESCRIBE
+	  part out to an own method (appendStaticData()).
+
+	* src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java:
+	  Override appendStaticData() to suppress the GeoJSON string to be
+	  included in the static DESCRIBE.
+
 2011-09-12  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/CrossSectionFactory.java,
--- 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
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java	Mon Sep 12 04:20:48 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java	Mon Sep 12 06:23:48 2011 +0000
@@ -9,6 +9,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;
 
@@ -45,6 +46,23 @@
 
 
     @Override
+    protected void appendStaticData(
+        FLYSArtifact   flys,
+        CallMeta       meta,
+        ElementCreator creator,
+        Element        ui,
+        String         name
+    ) {
+        if (name != null && name.equals(FIELD_BARRIERS)) {
+            return;
+        }
+        else {
+            super.appendStaticData(flys, meta, creator, ui, name);
+        }
+    }
+
+
+    @Override
     protected Element[] createItems(
         XMLUtils.ElementCreator cr,
         Artifact    artifact,

http://dive4elements.wald.intevation.org