Advertisement
tko_pb

getStringParam2

Aug 3rd, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. package org.wirabumi.gen.oez.callout;
  2. import java.util.Enumeration;
  3. import java.util.HashMap;
  4.  
  5. import org.openbravo.erpCommon.ad_callouts.SimpleCallout;
  6. import org.openbravo.erpCommon.utility.Utility;
  7.  
  8. public class CallGenerateAutoSearchKey extends SimpleCallout {
  9.  
  10.     @Override
  11.     protected void execute(CalloutInfo info) {
  12.         try {
  13.             //get parameter
  14.             String generateProductSearchKeyClassName = Utility.getPreference(info.vars, "ProductSearchKeyClassName", null);    
  15.             HashMap<String, String> CalloutInfoHashmap = new HashMap<>();
  16.  
  17.             Enumeration<String> Params =  info.vars.getEnumerationString(); // hasil dari get
  18.             while(Params.hasMoreElements())
  19.             {
  20.                 String paramsKey = Params.nextElement();
  21.                 String value = info.getStringParameter(paramsKey);
  22.                 CalloutInfoHashmap.put(paramsKey, value);
  23.             }  
  24.  
  25.             boolean strValid = generateProductSearchKeyClassName != null && !generateProductSearchKeyClassName.isEmpty();
  26.             if (strValid) {
  27.                 Class<?> cls = Class.forName(generateProductSearchKeyClassName);
  28.                 Object clsInstance = (Object) cls.newInstance();
  29.                 GenerateProductSearchKey generateProductSearchKey = null;
  30.                 generateProductSearchKey = (GenerateProductSearchKey) clsInstance;
  31.                 String searchKey = generateProductSearchKey.getProductSearchKey(CalloutInfoHashmap); // info diganti hashmap
  32.                 info.addResult("inpvalue", searchKey);
  33.             }  
  34.             else {
  35.                 return;
  36.             }
  37.         } catch (ClassNotFoundException e) {
  38.             // TODO Auto-generated catch block
  39.             e.printStackTrace();
  40.         } catch (InstantiationException e) {
  41.             // TODO Auto-generated catch block
  42.             e.printStackTrace();
  43.         } catch (IllegalAccessException e) {
  44.             // TODO Auto-generated catch block
  45.             e.printStackTrace();
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement