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

📄 partyroleservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
字号:
/* * $Id: PartyRoleServices.java 6412 2005-12-22 19:26:15Z sichen $ * * 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.party;import java.util.HashMap;import java.util.Map;import java.util.Locale;import org.ofbiz.base.util.Debug;import org.ofbiz.base.util.UtilMisc;import org.ofbiz.base.util.UtilProperties;import org.ofbiz.entity.GenericDelegator;import org.ofbiz.entity.GenericEntityException;import org.ofbiz.entity.GenericValue;import org.ofbiz.security.Security;import org.ofbiz.service.DispatchContext;import org.ofbiz.service.ModelService;import org.ofbiz.service.ServiceUtil;/** * Services for Party Role maintenance * * @author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a> * @version    $Rev: 6412 $ * @since      2.0 */public class PartyRoleServices {        public static final String module = PartyRoleServices.class.getName();    public static final String resource = "PartyUiLabels";    /**      * Creates a PartyRole     *@param ctx The DispatchContext that this service is operating in     *@param context Map containing the input parameters     *@return Map with the result of the service, the output parameters     */    public static Map createPartyRole(DispatchContext ctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = ctx.getDelegator();        Security security = ctx.getSecurity();        GenericValue userLogin = (GenericValue) context.get("userLogin");        // check permission PARTYMGR_ROLE_CREATE or use ServiceUtil.getPartyIdCheckSecurity to check permission        String partyId = null;        if (security.hasEntityPermission("PARTYMGR", "_ROLE_CREATE", userLogin)) {            partyId = (String) context.get("partyId");        } else {            partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_CREATE");        }        Locale locale = (Locale) context.get("locale");        String errMsg = null;        if (result.size() > 0)            return result;        GenericValue partyRole = delegator.makeValue("PartyRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", context.get("roleTypeId")));        try {            if (delegator.findByPrimaryKey(partyRole.getPrimaryKey()) != null) {                errMsg = UtilProperties.getMessage(resource,"partyroleservices.could_not_create_party_role_exists", locale);                return ServiceUtil.returnError(errMsg);            }        } catch (GenericEntityException e) {            Debug.logWarning(e, module);            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            errMsg = UtilProperties.getMessage(resource,"partyroleservices.could_not_create_party_role_read", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        try {            partyRole.create();        } catch (GenericEntityException e) {            Debug.logWarning(e.getMessage(), module);            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            errMsg = UtilProperties.getMessage(resource,"partyroleservices.could_not_create_party_role_write", messageMap, locale);            return ServiceUtil.returnError(errMsg);//            return ServiceUtil.returnError("Could create party role (write failure): " + e.getMessage());        }        result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);        return result;    }    /**      * Deletes a PartyRole     *@param ctx The DispatchContext that this service is operating in     *@param context Map containing the input parameters     *@return Map with the result of the service, the output parameters     */    public static Map deletePartyRole(DispatchContext ctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = ctx.getDelegator();        Security security = ctx.getSecurity();        GenericValue userLogin = (GenericValue) context.get("userLogin");        // check permission PARTYMGR_ROLE_DELETE or use ServiceUtil.getPartyIdCheckSecurity to check permission        String partyId = null;        if (security.hasEntityPermission("PARTYMGR", "_ROLE_DELETE", userLogin)) {            partyId = (String) context.get("partyId");        } else {            partyId = ServiceUtil.getPartyIdCheckSecurity(userLogin, security, context, result, "PARTYMGR", "_CREATE");        }        Locale locale = (Locale) context.get("locale");        String errMsg = null;        if (result.size() > 0)            return result;        GenericValue partyRole = null;        try {            partyRole = delegator.findByPrimaryKey("PartyRole", UtilMisc.toMap("partyId", partyId, "roleTypeId", context.get("roleTypeId")));        } catch (GenericEntityException e) {            Debug.logWarning(e, module);            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            errMsg = UtilProperties.getMessage(resource,"partyroleservices.could_not_delete_party_role_read", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        if (partyRole == null) {            errMsg = UtilProperties.getMessage(resource,"partyroleservices.could_not_delete_party_role_not_found", locale);            return ServiceUtil.returnError(errMsg);        }        try {            partyRole.remove();        } catch (GenericEntityException e) {            Debug.logWarning(e.getMessage(), module);            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            errMsg = UtilProperties.getMessage(resource,"partyroleservices.could_not_delete_party_role_write", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);        return result;    }}

⌨️ 快捷键说明

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