Friday, 23 March 2018

OIM API - Code Snippet to Get Catalog Details for a Particular Request.

public void getCatalogDetailsForRequest(String requestID) throws RequestServiceException,
                                                                     NoRequestPermissionException,
                                                                     CatalogException {
        //get required services
        RequestService requestService = Platform.getService(RequestService.class);
        CatalogService catalogService = Platform
.getService(CatalogService.class);
       
        //get request object
        Request request = requestService.getBasicRequestData(requestID);
       
        List<Beneficiary> reqBeneficiaries = request.getBeneficiaries();
       
        for (Beneficiary beneficiary : reqBeneficiaries){
            List requestBeneficiaryEntityList = beneficiary.getTargetEntities();
            for(RequestBeneficiaryEntity requestBeneficiaryEntity : requestBeneficiaryEntityList){
                String entityKey = requestBeneficiaryEntity.getEntityKey();
                OIMType entityType = requestBeneficiaryEntity.getRequestEntityType();
               
                Catalog catalog = catalogService.getCatalogItemDetails(null, entityKey, entityType, null);
               
                System.out.println("Approver Role :: " + catalog.getApproverRole());
                System.out.println("Approver User :: " + catalog.getApproverUser());
                System.out.println("Category :: " + catalog.getCategoryName());
            }
        }
 }


Happy Learning!!!

No comments:

Post a Comment