Monday, November 22, 2010

Task Assignment Adapter Creation and use




Task Assignment adapter is used to acertain the user/group to whom the process task should be assigned in a provisioning workflow. Task Assignment adapters are in use Jupiter onwards only.

Example to use a Task Assignment Adapter:

  1. Login into Java client with an admin user
  2. Move to Resource Management -> Resource Objects
  3. Create a resource object
  4. Move to Process Management -> Process Definition
  5. Create a provisioning process for the above resource object
  6. Create a new task in the above process and save
  7. Move to Development Tools -> Adapter Factory
  8. Enter valid adapter name, description and select “Task Assignment ” as adapter type
  9. Save the adapter
  10. Verify in the variable list tab that 2 default adapter return variables are created
  11. In the Adapter Tasks tab, click on Assign to add a task to the adapter. Select to add a java task
  12. In the API source, select the appropriate jar (eg. newtask.jar). Also select appropriate Methods and save the task.
  13. Add two java tasks to the above adapter:
    1. For first select method as getType and map the variables as “Output variable” -> Adapter Variable -> Return Variable for key type. Map the second variable to a literal “User/Group” and the third variable to anything.
    2. For second select method as getKey and map the variables as “Output variable” -> Adapter Variable -> Return Variable for key. Map the second variable to a user/group key and the third variable to anything.
  14. Save and compile the adapter
  15. Move to Process Management -> Process Definition and query for the process created in step 5
  16. Double click to invoke the edit task dialog for the task created in step 6 and move to the assignment tab
  17. Double click on the Target type lookup field and select either User/Group
  18. In the adapter lookup field, select the adapter created in step 9.
  19. After making an adapter association, select the row and click on Map button
  20. Map the adapter return variables to task information and save
  21. Now provision the resource object to a user/organization



<Expected Result>

Verify that the tasks (Approval/Provisioning) get assigned to appropriate users as mapped in the adapter.

Other things to test:

  1. Provision to organization
  2. Check for both approval and provisioning processes
  3. Login with appropriate user and complete the assigned task




3 comments:

  1. To create a task assignment adapter we need to create two methods one returning the return type either a user or a group and then one to return the key.This can be explained as follows:

    public String getApprovalGroupKey(String location){

    // build the group name from location
    String groupName = location + " "+"Admins";
    System.out.println("groupName " + groupName);
    long returnValue = 0;
    String sReturnVal=null;

    // find the group with group name as groupName
    HashMap grpAttrMap = new HashMap();
    grpAttrMap.put("Groups.Group Name",groupName);

    try {
    tcResultSet grp = groupOpr.findGroups(grpAttrMap);
    if(grp.getRowCount() > 0){
    System.out.println("-------");
    // group with group name groupName was found. Return
    // the key of that group
    String[] str=grp.getColumnNames();
    System.out.println(str[0]+"-----");
    returnValue=grp.getLongValue("Groups.Key");
    sReturnVal=new Long(returnValue).toString();

    //returnValue = grp.getLongValue(groupName);
    System.out.println("returnValue if " + returnValue);
    }else{
    HashMap grpAttrMapSys = new HashMap();
    grpAttrMapSys.put("Groups.Group Name","System Administrators");
    tcResultSet grpSys = groupOpr.findGroups(grpAttrMapSys);
    returnValue = grpSys.getLongValue("System Administrators");
    sReturnVal=new Long(returnValue).toString();
    System.out.println("returnValue else " + returnValue);
    // find the “System Administrators” group and return the
    // key for this group
    }
    } catch (tcAPIException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (tcColumnNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    System.out.println("---------Return Value"+sReturnVal);
    return sReturnVal;
    }


    public String getType()
    {
    return "Group"; //for a user this value will be User.
    }

    ReplyDelete
  2. how to assign the retrieved group key to the task assignment key?

    ReplyDelete
  3. Hi,

    Once you create a task assignment adapter and map it the respective process the group key will be assigned to the respective assignment. The method above explains to get the group key and assign the same with the task assignment.

    Thanks,
    vishnu

    ReplyDelete