Saturday 16 June 2018

OIM API - Code Snippet to Add Entries in the Lookup.

public void addLookupValues(HashMap<String, String> lookupMap, String lookupName) throws Exception {
    String logp = CN + " :: addLookupValues - ";
    logger.info(logp + "START");
    tcLookupOperationsIntf lookupService = Platform.getService(tcLookupOperationsIntf.class);
    Set<String> set = lookupMap.keySet();
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        String key = (String)iter.next();
        if (!("".equalsIgnoreCase(lookupService.getDecodedValueForEncodedValue(lookupName,key).trim()))){
            logger.info(logp + "Value : " + key + " already in lookup. Updating the value");
            lookupService.removeLookupValue(lookupName, key);
            lookupService.addLookupValue(lookupName,key, lookupMap.get(key), "en","US"); 
        }
        else{
            logger.info(logp + "Value : " + key + " not present in lookup. Adding the value");
            lookupService.addLookupValue(lookupName,key, lookupMap.get(key), "en","US"); 
        }
    }
    logger.info(logp + "Lookup is appened with the new values");
    logger.info(logp + "END");
}


Happy Learning!!!

No comments:

Post a Comment