Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Added overloaded method for RunMultipleActions()
......................................................................

webadmin: Added overloaded method for RunMultipleActions()

The overloaded method accepts only one VdcActionType, and runs it
multiple times. It also accepts a single callback, to be executed
after all identical actions have returned successfully.

Also changed the original RunMultipleActions() to accept List rather
than ArrayList (it shouldn't care about the implementation).

Change-Id: Ifbe1f99f72238714028b7f7762d67109559c473e
Signed-off-by: Lior Vernia <lver...@redhat.com>
---
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
1 file changed, 31 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/15859/1

diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
index 5cd3c10..cbec071 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/Frontend.java
@@ -4,6 +4,7 @@
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -616,9 +617,36 @@
         RunMultipleAction(actionType, parameters, null, null);
     }
 
-    public static void RunMultipleActions(final ArrayList<VdcActionType> 
actionTypes,
-            final ArrayList<VdcActionParametersBase> parameters,
-            final ArrayList<IFrontendActionAsyncCallback> callbacks,
+    /**
+     * A convenience method that calls RunMultipleActions with just the one 
VdcActionType for all actions, and a single
+     * callback to be called when all actions have succeeded.
+     *
+     * @param actionType
+     *            the action to be repeated.
+     * @param parameters
+     *            the parameters of each action.
+     * @param successCallback
+     *            the callback to be executed when all actions have succeeded.
+     */
+    public static void RunMultipleActions(VdcActionType actionType,
+            List<VdcActionParametersBase> parameters,
+            IFrontendActionAsyncCallback successCallback) {
+
+        if (parameters == null || parameters.isEmpty()) {
+            return;
+        }
+        int n = parameters.size();
+        List<VdcActionType> actionTypes = new 
LinkedList<VdcActionType>(Collections.nCopies(n, actionType));
+        List<IFrontendActionAsyncCallback> callbacks =
+                new 
LinkedList<IFrontendActionAsyncCallback>(Collections.<IFrontendActionAsyncCallback>
 nCopies(n - 1,
+                        null));
+        callbacks.add(successCallback);
+        RunMultipleActions(actionTypes, parameters, callbacks, null, null);
+    }
+
+    public static void RunMultipleActions(final List<VdcActionType> 
actionTypes,
+            final List<VdcActionParametersBase> parameters,
+            final List<IFrontendActionAsyncCallback> callbacks,
             final IFrontendActionAsyncCallback failureCallback,
             final Object state) {
         if (actionTypes.isEmpty() || parameters.isEmpty() || 
callbacks.isEmpty())


-- 
To view, visit http://gerrit.ovirt.org/15859
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbe1f99f72238714028b7f7762d67109559c473e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <lver...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to