Go to main content
|
|
The following is a sample groovy script for deleting child data.
The delete child data procedure is called as follows:
delSt= conn.prepareCall("{call DELETE_USERGROUP(?,?)}"); delSt= conn.prepareCall("{call DELETE_USERROLE(?,?)}");
The procedure for DELETE_USERGROUP
is as follows:
create or replace PROCEDURE DELETE_USERGROUP ( userin IN VARCHAR2, gId IN VARCHAR2 ) AS BEGIN DELETE from USER_GROUP where USERID=userin and GROUPID=gId; END DELETE_USERGROUP;
The procedure for DELETE_USERROLE
is as follows:
create or replace PROCEDURE DELETE_USERROLE ( userin IN VARCHAR2, rId IN VARCHAR2 ) AS BEGIN DELETE from USER_ROLE where USERID=userin and ROLEID=rId; END DELETE_USERROLE;
Register the delete child data script as follows:
import org.identityconnectors.framework.common.objects.*; System.out.println("[removeMultiValuedAttributeScript] Removing Child data::"+ attributes); try { childDataEOSet = null; delSt = null; //Get UID String id = attributes.get("__UID__").getValue().get(0); if(attributes.get("USER_GROUP")!=null) { childDataEOSet=attributes.get("USER_GROUP").getValue(); //Delete child data using stored procedure delSt= conn.prepareCall("{call DELETE_USERGROUP(?,?)}"); if(childDataEOSet !=null){ System.out.println("[removeMultiValuedAttributeScript] Removing Group data."); //Iterate through child data and delete for( iterator = childDataEOSet.iterator(); iterator.hasNext(); ) { eo = iterator.next(); attrsSet = eo.getAttributes(); grpattr=AttributeUtil.find("GROUPID",attrsSet); if(grpattr!=null){ groupid=grpattr.getValue().get(0); delSt.setString(1, id); delSt.setString(2, groupid); delSt.executeUpdate(); System.out.println("[removeMultiValuedAttributeScript] Deleted Group::"+ grpattr); } }; } } } finally { if (delSt != null) delSt.close(); }; try { childDataEOSet = null; delSt = null; String id = attributes.get("__UID__").getValue().get(0); if(attributes.get("USER_ROLE")!=null) { childDataEOSet=attributes.get("USER_ROLE").getValue(); delSt= conn.prepareCall("{call DELETE_USERROLE(?,?)}"); if(childDataEOSet !=null){ System.out.println("[removeMultiValuedAttributeScript] Removing Role data."); for( iterator = childDataEOSet.iterator(); iterator.hasNext(); ) { eo = iterator.next(); attrsSet = eo.getAttributes(); roleattr=AttributeUtil.find("ROLEID",attrsSet); if(roleattr!=null){ rolename=roleattr.getValue().get(0); delSt.setString(1, id); delSt.setString(2, rolename); delSt.executeUpdate(); System.out.println("[removeMultiValuedAttributeScript] Deleted Role::"+ rolename); } }; } } } finally { if (delSt != null) delSt.close(); };