changeset 913:9976d99aea34

Added loadMany-function to LoadArtifactService. flys-client/trunk@2774 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 16 Sep 2011 11:09:39 +0000
parents 2c8f1112be37
children 39a39e9be5af
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/LoadArtifactService.java flys-client/src/main/java/de/intevation/flys/client/client/services/LoadArtifactServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java
diffstat 4 files changed, 61 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Sep 16 09:35:42 2011 +0000
+++ b/flys-client/ChangeLog	Fri Sep 16 11:09:39 2011 +0000
@@ -1,3 +1,12 @@
+2011-09-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
+
+  Added a loadMany-Function to LoadArtifactService.
+
+	* src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java,
+	  src/main/java/de/intevation/flys/client/client/services/LoadArtifactService.java,
+	  src/main/java/de/intevation/flys/client/client/services/LoadArtifactServiceAsync.java:
+	  Added a loadMany-Function to LoadArtifactService
+
 2011-09-16  Raimund Renkert <raimund.renkert@intevation.de>
 
 	Issue203
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/LoadArtifactService.java	Fri Sep 16 09:35:42 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/LoadArtifactService.java	Fri Sep 16 11:09:39 2011 +0000
@@ -19,5 +19,13 @@
         String         url,
         String         locale)
     throws ServerException;
+
+    Artifact[] loadMany(
+        Collection       parent,
+        Recommendation[] recom,
+        String           factory,
+        String           url,
+        String           locale)
+    throws ServerException;
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/LoadArtifactServiceAsync.java	Fri Sep 16 09:35:42 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/LoadArtifactServiceAsync.java	Fri Sep 16 11:09:39 2011 +0000
@@ -19,5 +19,13 @@
         String         url,
         String         locale,
         AsyncCallback<Artifact> callback);
+
+    public void loadMany(
+        Collection       parent,
+        Recommendation[] recom,
+        String           factory,
+        String           url,
+        String           locale,
+        AsyncCallback<Artifact[]> callback);
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java	Fri Sep 16 09:35:42 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java	Fri Sep 16 11:09:39 2011 +0000
@@ -1,5 +1,7 @@
 package de.intevation.flys.client.server;
 
+import java.util.ArrayList;
+
 import de.intevation.flys.client.shared.exceptions.ServerException;
 import de.intevation.flys.client.shared.model.Artifact;
 import de.intevation.flys.client.shared.model.Collection;
@@ -48,5 +50,39 @@
 
         throw new ServerException(ERROR_LOAD_ARTIFACT);
     }
+
+    public Artifact[] loadMany(
+        Collection     parent,
+        Recommendation[] recoms,
+        String         factory,
+        String         url,
+        String         locale
+    )
+    throws ServerException {
+        System.out.println(
+            "LoadArtifactServiceImpl.loadMany: " + recoms[0].getMasterArtifact());
+        ArrayList<Artifact> artifacts = new ArrayList<Artifact>();
+
+        // 1) Clone the Artifacts specified in >>recom<<
+        for (Recommendation recom : recoms) {
+            Artifact clone = ArtifactHelper.createArtifact(
+                url, locale, factory, recom);
+    
+            if (clone != null) {
+                System.out.println("Successfully create Artifact Clone. Add now!");
+                Collection c = CollectionHelper.addArtifact(
+                    parent, clone, url, locale);
+    
+                if (c != null) {
+                    System.out.println("Successfully added Clone to Collection.");
+    
+                    artifacts.add(clone);
+                }
+            }
+        }
+        return artifacts.toArray(new Artifact[artifacts.size()]);
+
+        //throw new ServerException(ERROR_LOAD_ARTIFACT);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org