Pages

Thursday, January 2, 2014

tcFormInstanceOperationsIntf API Example

The tcFormInstanceOperationsIntf inteface API being used to retrieve and manipulate the the Active Directory Process form data and also child data. In my example I have used first name to update data in the AD Process form in OIM, and also Adding, Updating, and Removing group Names in OIM using the process child form as Follows:

Retrieving the Process Parent and Child Form Data, Updating the Parent and Process Child Form Data, Adding the Process Form Child Data, Removing the Process Form Child Data, and Retrieving the Parent and Child Process Form Definition Keys, and Retrieving the Process Form Active Version  in the Oracle Identity Manager repository.

Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

tcFormInstanceOperationsIntf  API Usage:

Process Form Data Example:


1. Retrieving the Process Form Data,
2. Updating the Process Form Data,

Process Form Child Data Example:

3. Retrieving the Process Form Definition Key,
4. Retrieving the Process Form Active Version,
5. Retrieving the Process Form Child Definition Key,
6. Retrieving the Process Form Child Data,
7. Adding the Process Form Child Data,
8. Updating the Process Form Child Data,
9. Removing the Process Form Child Data.

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get tcFormInstanceOperationsIntf service object

tcFormInstanceOperationsIntf formInstanceIntf = client.getService(tcFormInstanceOperationsIntf.class);

Process Form Data Example:

3.  Retrieving the Process Form Data. 

// This Key is Getting from the Process Definition Task 
long processInstanceKey= 123456
tcResultSet trs = formInstanceIntf.getProcessFormData(processInstanceKey);
int count=trs.getRowCount();
for(int i=0;i<count;i++){
                trs.goToRow(i);
 
        String columnNames[] = trs.getColumnNames();
        for (String string : columnNames)
        {
            try {
                System.out.println(string + " - " + trs.getStringValue(string));
            } catch (tcAPIException | tcColumnNotFoundException e)
           {
                e.printStackTrace();
            }
        }
}

4.  Updating the Process Form Data. 


// Updating the Users First Name
String adColumnName="AD_USER_FNAME";
Map updateData=new HashMap();
updateData.put(adColumnName, "Liyaqat");
formInstanceIntf.setProcessFormData(pkey, updateData);


Process Form Child Data Example:

5.  Retrieving the Process Form Definition Key.

long processDefKey = formInstanceIntf.getProcessFormDefinitionKey(processInstanceKey);

6.  Retrieving the Process Form Active Version.

int formActiveVersion=formInstanceIntf.getActiveVersion(processDefKey);

7.  Retrieving the Process Form Child Definition Key.

String childFormName="UD_ADUSRC";
tcResultSet childTrsDef=formInstanceIntf.getChildFormDefinition(processDefKey, formActiveVersion);
int childCount=childTrsDef.getRowCount();
long childDefKey=-1;
for(int i=0;i<childCount;i++)
{
   
childTrs.goToRow(i);
    //Retreiving the Child Table Name and Child Table Definition Key
    String tableName=childTrsDef.getStringValue("Structure Utility.Table Name");
    childDefKey = childTrsDef..getLongValue("Structure Utility.Child Tables.Child Key");
    if(tableName.equalsIgnoreCase(childFormName))
    {
       break;
    }
}

8.  Retrieving the Process Form Child Data.


getProcessFormChildData
tcResultSet childTrs=formInstanceIntf.getChildFormDefinition(processDefKey, formActiveVersion);
int childCount=childTrs.getRowCount();
Map<String,Long> childData= new HashMap<String,Long>();
for(int i=0;i<childCount;i++)
{
            childTrs.goToRow(i);
            try 
           {
    String groupName=childTrs.getStringValue("UD_ADUSRC_GROUPNAME");
    long groupKey = childTrs..getLongValue("UD_ADUSRC_KEY");
    childData.put(groupName,groupKey);
            } catch (tcAPIException | tcColumnNotFoundException e)
           {
                e.printStackTrace();
            }

}

9.  Adding the Process Form Child Data.

String groupName="cn=Admin,ou=groups,dc=test,dc=com";
String childColumnName="UD_ADUSRC_GROUPNAME";
Map<String, String> childData= new HashMap<String,String>();
data.put(childColumnName, groupName);
formInstanceIntf.addProcessFormChildData(childDefKey,processInstanceKey,childData);

10.  Updating the Process Form Child Data.

// Updating AD Group Names are not supported by OIM. First you need to remove the existing group Name and add the new group Name.

Supported Option:
 
String updateGroupName="cn=Admin1,ou=groups,dc=test,dc=com";
 If(childData.ContainsKey(groupName))
{
   // Remove the Existing Group Member Ship for the user
   long adGroupKey =   childData.get(groupName);
   formInstanceIntf.removeProcessFormChildData(childDefKey, adGroupKey);

// Adding the  Group Member Ship for the user
Map<String, String> childData= new HashMap<String,String>();
data.put(childColumnName, updateGroupName);
formInstanceIntf.addProcessFormChildData(childDefKey,processInstanceKey,childData);
}
Un-Supported Option:
If using this option, it will only update in the OIM repository and not updated in the target resource. In our example is Active Directory.
 
 If(childData.ContainsKey(groupName))
{
   // Remove the Existing Group Member Ship for the user
   long adGroupKey =   childData.get(groupName);
// Updating the  Group Member Ship for the user in OIM Repository only.
Map<String, String> childData= new HashMap<String,String>();
data.put(childColumnName, updateGroupName);
formInstanceIntf.updateProcessFormChildData(childDefKey,adGroupKey,childData); 
}

11.  Removing the Process Form Child Data.

String removeGroupName="cn=Admin1,ou=groups,dc=test,dc=com";
 If(childData.ContainsKey(removeGroupName))
{
   // Remove the Existing Group Member Ship to the the user in OIM and also target resource
   long adGroupKey =   childData.get(groupName);
   formInstanceIntf.removeProcessFormChildData(childDefKey, adGroupKey);
}








No comments:

Post a Comment