changeset 2011:81eaea64c0db

Hide deleted facets from outgenerators. flys-artifacts/trunk@3459 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 19 Dec 2011 09:04:50 +0000
parents 7f99845e9499
children 514d26021728
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java
diffstat 2 files changed, 85 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Dec 19 07:53:22 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Dec 19 09:04:50 2011 +0000
@@ -1,3 +1,8 @@
+2011-12-19	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java
+	  (doOut): Hide 'invisible' (deleted) themes from Outgenerators.
+
 2011-12-19	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Added area.name data item and access to areaartifact.
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Mon Dec 19 07:53:22 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Mon Dec 19 09:04:50 2011 +0000
@@ -59,6 +59,9 @@
     public static final String XPATH_ARTIFACT_STATE_DATA =
         "/art:result/art:ui/art:static/art:state/art:data";
 
+    public static final String XPATH_ARTIFACT_DYN_DATA =
+        "/art:result/art:ui/art:dynamic/art:select";
+
     public static final String XPATH_COLLECTION_ITEMS =
         "/art:result/art:artifact-collection/art:collection-item";
 
@@ -413,6 +416,11 @@
                     continue;
                 }
 
+                // Skip invisible themes.
+                if (theme.getVisible() == 0) {
+                    continue;
+                }
+
                 generator.doOut(
                     dataProviders.get(i),
                     getFacetThemeFromAttribute(
@@ -948,6 +956,78 @@
 
 
     /**
+     * Create the Artifacts Node that contains outputmode and statedata.
+     * @param uuid uuid of the artifact.
+    protected Element buildArtifactNode(
+        ArtifactDatabase        database,
+        String                  uuid,
+        CallContext             context,
+        XMLUtils.ElementCreator ec)
+    throws ArtifactDatabaseException
+    {
+        log.debug("Append artifact '" + uuid + "' to collection description");
+
+        // TODO
+        String hash = "MYHASH";
+
+        Element ci = ec.create("artifact");
+        ec.addAttr(ci, "uuid", uuid, true);
+        ec.addAttr(ci, "hash", hash, true);
+
+        // XXX I am not sure if it works well every time with an empty document
+        // 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,
+            XPathConstants.NODE,
+            ArtifactNamespaceContext.INSTANCE);
+
+        if (outputModes != null) {
+            Document doc = ci.getOwnerDocument();
+            ci.appendChild(doc.importNode(outputModes, true));
+        }
+
+        // Add state-data element(s).
+        Node dataNode = ci.appendChild(
+            ci.getOwnerDocument().createElement("art:data-items"));
+
+        // Static data first.
+        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));
+            }
+        }
+
+        // Dynamic data second
+        dataNodes = (NodeList) XMLUtils.xpath(
+            description,
+            XPATH_ARTIFACT_DYN_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;
+    }
+     */
+
+
+    /**
      * Inner class to structure/order the themes of a chart.
      */
     private static class ThemeList {

http://dive4elements.wald.intevation.org