OIM API to Get Provisioning/Pending Tasks


  1. package com.oimacademy.provision;
  2. import java.sql.Connection;
  3. import java.sql.DriverManager;
  4. import java.sql.ResultSet;
  5. import java.sql.Statement;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import Thor.API.tcResultSet;
  11. import Thor.API.Operations.tcProvisioningOperationsIntf;
  12. import com.oimacademy.connection.Platform;
  13. public class GetProvisioningTasks {
  14.  public static void main(String[] args) { 
  15.   try{ 
  16.    System.out.println("Startup..."); 
  17.    System.out.println("Getting configuration...");    
  18.    tcProvisioningOperationsIntf provOperIntf  = (tcProvisioningOperationsIntf) Platform.getService(Thor.API.Operations.tcProvisioningOperationsIntf.class);
  19.    String resourceName = "OID User";
  20.    String taskName = "Direct Provision";
  21.    Map<String, String> filter= new HashMap<String,String>();
  22.    filter.put("Objects.Name", resourceName);
  23.    filter.put("Process Definition.Tasks.Task Name",taskName);
  24.    String taskStaus[]= new String[]{"Rejected"};
  25.    tcResultSet trs=provOperIntf.findAllOpenProvisioningTasks(filter,taskStaus);
  26.    List<Map<String,Object>> taskLists= new ArrayList<Map<String,Object>>();
  27.    System.out.println("Started processing...");
  28.    int rowCount=trs.getRowCount();
  29.    System.out.println("Total tasks to be retried: " + rowCount);   
  30.    //Get all tasks to re-tried
  31.    if(rowCount >0){
  32.     for(int i=0;i<rowCount ;i++)
  33.     {
  34.      trs.goToRow(i);
  35.      Map<String,Object> map= new HashMap<String,Object>();
  36.      map.put("Process Instance.Task Details.Key",trs.getLongValue("Process Instance.Task Details.Key"));
  37.      map.put("Process Instance.Task Information.Target User",trs.getStringValue("Process Instance.Task Information.Target User"));
  38.      map.put("Process Instance.Key",trs.getLongValue("Process Instance.Key"));
  39.      map.put("Process Definition.Tasks.Key",trs.getLongValue("Process Definition.Tasks.Key"));
  40.      map.put("Process Definition.Tasks.Task Name",trs.getStringValue("Process Definition.Tasks.Task Name"));
  41.      taskLists.add(map);
  42.      System.out.println("added task: " + i);
  43.     }
  44.    }
  45.    System.out.println("taskLists size: " + taskLists.size()); 
  46.    
  47.    System.out.println("...Completed.."); 
  48.   }catch (Exception e){ 
  49.    e.printStackTrace(); 
  50.   } 
  51.  }
  52. }

No comments:

Post a Comment