⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contactmechworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * $Id: ContactMechWorker.java 6379 2005-12-19 17:31:44Z jaz $ * *  Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org * *  Permission is hereby granted, free of charge, to any person obtaining a *  copy of this software and associated documentation files (the "Software"), *  to deal in the Software without restriction, including without limitation *  the rights to use, copy, modify, merge, publish, distribute, sublicense, *  and/or sell copies of the Software, and to permit persons to whom the *  Software is furnished to do so, subject to the following conditions: * *  The above copyright notice and this permission notice shall be included *  in all copies or substantial portions of the Software. * *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *  THE USE OR OTHER DEALINGS IN THE SOFTWARE. */package org.ofbiz.party.contact;import java.util.Collection;import java.util.HashMap;import java.util.Iterator;import java.util.LinkedList;import java.util.List;import java.util.Map;import javax.servlet.ServletRequest;import javax.servlet.jsp.PageContext;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilProperties;import org.ofbiz.base.util.UtilValidate;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.util.EntityUtil;/** * Worker methods for Contact Mechanisms * * @author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a> * @version    $Rev: 6379 $ * @since      2.0 */public class ContactMechWorker {        public static final String module = ContactMechWorker.class.getName();        public static void getPartyContactMechValueMaps(PageContext pageContext, String partyId, boolean showOld, String partyContactMechValueMapsAttr) {        GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");        List partyContactMechValueMaps = getPartyContactMechValueMaps(delegator, partyId, showOld);        if (partyContactMechValueMaps.size() > 0) {            pageContext.setAttribute(partyContactMechValueMapsAttr, partyContactMechValueMaps);        }    }        public static List getPartyContactMechValueMaps(GenericDelegator delegator, String partyId, boolean showOld) {       return getPartyContactMechValueMaps(delegator, partyId, showOld, null);        }        public static List getPartyContactMechValueMaps(GenericDelegator delegator, String partyId, boolean showOld, String contactMechTypeId) {        List partyContactMechValueMaps = new LinkedList();        Iterator allPartyContactMechs = null;        try {            List tempCol = delegator.findByAnd("PartyContactMech", UtilMisc.toMap("partyId", partyId));            if(contactMechTypeId != null) {                List tempColTemp = new LinkedList();                for(Iterator iterator = tempCol.iterator(); iterator.hasNext();) {                    GenericValue partyContactMech = (GenericValue) iterator.next();                    GenericValue contactMech = delegator.getRelatedOne("ContactMech", partyContactMech);                    if(contactMech != null && contactMechTypeId.equals(contactMech.getString("contactMechTypeId"))) {                        tempColTemp.add(partyContactMech);                    }                                        }                tempCol = tempColTemp;            }             if (!showOld) tempCol = EntityUtil.filterByDate(tempCol, true);            allPartyContactMechs = UtilMisc.toIterator(tempCol);        } catch (GenericEntityException e) {            Debug.logWarning(e, module);        }        while (allPartyContactMechs != null && allPartyContactMechs.hasNext()) {            GenericValue partyContactMech = (GenericValue) allPartyContactMechs.next();            GenericValue contactMech = null;            try {                contactMech = partyContactMech.getRelatedOne("ContactMech");            } catch (GenericEntityException e) {                Debug.logWarning(e, module);            }            if (contactMech != null) {                Map partyContactMechValueMap = new HashMap();                partyContactMechValueMaps.add(partyContactMechValueMap);                partyContactMechValueMap.put("contactMech", contactMech);                partyContactMechValueMap.put("partyContactMech", partyContactMech);                try {                    partyContactMechValueMap.put("contactMechType", contactMech.getRelatedOneCache("ContactMechType"));                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }                try {                    List partyContactMechPurposes = partyContactMech.getRelated("PartyContactMechPurpose");                    if (!showOld) partyContactMechPurposes = EntityUtil.filterByDate(partyContactMechPurposes, true);                    partyContactMechValueMap.put("partyContactMechPurposes", partyContactMechPurposes);                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }                try {                    if ("POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) {                        partyContactMechValueMap.put("postalAddress", contactMech.getRelatedOne("PostalAddress"));                    } else if ("TELECOM_NUMBER".equals(contactMech.getString("contactMechTypeId"))) {                        partyContactMechValueMap.put("telecomNumber", contactMech.getRelatedOne("TelecomNumber"));                    }                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }            }        }        return partyContactMechValueMaps;    }        public static List getFacilityContactMechValueMaps(GenericDelegator delegator, String facilityId, boolean showOld, String contactMechTypeId) {        List facilityContactMechValueMaps = new LinkedList();        Iterator allFacilityContactMechs = null;        try {            List tempCol = delegator.findByAnd("FacilityContactMech", UtilMisc.toMap("facilityId", facilityId));            if(contactMechTypeId != null) {                List tempColTemp = new LinkedList();                for(Iterator iterator = tempCol.iterator(); iterator.hasNext();) {                    GenericValue partyContactMech = (GenericValue) iterator.next();                    GenericValue contactMech = delegator.getRelatedOne("ContactMech", partyContactMech);                    if(contactMech != null && contactMechTypeId.equals(contactMech.getString("contactMechTypeId"))) {                        tempColTemp.add(partyContactMech);                    }                                        }                tempCol = tempColTemp;            }             if (!showOld) tempCol = EntityUtil.filterByDate(tempCol, true);            allFacilityContactMechs = UtilMisc.toIterator(tempCol);        } catch (GenericEntityException e) {            Debug.logWarning(e, module);        }        while (allFacilityContactMechs != null && allFacilityContactMechs.hasNext()) {            GenericValue facilityContactMech = (GenericValue) allFacilityContactMechs.next();            GenericValue contactMech = null;            try {                contactMech = facilityContactMech.getRelatedOne("ContactMech");            } catch (GenericEntityException e) {                Debug.logWarning(e, module);            }            if (contactMech != null) {                Map facilityContactMechValueMap = new HashMap();                facilityContactMechValueMaps.add(facilityContactMechValueMap);                facilityContactMechValueMap.put("contactMech", contactMech);                facilityContactMechValueMap.put("facilityContactMech", facilityContactMech);                try {                    facilityContactMechValueMap.put("contactMechType", contactMech.getRelatedOneCache("ContactMechType"));                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }                try {                    List facilityContactMechPurposes = facilityContactMech.getRelated("FacilityContactMechPurpose");                    if (!showOld) facilityContactMechPurposes = EntityUtil.filterByDate(facilityContactMechPurposes, true);                    facilityContactMechValueMap.put("facilityContactMechPurposes", facilityContactMechPurposes);                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }                try {                    if ("POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) {                        facilityContactMechValueMap.put("postalAddress", contactMech.getRelatedOne("PostalAddress"));                    } else if ("TELECOM_NUMBER".equals(contactMech.getString("contactMechTypeId"))) {                        facilityContactMechValueMap.put("telecomNumber", contactMech.getRelatedOne("TelecomNumber"));                    }                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }            }        }        return facilityContactMechValueMaps;    }        public static void getOrderContactMechValueMaps(PageContext pageContext, String orderId, String orderContactMechValueMapsAttr) {        GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");        List maps = getOrderContactMechValueMaps(delegator, orderId);        if (maps != null && maps.size() > 0) {            pageContext.setAttribute(orderContactMechValueMapsAttr, maps);        }    }    public static List getOrderContactMechValueMaps(GenericDelegator delegator, String orderId) {                List orderContactMechValueMaps = new LinkedList();        Iterator allOrderContactMechs = null;        try {            Collection tempCol = delegator.findByAnd("OrderContactMech", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("contactMechPurposeTypeId"));            allOrderContactMechs = UtilMisc.toIterator(tempCol);        } catch (GenericEntityException e) {            Debug.logWarning(e, module);        }        while (allOrderContactMechs != null && allOrderContactMechs.hasNext()) {            GenericValue orderContactMech = (GenericValue) allOrderContactMechs.next();            GenericValue contactMech = null;            try {                contactMech = orderContactMech.getRelatedOne("ContactMech");            } catch (GenericEntityException e) {                Debug.logWarning(e, module);            }            if (contactMech != null) {                Map orderContactMechValueMap = new HashMap();                orderContactMechValueMaps.add(orderContactMechValueMap);                orderContactMechValueMap.put("contactMech", contactMech);                orderContactMechValueMap.put("orderContactMech", orderContactMech);                try {                    orderContactMechValueMap.put("contactMechType", contactMech.getRelatedOneCache("ContactMechType"));                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }                try {                    GenericValue contactMechPurposeType = orderContactMech.getRelatedOne("ContactMechPurposeType");                    orderContactMechValueMap.put("contactMechPurposeType", contactMechPurposeType);                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);                }                try {                    if ("POSTAL_ADDRESS".equals(contactMech.getString("contactMechTypeId"))) {                        orderContactMechValueMap.put("postalAddress", contactMech.getRelatedOne("PostalAddress"));                    } else if ("TELECOM_NUMBER".equals(contactMech.getString("contactMechTypeId"))) {                        orderContactMechValueMap.put("telecomNumber", contactMech.getRelatedOne("TelecomNumber"));                    }                } catch (GenericEntityException e) {                    Debug.logWarning(e, module);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -