Wednesday, 20 June 2012

How to fetch Lookup values into a map in OIM 11g

   public static Map<String, String> getLookupValue(String lookupName)
    {
       
        tcLookupOperationsIntf lookupOpsIntf = null;
        Map<String, String> lookupValues = new HashMap<String, String>();
        tcResultSet lookupResSet = null;
        String lookupCode;
        String lookupValue;
      

        try
        {
           lookupOpsIntf=Platform.getService(tcLookupOperationsIntf.class);
            lookupResSet = lookupOpsIntf.getLookupValues(lookupName);
            if ((lookupResSet != null) && (lookupResSet.getRowCount() > 0))
            {
                for (int i = 0; i < lookupResSet.getRowCount(); i++)
                {
                    lookupResSet.goToRow(i);
                    lookupCode = lookupResSet.getStringValue(Constants.LKV_ENCODED);
                    lookupValue =lookupResSet.getStringValue(Constants.LKV_DECODED);
                   
                    lookupValues.put(lookupCode, lookupValue);
                   
                }
            }
        }
       
        catch (tcInvalidLookupException invalidLookupEx)
        {
         //print Exceptions
        }
       
        catch (Exception e)
        {
         //print Exceptions
        }
        finally
        {
            if (lookupOpsIntf != null)
            {
                lookupOpsIntf.close();
            }
          
        }
       
        return lookupValues;
    }
   

2 comments: