Monday, 9 December 2019

Get Decode Value From Lookup Using API



                                           Get Decode Value Lookup Using API


package demo.com;

import Thor.API.Exceptions.tcAPIException;
import Thor.API.Exceptions.tcColumnNotFoundException;
import Thor.API.Exceptions.tcInvalidLookupException;

import java.util.HashMap;
import java.util.Hashtable;
import oracle.iam.platform.OIMClient;
import Thor.API.tcResultSet;
import Thor.API.Operations.tcLookupOperationsIntf;


import oracle.core.ojdl.logging.ODLLevel;

public class UpdateLookup {
  private static final String CLASS_NAME = UpdateLookup.class.getSimpleName();
    private static String OIMUserName = "xelsysadm";
    private static String OIMPassword = "*****";
    private static String OIMURL = "t3://localhost:14000";
    private static String OIMInitialContextFactory ="weblogic.jndi.WLInitialContextFactory";
      //OIM Client Initiallization
        public static OIMClient loginWithCustomEnv() {
        Hashtable env = new Hashtable();
        env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, OIMInitialContextFactory);
        env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, OIMURL);
     // New Properties needs to be added into system property.
        System.setProperty("OIM.AppServerType", "wls");
        System.setProperty("APPSERVER_TYPE", "wls");
        System.setProperty("java.security.auth.login.config","C:\\Users\\RK\\TestReconEvent\\oimclient\\conf\\authwl.conf");
        OIMClient oimClient = new OIMClient(env);
         try {
              System.out.println("12");
              oimClient = new OIMClient(env);
              System.out.println("Initiating Oim Client");
              oimClient.login(OIMUserName, OIMPassword.toCharArray());
              System.out.println("got OIM client successfully");
              System.out.println("Client - " + oimClient);
             } catch (Exception e) {
              System.out.println("Error: " + e);
               oimClient = null;
                          }
        return oimClient;
     
        }
//        public void addLookupEntry(OIMClient oimClient,String lookupName,String lookupCodekey,String Decode)  {
//             oimClient= null;
//            OIMClient oimClient=this.loginWithCustomEnv();
//            System.out.println("Got the value of lookupName:"+lookupName);
//            System.out.println("Got the value of lookupCodekey:"+lookupCodekey);
//            System.out.println("Got the value of Decode:"+Decode);
//         try {
//          tcLookupOperationsIntf lookupOps = oimClient.getService(tcLookupOperationsIntf.class);
//          lookupOps.addLookupValue(lookupName,lookupCodekey, Decode, "", "");
//         
//         } catch (Exception e) {
//          e.printStackTrace();
//         }
//        }
   //     public void readLookupValues(String lookupname) {
