changeset 1950:37a7b3841565

Include state data items in description document of collection. flys-artifacts/trunk@3343 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 02 Dec 2011 11:01:11 +0000
parents d04cc7e4b55d
children 2c9bf9aede64 cc83b8e42dbe
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java
diffstat 2 files changed, 33 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Nov 30 12:14:11 2011 +0000
+++ b/flys-artifacts/ChangeLog	Fri Dec 02 11:01:11 2011 +0000
@@ -1,3 +1,9 @@
+2011-12-02	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  (buildArtifactNode): Include artifacts state data in description
+	  document of collection.
+
 2011-11-30	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/DischargeCurveGenerator.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Nov 30 12:14:11 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Fri Dec 02 11:01:11 2011 +0000
@@ -54,6 +54,9 @@
     public static final String XPATH_ARTIFACT_OUTPUTMODES =
         "/art:result/art:outputmodes";
 
+    public static final String XPATH_ARTIFACT_STATE_DATA =
+        "/art:result/art:ui/art:static/art:state/art:data";
+
     public static final String XPATH_COLLECTION_ITEMS =
         "/art:result/art:artifact-collection/art:collection-item";
 
@@ -414,7 +417,7 @@
         }
     
         aParser.parse(oldAttr);
-    
+
         return new AttributeWriter(
             db,
             aParser.getOuts(),
@@ -826,6 +829,10 @@
     }
 
 
+    /**
+     * Create the Artifacts Node that contains outputmode and statedata.
+     * @param uuid uuid of the artifact.
+     */
     protected Element buildArtifactNode(
         ArtifactDatabase        database,
         String                  uuid,
@@ -838,7 +845,7 @@
         // TODO
         String hash = "MYHASH";
 
-        Element ci   = ec.create("artifact");
+        Element ci = ec.create("artifact");
         ec.addAttr(ci, "uuid", uuid, true);
         ec.addAttr(ci, "hash", hash, true);
 
@@ -846,6 +853,7 @@
         // in the describe operation of an artifact.
         Document description = database.describe(uuid, null, context.getMeta());
 
+        // Add outputmode element(s).
         Node outputModes = (Node) XMLUtils.xpath(
             description,
             XPATH_ARTIFACT_OUTPUTMODES,
@@ -857,6 +865,23 @@
             ci.appendChild(doc.importNode(outputModes, true));
         }
 
+        // Add state-data element(s).
+        Node dataNode = ci.appendChild(
+            ci.getOwnerDocument().createElement("art:data-items"));
+
+        NodeList dataNodes = (NodeList) XMLUtils.xpath(
+            description,
+            XPATH_ARTIFACT_STATE_DATA,
+            XPathConstants.NODESET,
+            ArtifactNamespaceContext.INSTANCE);
+
+        if (dataNodes != null) {
+            Document doc = ci.getOwnerDocument();
+            for (int i = 0; i < dataNodes.getLength(); i++) {
+                dataNode.appendChild(doc.importNode(dataNodes.item(i), true));
+            }
+        }
+
         return ci;
     }
 

http://dive4elements.wald.intevation.org