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

📄 viewprefworker.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
字号:
/* * * Copyright (C) 2006  Open Source Strategies, Inc. *  * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */package com.opensourcestrategies.crmsfa.party;import java.util.Iterator;import java.util.List;import java.util.Map;import javolution.util.FastMap;import javolution.util.FastList;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilDateTime;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.entity.condition.*;import org.ofbiz.entity.util.EntityUtil;import org.ofbiz.service.GenericServiceException;import org.ofbiz.service.LocalDispatcher;import org.ofbiz.service.ServiceUtil;/** * ViewPreference helper methods * * @author     <a href="mailto:leon@opensourcestrategies.org">Leon Torres</a> * @version    $Rev: $ * @since      3.1 */public class ViewPrefWorker {        public static String module = ViewPrefWorker.class.getName();    /** Gets the view preferences as a Map of String values keyed to the preference type for the given location. */    public static Map getViewPreferencesByLocation(GenericValue userLogin, String application, String applicationSection, String screenName, String formName)         throws GenericEntityException {        Map conditions = UtilMisc.toMap("userLoginId", userLogin.get("userLoginId"), "application", application, "applicationSection", applicationSection, "screenName", screenName, "formName", formName);        List prefs = userLogin.getDelegator().findByAnd("ViewPrefAndLocation", conditions);        Map results = FastMap.newInstance();        for (Iterator iter = prefs.iterator(); iter.hasNext(); ) {            GenericValue pref = (GenericValue) iter.next();            if ("VPREF_VALTYPE_ENUM".equals(pref.get("viewPrefValueTypeId"))) {                results.put(pref.get("viewPrefTypeId"), pref.get("viewPrefEnumId"));            } else {                results.put(pref.get("viewPrefTypeId"), pref.get("viewPrefString"));            }        }        return results;    }    /** As above, but for application and section */    public static Map getViewPreferencesByLocation(GenericValue userLogin, String application, String applicationSection) throws GenericEntityException {        return getViewPreferencesByLocation(userLogin, application, applicationSection, null, null);    }    /** Gets the value of the preference as a String. Speficy the userLogin and viewPrefTypeId. */    public static String getViewPreferenceString(GenericValue userLogin, String viewPrefTypeId) throws GenericEntityException {        GenericValue pref = getViewPreferenceValue(userLogin, viewPrefTypeId);        if (pref == null) return null;        if ("VPREF_VALTYPE_ENUM".equals(pref.get("viewPrefValueTypeId"))) return pref.getString("viewPrefEnumId");        return pref.getString("viewPrefString");    }    /** Fetch the user login's active view preference as a GenericValue given a preference type.  */    public static GenericValue getViewPreferenceValue(GenericValue userLogin, String viewPrefTypeId) throws GenericEntityException {        GenericDelegator delegator = userLogin.getDelegator();        return delegator.findByPrimaryKey("ViewPreference",                     UtilMisc.toMap("viewPrefTypeId", viewPrefTypeId, "userLoginId", userLogin.get("userLoginId")));    }}

⌨️ 快捷键说明

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