changeset 1715:a70e0cbc5e02

Added support for removing themes from output. flys-artifacts/trunk@2989 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 17 Oct 2011 14:55:45 +0000
parents 004b1b0838d6
children 3ca999f507b7
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedDomFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java
diffstat 6 files changed, 76 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Oct 17 13:00:24 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Oct 17 14:55:45 2011 +0000
@@ -1,3 +1,17 @@
+2011-10-17  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/ManagedDomFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java:
+	  Prepared Facets to support a "visible" attribute.
+
+	* src/main/java/de/intevation/flys/collections/OutputParser.java: Adapted
+	  the constructor call of ManagedFacetAdapter.
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  The inner class ThemeList now supports the "visible" attribute of
+	  ManagedFacets.
+
 2011-10-17  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/StyledXYSeries.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedDomFacet.java	Mon Oct 17 13:00:24 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedDomFacet.java	Mon Oct 17 14:55:45 2011 +0000
@@ -26,7 +26,7 @@
 
 
     public ManagedDomFacet(Element facet) {
-        super(null, -1, null, null, -1, -1);
+        super(null, -1, null, null, -1, -1, -1);
 
         this.facet = facet;
     }
@@ -129,6 +129,32 @@
 
 
     @Override
+    public int getVisible() {
+        if (this.visible < 0) {
+            String visible = facet.getAttributeNS(
+                ArtifactNamespaceContext.NAMESPACE_URI, "visible");
+
+            if (visible != null && visible.length() > 0) {
+                this.visible = Integer.parseInt(visible);
+            }
+        }
+
+        return this.visible;
+    }
+
+
+    @Override
+    public void setVisible(int visible) {
+        this.visible = visible;
+
+        facet.setAttributeNS(
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            "visible",
+            String.valueOf(getVisible()));
+    }
+
+
+    @Override
     public String getArtifact() {
         if (this.uuid == null || this.uuid.length() == 0) {
             String uuid = facet.getAttributeNS(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Mon Oct 17 13:00:24 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacet.java	Mon Oct 17 14:55:45 2011 +0000
@@ -27,6 +27,9 @@
     /** A property that determines if this facet is active or not. */
     protected int active;
 
+    /** A property that determines if this facet is visible or not. */
+    protected int visible;
+
     public ManagedFacet() {
     }
 
@@ -36,13 +39,15 @@
         String  desc,
         String  uuid,
         int     pos,
-        int     active)
+        int     active,
+        int     visible)
     {
         super(index, name, desc);
 
         this.uuid     = uuid;
         this.position = pos;
         this.active   = active;
+        this.visible  = visible;
     }
 
 
@@ -66,6 +71,16 @@
     }
 
 
+    public void setVisible(int visible) {
+        this.visible = visible;
+    }
+
+
+    public int getVisible() {
+        return visible;
+    }
+
+
     public String getArtifact() {
         return uuid;
     }
@@ -84,6 +99,7 @@
         ec.addAttr(facet, "active", String.valueOf(getActive()), true);
         ec.addAttr(facet, "index", String.valueOf(getIndex()), true);
         ec.addAttr(facet, "description", getDescription(), true);
+        ec.addAttr(facet, "visible", String.valueOf(getVisible()), true);
 
         return facet;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java	Mon Oct 17 13:00:24 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ManagedFacetAdapter.java	Mon Oct 17 14:55:45 2011 +0000
@@ -19,14 +19,21 @@
     public ManagedFacetAdapter() {
     }
 
-    public ManagedFacetAdapter(Facet facet, String uuid, int pos, int active) {
+    public ManagedFacetAdapter(
+        Facet   facet,
+        String  uuid,
+        int     pos,
+        int     active,
+        int     visible
+    ) {
         super(
             facet.getName(),
             facet.getIndex(),
             facet.getDescription(),
             uuid,
             pos,
-            active);
+            active,
+            visible);
 
         this.facet = facet;
     }
@@ -44,6 +51,7 @@
         ec.addAttr(e, "facet", getName(), true);
         ec.addAttr(e, "pos", String.valueOf(getPosition()), true);
         ec.addAttr(e, "active", String.valueOf(getActive()), true);
+        ec.addAttr(e, "visible", String.valueOf(getVisible()), true);
 
         return e;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Mon Oct 17 13:00:24 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Mon Oct 17 14:55:45 2011 +0000
@@ -800,8 +800,9 @@
                 String active = theme.getAttributeNS(uri, "active");
                 String idx    = theme.getAttributeNS(uri, "index");
                 String desc   = theme.getAttributeNS(uri, "description");
+                String visible = theme.getAttributeNS(uri, "visible");
 
-                addTheme(uuid, name, idx, pos, active, desc);
+                addTheme(uuid, name, idx, pos, active, desc, visible);
             }
         }
 
@@ -811,7 +812,8 @@
             String index,
             String position,
             String active,
-            String description)
+            String desc,
+            String visible)
         {
             if (logger.isDebugEnabled()) {
                 logger.debug("Add theme: ");
@@ -819,16 +821,18 @@
                 logger.debug(".. uuid: " + uuid);
                 logger.debug(".. position: " + position);
                 logger.debug(".. active: " + active);
+                logger.debug(".. visible: " + visible);
             }
 
             try {
                 int pos = Integer.parseInt(position);
                 int act = Integer.parseInt(active);
                 int idx = Integer.parseInt(index);
+                int vis = Integer.parseInt(visible);
 
                 themes.put(
                     new Integer(pos-1),
-                    new ManagedFacet(name, idx, description, uuid, pos, act));
+                    new ManagedFacet(name, idx, desc, uuid, pos, act, vis));
             }
             catch (NumberFormatException nfe) {
                 logger.warn(nfe, nfe);
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java	Mon Oct 17 13:00:24 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java	Mon Oct 17 14:55:45 2011 +0000
@@ -92,7 +92,7 @@
         List<Facet> newFacets = new ArrayList<Facet>(old.size());
 
         for (Facet f: old) {
-            newFacets.add(new ManagedFacetAdapter(f, uuid, pos++, 1));
+            newFacets.add(new ManagedFacetAdapter(f, uuid, pos++, 1, 1));
         }
 
         return newFacets;

http://dive4elements.wald.intevation.org