Advertisement
tko_pb

ParentProductClassName.java

Sep 30th, 2018
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. package org.wirabumi.gen.oez.callout;
  2.  
  3. import java.util.List;
  4.  
  5. import org.hibernate.criterion.Restrictions;
  6. import org.openbravo.dal.core.OBContext;
  7. import org.openbravo.dal.service.OBCriteria;
  8. import org.openbravo.dal.service.OBDal;
  9. import org.openbravo.erpCommon.ad_callouts.SimpleCallout.CalloutInfo;
  10. import org.openbravo.model.ad.system.ClientInformation;
  11. import org.openbravo.model.ad.utility.Tree;
  12. import org.openbravo.model.ad.utility.TreeNode;
  13. import org.openbravo.model.common.plm.ProductCategory;
  14.  
  15. public class ParentProductClassName implements GenerateProductSearchKey {
  16.  
  17.     @Override
  18.     public String getParentProduct(CalloutInfo info) {
  19.         //get key from sub category
  20.         String strProductCategoryId = info.getStringParameter("inpmProductCategoryId", null);
  21.  
  22.         //get tree
  23.         ClientInformation ClientInfo = OBContext.getOBContext().getCurrentClient().getClientInformationList().get(0);
  24.         Tree adTree = ClientInfo.getPrimaryTreeProductCategory();
  25.  
  26.         //get product category ID
  27.         ProductCategory pcSubId = OBDal.getInstance().get(ProductCategory.class, strProductCategoryId);
  28.         String subKey = pcSubId.getSearchKey();
  29.  
  30.         //get key from main category
  31.         OBCriteria<TreeNode> treeNodeCriteria = OBDal.getInstance().createCriteria(TreeNode.class);
  32.         treeNodeCriteria.add(Restrictions.eq(TreeNode.PROPERTY_TREE, adTree));
  33.         treeNodeCriteria.add(Restrictions.eq(TreeNode.PROPERTY_NODE, strProductCategoryId));
  34.  
  35.         TreeNode treeNode = treeNodeCriteria.list().get(0);
  36.         String pcMainId = treeNode.getReportSet();
  37.         if (pcMainId.equalsIgnoreCase("0")) {
  38.             pcMainId = subKey;
  39.         }
  40.         ProductCategory pcMain = OBDal.getInstance().get(ProductCategory.class, pcMainId);
  41.         String mainKey = pcMain.getSearchKey();
  42.  
  43.         return mainKey;
  44.     }
  45.  
  46.     @Override
  47.     public String getProductSearchKey(CalloutInfo info) {
  48.         // TODO Auto-generated method stub
  49.         return null;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement