changeset 227:4bb6bfaca393

The output nodes written into the DESCRIBE document by ProtocolUtils have nodes for each facet supported by an output. artifacts/trunk@1627 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 30 Mar 2011 15:19:08 +0000
parents 41404961c804
children dd977fb7552e
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java
diffstat 2 files changed, 51 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 30 14:45:15 2011 +0000
+++ b/ChangeLog	Wed Mar 30 15:19:08 2011 +0000
@@ -1,3 +1,8 @@
+2011-03-30  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java:
+	  The output nodes written to DESCRIBE document have facet nodes now.
+
 2011-03-30  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultFacet.java,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java	Wed Mar 30 14:45:15 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java	Wed Mar 30 15:19:08 2011 +0000
@@ -13,6 +13,7 @@
 
 import de.intevation.artifacts.common.utils.XMLUtils;
 
+import de.intevation.artifactdatabase.state.Facet;
 import de.intevation.artifactdatabase.state.Output;
 import de.intevation.artifactdatabase.state.State;
 
@@ -147,17 +148,60 @@
     }
 
 
+    /**
+     * This method appends a node for each Output in the <i>outputs</i> list to
+     * <i>out</i>. Note: an output node includes its provided facets!
+     *
+     * @param creator The ElementCreator used to create new elements.
+     * @param out The parent node for new elements.
+     * @param outputs The list of reachable outputs.
+     */
     public static void appendOutputModes(
         XMLUtils.ElementCreator creator,
         Element                 out,
         List<Output>            outputs)
     {
         for (Output o: outputs) {
-            out.appendChild(createArtNode(
+            Element newOut = createArtNode(
                 creator,
                 "output",
                 new String[] {"name", "description", "mime-type"},
-                new String[] {o.getName(),o.getDescription(),o.getMimeType()}));
+                new String[] {o.getName(),o.getDescription(),o.getMimeType()});
+
+            Element facets = createArtNode(creator, "facets", null, null);
+            appendFacets(creator, facets, o.getFacets());
+
+            newOut.appendChild(facets);
+            out.appendChild(newOut);
+        }
+    }
+
+
+    /**
+     * This method appends a node for each Facet in the <i>facets</i> list to
+     * <i>facet</i>.
+     *
+     * @param creator The ElementCreator used to create new elements.
+     * @param facet The root node for new elements.
+     * @param facets The list of facets.
+     */
+    public static void appendFacets(
+        XMLUtils.ElementCreator creator,
+        Element                 facet,
+        List<Facet>             facets)
+    {
+        if (facets == null || facets.size() == 0) {
+            return;
+        }
+
+        for (Facet f: facets) {
+            Element newFacet = createArtNode(
+                creator,
+                "facet",
+                new String[] { "name", "description" },
+                new String[] { f.getName(), f.getDescription() });
+
+            facet.appendChild(newFacet);
         }
     }
 }

http://dive4elements.wald.intevation.org