Pages

Tuesday, April 29, 2014

tcProvisioningOperationsIntf API addTask example

The tcProvisioningOperationsIntf  inteface API being used to add the task to process form instance programmatically.

Pre-Requisite:

Initial Setup.

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


Client Code Setup

tcProvisioningOperationsIntf  API Usage:

1. Retrieving the Process Instance key
2. Retrieving the All the Tasks available for the Process Instance.
3. Add  the Process Task Instance to Process Form

Tasks Needs to be Performed:

1.    Create the OIMClient Handle


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

2.    Get tcProvisioningOperationsIntf service object


tcProvisioningOperationsIntf provisioningServiceIntf = client.getService(tcProvisioningOperationsIntf.class);
TaskDefinitionOperationsIntf taskdefinition = client.getService(TaskDefinitionOperationsIntf.class);
tcUserOperationsIntf userOperationsIntf=client.getService(tcUserOperationsIntf.class);


3.  Retrieving the Process Instance Key Based on the User Key.

long userKey=123456789;
Map<String,Long> resources= new HashMap<String,Long>();

                tcResultSet trs= userOperationsIntf.getObjects(userKey);
                if(trs != null)
                {
                    int count=trs.getRowCount();
                    for(int i=0;i<count;i++)
                    {
                        trs.goToRow(i);
                        String objectName=trs.getStringValue("Objects.Name");
                        String status=trs.getStringValue("Objects.Object Status.Status");

                        if(status.equalsIgnoreCase("Provisioned") || status.equalsIgnoreCase("Enabled"))
                        {
                            resources.put(objectName,trs.getLongValue("Process Instance.Key"));
                        }
                    }
                }



4. Retrieving the All the Tasks available for the Process Instance

// Resource Name. My Example Resource Name is AD User
String resourceName="AD User";
long  processInstance =  resources.containsKey(resourceName) ? resources.get(resourceName) : -1;

if(processInstance ==-1)
{
    return;
}

        Map<String, Long> listTasks= new HashMap<String,Long>();
        try
        {
            Map<String, String> filter=new HashMap<String,String>();
            tcResultSet trs= taskdefinition.getTaskDetail(processInstance, filter);
            if(trs != null && !trs.isEmpty())
            {
                int count=trs.getRowCount();
                for(int i=0;i<count;i++)
                {
                    trs.goToRow(i);
                    //displayData(trs);
                    listTasks.put(trs.getStringValue("Process Definition.Tasks.Task Name"), trs.getLongValue("Process Definition.Tasks.Key"));
                }
            }
           
        } catch (tcAPIException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (tcColumnNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

5.   Add  the Process Task Instance to Process Form


String taskName= "Last Name Updated";
if(listTasks.containsKey(taskName))
{
    long taskKey= listTasks.get(taskName);
            try
        {
            //tcProvisioningOperationsIntf.getT
            tcProvisioningOperationsIntf.addProcessTaskInstance(taskKey, processInstance );

        } catch (tcAPIException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (tcTaskNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}


1 comment: