Friday 23 March 2018

OIM API - Code Snippet to Read Lookup Values.

public Map<String, String> getLookupMap(String lookupName) {
        final String logp = CN + " :: getLookupMap - ";
        LOGGER.debug(logp + "START");
        Map<String, String> lookupMap = new HashMap<String, String>();
        tcLookupOperationsIntf lookupService = Platform.getService(tcLookupOperationsIntf.class);
        try {
            tcResultSet resultSet = lookupService.getLookupValues(lookupName);
            String codeKey, meaningValue;
            for (int i = 0; i < resultSet.getRowCount(); i++) {
                resultSet.goToRow(i);
                codeKey = resultSet.getStringValue("Lookup Definition.Lookup Code Information.Code Key");
                meaningValue = resultSet.getStringValue("Lookup Definition.Lookup Code Information.Decode");
                lookupMap.put(codeKey, meaningValue);
                LOGGER.info(logp + " \nLookup Key: [" + codeKey + "], Lookup Value:[" + meaningValue + "])");
            }
        } catch (tcAPIException e) {
            LOGGER.severe(logp + "Exception occured while reading lookup " + e.getMessage());
            e.printStackTrace();
        } catch (tcInvalidLookupException e) {
            LOGGER.severe(logp + "Exception occured while reading lookup " + e.getMessage());
            e.printStackTrace();
        } catch (tcColumnNotFoundException e) {
            LOGGER.severe(logp + "Exception occured while reading lookup " + e.getMessage());
            e.printStackTrace();
        }
        LOGGER.debug(logp + "END");
        return lookupMap;
    }


Happy Learning!!!

No comments:

Post a Comment