changeset 841:e699adf3b092

Fix loading of recommendations when collection is not yet in place. flys-client/trunk@2561 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 24 Aug 2011 13:21:15 +0000
parents 18fc7afe0251
children 95fd96b3a19f
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java
diffstat 2 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Aug 24 13:17:22 2011 +0000
+++ b/flys-client/ChangeLog	Wed Aug 24 13:21:15 2011 +0000
@@ -1,3 +1,13 @@
+2011-08-24	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
+
+	Fix loading of recommendations when collection is not yet in place.
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java
+	  (createNewCollection):
+	  Load recommendations when new Collection is created.
+	  (onParameterChange):
+	  Guard call to loadRecommendation to avoid NPE when no collection is yet set.
+
 2011-08-24	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
 
 	* src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Aug 24 13:17:22 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Aug 24 13:21:15 2011 +0000
@@ -226,6 +226,14 @@
 
                     Artifact artifact = getArtifact();
                     addArtifactToCollection(artifact);
+                    // Load recommendations, if any.
+                    ArtifactDescription desc = 
+                         artifact.getArtifactDescription();
+                    Recommendation[] recom = desc.getRecommendations();
+
+                    if (recom != null && collection != null) {
+                        loadRecommendedArtifacts(recom);
+                    }
                 }
             });
     }
@@ -335,14 +343,14 @@
         OutputMode[] outs        = desc.getOutputModes();
         Recommendation[] recom   = desc.getRecommendations();
 
-        if (recom != null) {
-            loadRecommendedArtifacts(recom);
-        }
-
         setArtifact(art);
 
         Collection c = getCollection();
 
+        if (recom != null && collection != null) {
+            loadRecommendedArtifacts(recom);
+        }
+
         if (outs != null && c == null) {
             User user = getFlys().getCurrentUser();
             createNewCollection(user.identifier());
@@ -612,7 +620,6 @@
             return;
         }
 
-
         for (final Recommendation recommendation: recommendations) {
             if (collection.loadedRecommendation(recommendation)) {
                 continue;

http://dive4elements.wald.intevation.org