//            OIMClient client=this.loginWithCustomEnv();
//         try {
//          tcLookupOperationsIntf lookupOps = client.getService(tcLookupOperationsIntf.class);
//          tcResultSet values = lookupOps.getLookupValues(lookupname);
//          for (int i = 0; i < values.getRowCount(); i++) {
//           values.goToRow(i);
//           System.out.print(values.getStringValue("Lookup Definition.Lookup Code Information.Decode"));
//           System.out.println("," + values.getStringValue("Lookup Definition.Lookup Code Information.Code Key"));
//          }
//         } catch (Exception e) {
//          e.printStackTrace();
//         }
//        }
     
     
     
   
  private String readLookupValues(String lookupName,String lookupCodekey)
        {
           String methodName = "::getLookupData::";
         
            OIMClient client=this.loginWithCustomEnv();
           String Decode=null;
           tcLookupOperationsIntf lookupOpsIntf = null;
           System.out.println("getLookupValue " + lookupName + "," + lookupCodekey);
           try
                        {
                                lookupOpsIntf = client.getService(tcLookupOperationsIntf.class);
                                Decode = lookupOpsIntf.getDecodedValueForEncodedValue(lookupName, lookupCodekey);
                        }
                        catch (Exception e)
                        {
                                System.out.println("error looking up " + e);
                        }
                        finally
                        {
                                if ( lookupOpsIntf != null )
                                {
                                        lookupOpsIntf.close();
                                }

                        }
                        System.out.println("getLookupValue return " + Decode);
                        return Decode;
                }
        private boolean empIdExit(String emp)
          {
                  boolean isExit=false;
           
                 // HashMap<String, String> map=null;
                  String map=null;
              try
                    {
                  if(map==null)
                  {
                    map= readLookupValues("Lookup.Workday.EmpNumber.ReconValidation",emp);
                      System.out.println(map);
                    //  logger.info("#### map $$$$ " + map);
           
              if(map.equals(emp))
                 {
                     System.out.println(emp);
                         return isExit=true;
                       
                 }
               
                 else{
                         return isExit;
       
           
          }
     

//private boolean empIdExit(String emp)
//      {
//              boolean isExit=false;
//              HashMap<String, String> map=null;
//              if(map==null)
//              {
//                map= readLookupValues("Lookup.Workday.EmpNumber.ReconValidation", emp, emp);
//                 // logger.info("#### map $$$$ " + map);
//                 System.out.println("map"+map);
//              }
//             if(map.containsKey(emp))
//             {
//                     return isExit=true;
//             }
//             else{
//                     return isExit;
//             }
//      }
 
 
//    private HashMap<String, String> readLookupValues(String lookupName,String lookupCode,String lookupDecode)
//            {
//              String methodName = "::readLookupValues::";
//                OIMClient client=this.loginWithCustomEnv();
//              HashMap<String, String> lookupValues = new HashMap();
//              tcResultSet lookupResultSet = null;
//                     
//                tcLookupOperationsIntf lookupOps = (tcLookupOperationsIntf)client.getService(tcLookupOperationsIntf.class);
//              //  logger.info
//              System.out.println("#### lookupOps $$$$ " + lookupOps);
//             
//              try
//              {
//                lookupResultSet = lookupOps.getLookupValues(lookupName);
//                int i;
//                if ((lookupResultSet != null) && (lookupResultSet.getRowCount() > 0))
//                {
//                  for (i = 0; i < lookupResultSet.getRowCount(); i++)
//                  {
//                    lookupResultSet.goToRow(i);
//                    try
//                    {
//                      lookupCode = lookupResultSet.getStringValue("Lookup Definition.Lookup Code Information.Code Key");
//                      //  logger.info
//                            System.out.println("#### lookupCode $$$$ " + lookupCode);
//                     
//                    }
//                    catch (tcColumnNotFoundException localtcColumnNotFoundException1) {}
//
//                        try {
//                            lookupDecode = lookupResultSet.getStringValue("Lookup Definition.Lookup Code Information.Decode");
//                          //  logger.info
//                          System.out.println("#### lookupDecode $$$$ " + lookupDecode);
//                         
//                        } catch (tcColumnNotFoundException e) {
//                        }
//                        lookupValues.put(lookupCode, lookupDecode);
//                  }
//                }
//             
//                if ((lookupValues == null) && (lookupValues.size() == 0))
//                {
//               
//                  return null;
//                }
//              } catch (tcInvalidLookupException e) {
//            } catch (tcAPIException e) {
//            }
//            System.out.println("#################### Reading Lookup Completed ################");
//            return lookupValues;
//           
//            }
        public static void main(String args[]) {
          UpdateLookup obj = new UpdateLookup();
         //  obj.addLookupEntry(null,"Lookup.Data.AAPName","AAPNam26","AAPData26");
       obj.empIdExit(null);
      // obj.empIdExit(null);
       
        }
    }

No comments:

Post a Comment

Get Decode Value From Lookup Using API

                                            Get Decode Value Lookup Using API package demo.com; import Thor.API.Exceptions.tcAPIExce...