changeset 1744:62efd1288e34

Fix setting of masterartifact in flyscollections. flys-artifacts/trunk@3038 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 19 Oct 2011 16:04:40 +0000
parents 8a2cbf947395
children 4ae7df2a74ed
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java
diffstat 2 files changed, 32 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Oct 19 15:32:22 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Oct 19 16:04:40 2011 +0000
@@ -1,3 +1,16 @@
+2011-10-19  Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Fix masterartifact in collections in cases where the original
+	masterartifacts facets do not come first in certain list. Query
+	'backend'/db instead.
+
+	* src/main/java/de/intevation/flys/exports/WDifferencesCurveGenerator.java:
+	  (addSubtitles): Overridden, the master artifact has no range.
+
+	* src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java:
+	  Set 'real' master artifact, defined to be oldest belonging to this
+	  collection.
+
 2011-10-19  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/DefaultState.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Oct 19 15:32:22 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java	Wed Oct 19 16:04:40 2011 +0000
@@ -58,11 +58,12 @@
 
     public static final String XPATH_OUT_TYPE = "/art:action/@art:type";
 
+    public static final String XPATH_MASTER_UUID = "/art:artifact-collection/art:artifact/@art:uuid";
+
     public static final String XPATH_LOADED_RECOMMENDATIONS =
         "/art:attribute/art:loaded-recommendations";
 
 
-
     /**
      * Return description Document for this collection.
      */
@@ -217,7 +218,23 @@
 
         generator.init(format, out, context);
 
-        // TODO Determine the correct master artifact here!
+        // Get master artifact.
+        try{
+            ArtifactDatabase db = context.getDatabase();
+            CallMeta callMeta   = context.getMeta();
+            Document document = 
+            db.getCollectionsMasterArtifact(identifier(), callMeta);
+
+            //log.debug(XMLUtils.toString(document));
+
+            String masterUUID = XMLUtils.xpathString(
+            document, XPATH_MASTER_UUID, ArtifactNamespaceContext.INSTANCE);
+
+            log.error("Will set master Artifact to uuid: " + masterUUID);
+            generator.setMasterArtifact(getArtifact(masterUUID, context));
+        } catch (ArtifactDatabaseException adb) {
+            log.error(adb, adb);
+        }
 
         try {
             Document attr = getAttribute(context, name);
@@ -277,9 +294,6 @@
                 }
 
                 Artifact artifact = getArtifact(art, context);
-                if (i == 0) {
-                    generator.setMasterArtifact(artifact);
-                }
 
                 generator.doOut(
                     artifact,

http://dive4elements.wald.intevation.org