Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-29 Thread Adam Young

On 10/28/2010 05:30 PM, Adam Young wrote:

On 10/28/2010 05:22 PM, Adam Young wrote:

 delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of deletion.  While this works for all 
deletes,

it is slower than bulk.


___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Found one problem myself:  the '*_remove_member'  approach only works 
one way, not both for removing associations.



___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

This version matches the serial and bulk associators with the deleter
From f9b4d2723c1087652d03d2a2af850b65d1f04a3c Mon Sep 17 00:00:00 2001
From: Adam Young ayo...@redhat.com
Date: Thu, 28 Oct 2010 17:20:12 -0400
Subject: [PATCH] delete associations

Uses code very similar to the search code for deleting associations
Had to modify how we were configuring for bulk so that the logic for delete matched the logic for enroll
---
 install/static/associate.js|  199 
 install/static/group.js|6 +-
 install/static/host.js |4 +-
 install/static/serverconfig.js |4 +-
 install/static/user.js |8 +-
 5 files changed, 190 insertions(+), 31 deletions(-)

diff --git a/install/static/associate.js b/install/static/associate.js
index 7daa0cf..e538e3d 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -25,7 +25,7 @@
 /**
 *This associator is built for the case where each association requires a separate rpc
 */
-function SerialAssociator(form, manyObjPkeys, on_success)
+function serial_associate(form, manyObjPkeys, on_success)
 {
 var associator = this;
 this.form = form;
@@ -59,11 +59,80 @@ function SerialAssociator(form, manyObjPkeys, on_success)
 }
 }
 
+
+function serial_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+   many_entity_pkeys, on_success){
+that = {};
+that.one_entity = one_entity;
+that.on_success = on_success;
+that.many_entity_pkeys = many_entity_pkeys;
+that.delete_next = function(){
+var  many_entity_pkey =  this.many_entity_pkeys.shift();
+if (many_entity_pkey){
+var options = {};
+options[one_entity] = one_entity_pkey;
+var args = [many_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert(error deleting member: 
+   +data.error.message);
+ }else{
+ that.delete_next();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert(associateFailure);
+ },
+ many_entity );
+}else{
+this.on_success();
+}
+}
+
+that.delete_next();
+}
+
+function bulk_delete(delete_method, one_entity, one_entity_pkey, many_entity,
+ many_entity_pkeys, on_success){
+if (many_entity_pkeys.length){
+var options = {};
+options[one_entity] = one_entity_pkey;
+
+var option = many_entity_pkeys.shift();
+while(many_entity_pkeys.length  0) {
+option += ',' + many_entity_pkeys.shift();
+}
+
+var options = {
+'all':true
+};
+options[many_entity] = option;
+var args = [one_entity_pkey];
+ipa_cmd( delete_method,args, options ,
+ function(data, text_status, xhr) {
+ if (data.error){
+ alert(error deleting member: 
+   +data.error.message);
+ }else{
+ on_success();
+ }
+ },
+ function(xhr, text_status, error_thrown) {
+ alert(associateFailure);
+ },
+ one_entity );
+}else{
+on_success();
+}
+}
+
+
 /**
 *This associator is for the common case where all the asociations can be sent
 in a single rpc
 */
-function BulkAssociator(form, manyObjPkeys, on_success)
+function bulk_associate(form, manyObjPkeys, on_success)
 {
 var associator = this;
 this.form = form;
@@ -103,7 +172,7 @@ function BulkAssociator(form, manyObjPkeys, on_success)
  *  Create a form for a one to many association.
  *
  */
-function AssociationForm(oneObj, pkey, manyObj, on_success, associatorConstructor, method)
+function AssociationForm(oneObj, pkey, manyObj, on_success, 

Re: [Freeipa-devel] [PATCH] freeipa-admiyo-freeipa-0070-delete-associations.patch

2010-10-29 Thread Endi Sukma Dewata

On 10/29/2010 10:33 AM, Adam Young wrote:

On 10/28/2010 05:30 PM, Adam Young wrote:

On 10/28/2010 05:22 PM, Adam Young wrote:

delete associations

Uses code very similar to the search code for deleting associations
Only uses the serial means of deletion. While this works for all
deletes,
it is slower than bulk.



Found one problem myself: the '*_remove_member' approach only works
one way, not both for removing associations.



This version matches the serial and bulk associators with the deleter


NACK. The enrollment  deletion work, but there are some issues:
- The unit test failed because it's still referring to the old
  associator names.
- The ipa_entity_set_association_definition() invocation in aci.js is
  still using the old parameter.
- The variable 'that' in serial_delete() is defined as global variable.
- The members in the association list are clickable but it brings you
  to an empty page. I see the note in the code saying that this is not
  working yet, I think the link should be disabled for now.
- Deleter's method name is hardcoded, but this can be fixed later when
  needed.
- There are some trailing white spaces in the patch.

--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel