changeset 1668:6566c7868456

Added facet and index information to theme which are stored at CollectionItems. flys-artifacts/trunk@2880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 04 Oct 2011 11:28:37 +0000 (2011-10-04)
parents f1af0c07a6ee
children 0296684a5553
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java flys-artifacts/src/main/java/de/intevation/flys/themes/DefaultTheme.java flys-artifacts/src/main/java/de/intevation/flys/themes/Theme.java
diffstat 4 files changed, 62 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Oct 04 07:37:05 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Oct 04 11:28:37 2011 +0000
@@ -1,3 +1,13 @@
+2011-10-04  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/themes/Theme.java,
+	  src/main/java/de/intevation/flys/themes/DefaultTheme.java: Added
+	  getter/setter methods to provide a facet (string) and index (int). Both
+	  values are written as attribute to the Theme's XML representation.
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Set the "facet" and "index" values of themes.
+
 2011-10-04  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue346 (W-INFO / Anzeige der Höheninformation)
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Tue Oct 04 07:37:05 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Tue Oct 04 11:28:37 2011 +0000
@@ -291,6 +291,7 @@
                         art,
                         outName,
                         facetName,
+                        theme.getIndex(),
                         context));
             }
         }
@@ -457,6 +458,7 @@
         String      uuid,
         String      outName,
         String      facet,
+        int         index,
         CallContext context)
     throws    ArtifactDatabaseException
     {
@@ -477,7 +479,7 @@
         Document attr = db.getCollectionItemAttribute(identifier(), uuid, meta);
 
         if (attr == null) {
-            attr = initItemAttribute(uuid, facet, context);
+            attr = initItemAttribute(uuid, facet, index, context);
 
             if (attr == null) {
                 return null;
@@ -501,14 +503,15 @@
 
         Node theme = (Node) XMLUtils.xpath(
             tmp,
-            "art:themes/theme[@name='" + themeName + "']",
+            "art:themes/theme[@facet='" + facet +
+            "' and @index='" + String.valueOf(index) + "']",
             XPathConstants.NODE,
             ArtifactNamespaceContext.INSTANCE);
 
         if (theme == null) {
             log.warn("Could not find the theme in attribute of: " + uuid);
 
-            Theme t = getThemeForFacet(uuid, facet, context);
+            Theme t = getThemeForFacet(uuid, facet, index, context);
 
             if (t == null) {
                 log.warn("No theme found for facet: " + facet);
@@ -601,11 +604,12 @@
     protected Document initItemAttribute(
         String      uuid,
         String      facet,
+        int         index,
         CallContext context)
     {
         log.info("FLYSArtifactCollection.initItemAttribute");
 
-        Theme t = getThemeForFacet(uuid, facet, context);
+        Theme t = getThemeForFacet(uuid, facet, index, context);
 
         if (t == null) {
             log.info("Could not find theme for facet. Cancel initialization.");
@@ -662,6 +666,7 @@
     protected Theme getThemeForFacet(
         String uuid,
         String facet,
+        int    index,
         CallContext context)
     {
         log.info("FLYSArtifactCollection.getThemeForFacet: " + facet);
@@ -670,7 +675,14 @@
             ? (FLYSContext) context
             : (FLYSContext) context.globalContext();
 
-        return ThemeFactory.getTheme(flysContext, facet);
+        Theme t = ThemeFactory.getTheme(flysContext, facet);
+
+        if (t != null) {
+            t.setFacet(facet);
+            t.setIndex(index);
+        }
+
+        return t;
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/themes/DefaultTheme.java	Tue Oct 04 07:37:05 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/DefaultTheme.java	Tue Oct 04 11:28:37 2011 +0000
@@ -23,6 +23,10 @@
     /** The description of the theme.*/
     protected String description;
 
+    protected String facet;
+
+    protected int index;
+
 
     /** The map storing the fields of this theme.*/
     protected Map<String, ThemeField> fields;
@@ -56,6 +60,26 @@
     }
 
 
+    public String getFacet() {
+        return facet;
+    }
+
+
+    public void setFacet(String facet) {
+        this.facet = facet;
+    }
+
+
+    public int getIndex() {
+        return index;
+    }
+
+
+    public void setIndex(int index) {
+        this.index = index;
+    }
+
+
     public void addAttribute(String name, String value) {
         if (name != null && value != null) {
             attr.put(name, value);
@@ -111,6 +135,8 @@
         ElementCreator cr = new ElementCreator(doc, null, null);
 
         Element theme = cr.create("theme");
+        theme.setAttribute("facet", facet);
+        theme.setAttribute("index", String.valueOf(index));
 
         appendAttributes(cr, theme);
         appendFields(cr, theme);
--- a/flys-artifacts/src/main/java/de/intevation/flys/themes/Theme.java	Tue Oct 04 07:37:05 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/themes/Theme.java	Tue Oct 04 11:28:37 2011 +0000
@@ -33,6 +33,15 @@
     String getDescription();
 
 
+    String getFacet();
+
+    void setFacet(String facet);
+
+    int getIndex();
+
+    void setIndex(int index);
+
+
     /**
      * Adds a new attribute.
      *

http://dive4elements.wald.intevation.org