Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.wirabumi.gen.oez.callout;
- import java.util.List;
- import org.hibernate.criterion.Restrictions;
- import org.openbravo.dal.core.OBContext;
- import org.openbravo.dal.service.OBCriteria;
- import org.openbravo.dal.service.OBDal;
- import org.openbravo.erpCommon.ad_callouts.SimpleCallout.CalloutInfo;
- import org.openbravo.model.ad.system.ClientInformation;
- import org.openbravo.model.ad.utility.Tree;
- import org.openbravo.model.ad.utility.TreeNode;
- import org.openbravo.model.common.plm.ProductCategory;
- public class ParentProductClassName implements GenerateProductSearchKey {
- @Override
- public String getParentProduct(CalloutInfo info) {
- //get key from sub category
- String strProductCategoryId = info.getStringParameter("inpmProductCategoryId", null);
- //get tree
- ClientInformation ClientInfo = OBContext.getOBContext().getCurrentClient().getClientInformationList().get(0);
- Tree adTree = ClientInfo.getPrimaryTreeProductCategory();
- //get product category ID
- ProductCategory pcSubId = OBDal.getInstance().get(ProductCategory.class, strProductCategoryId);
- String subKey = pcSubId.getSearchKey();
- //get key from main category
- OBCriteria<TreeNode> treeNodeCriteria = OBDal.getInstance().createCriteria(TreeNode.class);
- treeNodeCriteria.add(Restrictions.eq(TreeNode.PROPERTY_TREE, adTree));
- treeNodeCriteria.add(Restrictions.eq(TreeNode.PROPERTY_NODE, strProductCategoryId));
- TreeNode treeNode = treeNodeCriteria.list().get(0);
- String pcMainId = treeNode.getReportSet();
- if (pcMainId.equalsIgnoreCase("0")) {
- pcMainId = subKey;
- }
- ProductCategory pcMain = OBDal.getInstance().get(ProductCategory.class, pcMainId);
- String mainKey = pcMain.getSearchKey();
- return mainKey;
- }
- @Override
- public String getProductSearchKey(CalloutInfo info) {
- // TODO Auto-generated method stub
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement