Monday, 5 September 2011

OIM11G Request Creation via API


  long resKey = 0L;
       String str = null;
       String resourceKey = null;
       Map<String, String> searchMap = new HashMap<String, String>();
       tcResultSet resultSet = null;                                  
       RequestData requestData = null;                               
       Beneficiary beneficiary = null;                    
       RequestBeneficiaryEntity entity = null;                       
       List<Beneficiary> beneficiaryList = null;                      
       List<RequestBeneficiaryEntity> entityList = null;              
       List<RequestBeneficiaryEntityAttribute> entityAttrList = null; 
 
       searchMap.put(RESOURCE_ATTR_NAME, RESOURCE);
       resultSet = _resourceService.findObjects(searchMap);
       resKey = resultSet.getLongValue(RESOURCE_ATTR_KEY);
       resourceKey = Long.toString(resKey);       
     
       RequestBeneficiaryEntityAttribute parantAttr = new RequestBeneficiaryEntityAttribute();
       parantAttr.setType(TYPE.String);
       parantAttr.setName("Title");
       parantAttr.setValue("Mr.");
  
       entityAttrList = new ArrayList<RequestBeneficiaryEntityAttribute>();
       entityAttrList.add(parantAttr);
  
       entity = new RequestBeneficiaryEntity();
       entity.setEntityKey(resourceKey);  
       entity.setEntityType(RequestConstants.RESOURCE);
       entity.setEntitySubType(RESOURCE); 
       entity.setEntityData(entityAttrList);
  
              entityList = new ArrayList<RequestBeneficiaryEntity>();
       entityList.add(entity);
 
       beneficiary = new Beneficiary();
       beneficiary.setBeneficiaryType(Beneficiary.USER_BENEFICIARY);
       beneficiary.setBeneficiaryKey(USER_KEY);
       beneficiary.setTargetEntities(entityList);      
   
       requestData = new RequestData();
       requestData.setRequestTemplateName(TEMPLATE);
       requestData.setJustification("Test");
       requestData.setBeneficiaries(beneficiaryList);
   
       RequestService reqsrvc = client.getService(RequestService.class);       
     
       str = reqsrvc.submitRequest(requestData);
       
       System.out.println("Value from submitRequest : '" + (str != null ? str : null) + "'");
 

No comments:

Post a Comment