changeset 1717:755a890ecf0e

FLYSArtifactCollection.ThemeList makes now use of ManagedDomFacet to read all attributes of a Facet. flys-artifacts/trunk@2995 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 17 Oct 2011 15:53:59 +0000
parents 3ca999f507b7
children defe2cfeefa5
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java
diffstat 2 files changed, 12 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Oct 17 15:53:03 2011 +0000
+++ b/flys-artifacts/ChangeLog	Mon Oct 17 15:53:59 2011 +0000
@@ -1,3 +1,9 @@
+2011-10-17  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  The inner class ThemeList makes now use of ManagedDomFacet to read the
+	  attributes of Facets saved in the Collection's attribute.
+
 2011-10-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	flys/issue314: Variables in datacage are now case insensitive.
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Mon Oct 17 15:53:03 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Mon Oct 17 15:53:59 2011 +0000
@@ -33,6 +33,7 @@
 
 import de.intevation.flys.artifacts.context.FLYSContext;
 import de.intevation.flys.artifacts.model.ManagedFacet;
+import de.intevation.flys.artifacts.model.ManagedDomFacet;
 import de.intevation.flys.exports.OutGenerator;
 import de.intevation.flys.themes.Theme;
 import de.intevation.flys.themes.ThemeFactory;
@@ -775,13 +776,13 @@
         }
 
         protected void parse(Document output) {
-            NodeList themes = (NodeList) XMLUtils.xpath(
+            NodeList themeList = (NodeList) XMLUtils.xpath(
                 output,
                 "art:output/art:facet",
                 XPathConstants.NODESET,
                 ArtifactNamespaceContext.INSTANCE);
 
-            int num = themes != null ? themes.getLength() : 0;
+            int num = themeList != null ? themeList.getLength() : 0;
 
             logger.debug("Output has " +  num + " elements.");
 
@@ -792,50 +793,10 @@
             String uri = ArtifactNamespaceContext.NAMESPACE_URI;
 
             for (int i = 0; i < num; i++) {
-                Element theme = (Element) themes.item(i);
-
-                String name   = theme.getAttributeNS(uri, "facet");
-                String uuid   = theme.getAttributeNS(uri, "artifact");
-                String pos    = theme.getAttributeNS(uri, "pos");
-                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, visible);
-            }
-        }
+                Element theme = (Element) themeList.item(i);
 
-        protected void addTheme(
-            String uuid,
-            String name,
-            String index,
-            String position,
-            String active,
-            String desc,
-            String visible)
-        {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Add theme: ");
-                logger.debug(".. name: " + name);
-                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, desc, uuid, pos, act, vis));
-            }
-            catch (NumberFormatException nfe) {
-                logger.warn(nfe, nfe);
+                ManagedDomFacet facet = new ManagedDomFacet(theme);
+                themes.put(new Integer(facet.getPosition()-1), facet);
             }
         }
 

http://dive4elements.wald.intevation.org