[Dive4elements-commits] [PATCH 5 of 7] Move loading of the full Collection to an own method

Wald Commits scm-commit at wald.intevation.org
Tue Dec 11 16:27:40 CET 2012


# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1355239541 -3600
# Node ID 5025acdb3815c8a8d5d886e4b013fec3887c7e75
# Parent  bb9ce9aece70b43ce7620674a9701205d503806a
Move loading of the full Collection to an own method

diff -r bb9ce9aece70 -r 5025acdb3815 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue Dec 11 16:24:57 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue Dec 11 16:25:41 2012 +0100
@@ -391,49 +391,54 @@
 
 
     protected void artifactChanged() {
-        ArtifactDescription desc = getArtifact().getArtifactDescription();
-        //OutputMode[] outs        = desc.getOutputModes();
-        final Recommendation[] recom = desc.getRecommendations();
-
         Collection c = getCollection();
 
         if (c != null) {
-            Config config = Config.getInstance();
-            String locale = config.getLocale();
-
-            describeCollectionService.describe(c.identifier(), locale,
-                new AsyncCallback<Collection>() {
-                    @Override
-                    public void onFailure(Throwable caught) {
-                        GWT.log("Could not DESCRIBE collection.");
-                        SC.warn(FLYS.getExceptionString(messages, caught));
-                    }
-
-
-                    @Override
-                    public void onSuccess(Collection newCollection) {
-                        GWT.log("Successfully DESCRIBED collection.");
-                        boolean loaded = true;
-                        for (Recommendation r: recom) {
-                            if(!newCollection.loadedRecommendation(r)) {
-                                loaded = false;
-                            }
-                        }
-                        if  (!loaded) {
-                            loadRecommendedArtifacts(recom);
-                        }
-                        else {
-                            setCollection(newCollection);
-                        }
-                    }
-                }
-            );
+            loadCollection(c);
         }
         else {
             updateView();
         }
     }
 
+    /**
+     * Loads all information of a collection
+     * @param c the Collection
+     */
+    private void loadCollection(Collection c) {
+        ArtifactDescription desc = getArtifact().getArtifactDescription();
+        final Recommendation[] recom = desc.getRecommendations();
+        Config config = Config.getInstance();
+        String locale = config.getLocale();
+
+        describeCollectionService.describe(c.identifier(), locale,
+            new AsyncCallback<Collection>() {
+                @Override
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not DESCRIBE collection.");
+                    SC.warn(FLYS.getExceptionString(messages, caught));
+                }
+
+                @Override
+                public void onSuccess(Collection newCollection) {
+                    GWT.log("Successfully DESCRIBED collection.");
+                    boolean loaded = true;
+                    for (Recommendation r: recom) {
+                        if(!newCollection.loadedRecommendation(r)) {
+                            loaded = false;
+                        }
+                    }
+                    if  (!loaded) {
+                        loadRecommendedArtifacts(recom);
+                    }
+                    else {
+                        setCollection(newCollection);
+                    }
+                }
+            }
+        );
+    }
+
 
     /**
      * Returns the collection of displayed by this view.


More information about the Dive4elements-commits mailing list