changeset 515:27ffaf628b54

The default values/labels for Data objects are read from DESCRIBE document. flys-client/trunk@1985 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 24 May 2011 10:46:48 +0000
parents b9127f876a6a
children ba606e575663
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java
diffstat 2 files changed, 32 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue May 24 10:44:59 2011 +0000
+++ b/flys-client/ChangeLog	Tue May 24 10:46:48 2011 +0000
@@ -1,3 +1,8 @@
+2011-05-24  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java:
+	  Read the default values for Data objects from DESCRIBE.
+
 2011-05-24  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/Data.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Tue May 24 10:44:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java	Tue May 24 10:46:48 2011 +0000
@@ -116,8 +116,9 @@
                 d, "@art:name", ArtifactNamespaceContext.INSTANCE);
 
             DataItem[] dataItems = extractCurrentDataItems(choices);
+            DataItem   def       = extractDefaultDataItem(d);
 
-            list.add(new DefaultData(name, label, null, dataItems));
+            list.add(new DefaultData(name, label, null, dataItems, def));
         }
 
         return list;
@@ -125,6 +126,31 @@
 
 
     /**
+     * This method extracts the default value of a Data object.
+     *
+     * @param data The data object node.
+     *
+     * @return the default DataItem.
+     */
+    protected static DataItem extractDefaultDataItem(Node data) {
+        System.out.println(
+            "ArtifactDescriptionFactory - extractSelectedDataItem");
+
+        String value = XMLUtils.xpathString(
+            data, "@art:defaultValue", ArtifactNamespaceContext.INSTANCE);
+
+        String label = XMLUtils.xpathString(
+            data, "@art:defaultLabel", ArtifactNamespaceContext.INSTANCE);
+
+        if (value != null && label != null) {
+            return new DefaultDataItem(label, null, value);
+        }
+
+        return null;
+    }
+
+
+    /**
      * This method extract the {@link DataItem}s of the DESCRIBE document.
      *
      * @param items The items in the DESCRIBE document.

http://dive4elements.wald.intevation.org