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

📄 partyservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     * Get the party object(s) from an e-mail address     * @param dctx 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 getPartyFromEmail(DispatchContext dctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = dctx.getDelegator();        Collection parties = new LinkedList();        String email = (String) context.get("email");        Locale locale = (Locale) context.get("locale");        String errMsg = null;        if (email.length() == 0){            errMsg = UtilProperties.getMessage(resource,"partyservices.required_parameter_email_cannot_be_empty", locale);            return ServiceUtil.returnError(errMsg);        }        try {            List exprs = new LinkedList();            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("infoString")), EntityOperator.LIKE, new EntityFunction.UPPER("%" + email.toUpperCase() + "%")));            List c = EntityUtil.filterByDate(delegator.findByAnd("PartyAndContactMech", exprs, UtilMisc.toList("infoString")), true);            if (Debug.verboseOn()) Debug.logVerbose("List: " + c, module);            if (Debug.infoOn()) Debug.logInfo("PartyFromEmail number found: " + c.size(), module);            if (c != null) {                Iterator i = c.iterator();                while (i.hasNext()) {                    GenericValue pacm = (GenericValue) i.next();                    GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", pacm.get("partyId"), "partyTypeId", pacm.get("partyTypeId")));                    parties.add(UtilMisc.toMap("party", party));                }            }        } catch (GenericEntityException e) {            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        if (parties.size() > 0)            result.put("parties", parties);        return result;    }    /**     * Get the party object(s) from a user login ID     * @param dctx 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 getPartyFromUserLogin(DispatchContext dctx, Map context) {        Debug.logWarning("Running the getPartyFromUserLogin Service...", module);        Map result = new HashMap();        GenericDelegator delegator = dctx.getDelegator();        Collection parties = new LinkedList();        String userLoginId = (String) context.get("userLoginId");        Locale locale = (Locale) context.get("locale");        if (userLoginId.length() == 0)            return ServiceUtil.returnError("Required parameter 'userLoginId' cannot be empty.");        try {            List exprs = new LinkedList();            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("userLoginId")), EntityOperator.LIKE, new EntityFunction.UPPER("%" + userLoginId.toUpperCase() + "%")));            Collection ulc = delegator.findByAnd("PartyAndUserLogin", exprs, UtilMisc.toList("userloginId"));            if (Debug.verboseOn()) Debug.logVerbose("Collection: " + ulc, module);            if (Debug.infoOn()) Debug.logInfo("PartyFromUserLogin number found: " + ulc.size(), module);            if (ulc != null) {                Iterator i = ulc.iterator();                while (i.hasNext()) {                    GenericValue ul = (GenericValue) i.next();                    GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", ul.get("partyId"), "partyTypeId", ul.get("partyTypeId")));                    parties.add(UtilMisc.toMap("party", party));                }            }        } catch (GenericEntityException e) {            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            String errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        if (parties.size() > 0) {            result.put("parties", parties);        }        return result;    }    /**     * Get the party object(s) from person information     * @param dctx 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 getPartyFromPerson(DispatchContext dctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = dctx.getDelegator();        Collection parties = new LinkedList();        String firstName = (String) context.get("firstName");        String lastName = (String) context.get("lastName");        Locale locale = (Locale) context.get("locale");        if (firstName == null) {            firstName = "";        }        if (lastName == null) {            lastName = "";        }        if (firstName.length() == 0 && lastName.length() == 0){            String errMsg = UtilProperties.getMessage(resource,"partyservices.both_names_cannot_be_empty", locale);            return ServiceUtil.returnError(errMsg);        }        try {            List exprs = new LinkedList();            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("firstName")), EntityOperator.LIKE, new EntityFunction.UPPER("%" + firstName.toUpperCase() + "%")));            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("lastName")), EntityOperator.LIKE, new EntityFunction.UPPER("%" + lastName.toUpperCase() + "%")));            Collection pc = delegator.findByAnd("Person", exprs, UtilMisc.toList("lastName", "firstName", "partyId"));            if (Debug.infoOn()) Debug.logInfo("PartyFromPerson number found: " + pc.size(), module);            if (pc != null) {                Iterator i = pc.iterator();                while (i.hasNext()) {                    GenericValue person = (GenericValue) i.next();                    GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", person.get("partyId"), "partyTypeId", "PERSON"));                    parties.add(UtilMisc.toMap("person", person, "party", party));                }            }        } catch (GenericEntityException e) {            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            String errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        if (parties.size() > 0) {            result.put("parties", parties);        }        return result;    }    /**     * Get the party object(s) from party group name.     * @param dctx 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 getPartyFromPartyGroup(DispatchContext dctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = dctx.getDelegator();        Collection parties = new LinkedList();        String groupName = (String) context.get("groupName");        Locale locale = (Locale) context.get("locale");        if (groupName.length() == 0) {            return ServiceUtil.returnError("Required parameter 'groupName' cannot be empty.");        }        try {            List exprs = new LinkedList();            exprs.add(new EntityExpr(new EntityFunction.UPPER(new EntityFieldValue("groupName")), EntityOperator.LIKE, new EntityFunction.UPPER("%" + groupName.toUpperCase() + "%")));            Collection pc = delegator.findByAnd("PartyGroup", exprs, UtilMisc.toList("groupName", "partyId"));            if (Debug.infoOn()) Debug.logInfo("PartyFromGroup number found: " + pc.size(), module);            if (pc != null) {                Iterator i = pc.iterator();                while (i.hasNext()) {                    GenericValue group = (GenericValue) i.next();                    GenericValue party = delegator.makeValue("Party", UtilMisc.toMap("partyId", group.get("partyId"), "partyTypeId", "PARTY_GROUP"));                    parties.add(UtilMisc.toMap("partyGroup", group, "party", party));                }            }        } catch (GenericEntityException e) {            Map messageMap = UtilMisc.toMap("errMessage", e.getMessage());            String errMsg = UtilProperties.getMessage(resource,"partyservices.cannot_get_party_entities_read", messageMap, locale);            return ServiceUtil.returnError(errMsg);        }        if (parties.size() > 0) {            result.put("parties", parties);        }        return result;    }    public static Map getPerson(DispatchContext dctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = dctx.getDelegator();        String partyId = (String) context.get("partyId");        GenericValue person = null;        try {            person = delegator.findByPrimaryKeyCache("Person", UtilMisc.toMap("partyId", partyId));        } catch (GenericEntityException e) {            return ServiceUtil.returnError("Cannot get person entity (read failure): " + e.getMessage());        }        if (person != null) {            result.put("lookupPerson", person);        }        return result;    }    public static Map createRoleType(DispatchContext dctx, Map context) {        Map result = new HashMap();        GenericDelegator delegator = dctx.getDelegator();        GenericValue roleType = null;        try {            roleType = delegator.makeValue("RoleType", null);            roleType.setPKFields(context);            roleType.setNonPKFields(context);            roleType = delegator.create(roleType);        } catch (GenericEntityException e) {            Debug.logError(e, module);            return ServiceUtil.returnError("Cannot create role type entity (write failure): " + e.getMessage());        }        if (roleType != null) {            result.put("roleType", roleType);        }        return result;    }    public static Map createPartyDataSource(DispatchContext ctx, Map context) {        GenericDelegator delegator = ctx.getDelegator();        Security security = ctx.getSecurity();        GenericValue userLogin = (GenericValue) context.get("userLogin");        Locale locale = (Locale) context.get("locale");         // input data        String partyId = (String) context.get("partyId");        String dataSourceId = (String) context.get("dataSourceId");        Timestamp fromDate = (Timestamp) context.get("fromDate");        if (fromDate == null) fromDate = UtilDateTime.nowTimestamp();        // userLogin must have PARTYMGR_SRC_CREATE permission        if (!security.hasEntityPermission("PARTYMGR", "_SRC_CREATE", userLogin)) {            String errorMsg = UtilProperties.getMessage(ServiceUtil.resource, "serviceUtil.no_permission_to_operation", locale) + ".";            return ServiceUtil.returnError(errorMsg);        }        try {            // validate the existance of party and dataSource            GenericValue party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId));            GenericValue dataSource = delegator.findByPrimaryKey("DataSource", UtilMisc.toMap("dataSourceId", dataSourceId));            if (party == null || dataSource == null) {                List errorList = UtilMisc.toList("Cannot create PartyDataSource");                if (party == null) errorList.add("party with ID [" + partyId + "] was not found ");                if (dataSource == null) errorList.add("data source with ID [" + dataSourceId + "] was not found ");                return ServiceUtil.returnError(errorList);            }            // create the PartyDataSource            GenericValue partyDataSource = delegator.makeValue("PartyDataSource", UtilMisc.toMap("partyId", partyId, "dataSourceId", dataSourceId, "fromDate", fromDate));            partyDataSource.create();        } catch (GenericEntityException e) {            Debug.logError(e, e.getMessage(), module);            return ServiceUtil.returnError(e.getMessage());        }        return ServiceUtil.returnSuccess();    }    public static Map findParty(DispatchContext dctx, Map context) {        Map result = ServiceUtil.returnSuccess();        GenericDelegator delegator = dctx.getDelegator();        String extInfo = (String) context.get("extInfo");        // get the role types        try {            List roleTypes = delegator.findAll("RoleType", UtilMisc.toList("description"));            result.put("roleTypes", roleTypes);        } catch (GenericEntityException e) {            String errMsg = "Error looking up RoleTypes: " + e.toString();            Debug.logError(e, errMsg, module);            return ServiceUtil.returnError(errMsg);        }        // current role type        String roleTypeId;        try {            roleTypeId = (String) context.get("roleTypeId");            if (roleTypeId != null && roleTypeId.length() > 0) {                GenericValue currentRole = delegator.findByPrimaryKeyCache("RoleType", UtilMisc.toMap("roleTypeId", roleTypeId));                result.put("currentRole", currentRole);            }        } catch (GenericEntityException e) {            String errMsg = "Error looking up current RoleType: " + e.toString();            Debug.logError(e, errMsg, module);            return ServiceUtil.returnError(errMsg);        }        // current state        String stateProvinceGeoId;        try {            stateProvinceGeoId = (String) context.get("stateProvinceGeoId");            if (stateProvinceGeoId != null && stateProvinceGeoId.length() > 0) {                GenericValue currentStateGeo = delegator.findByPrimaryKeyCache("Geo", UtilMisc.toMap("geoId", stateProvinceGeoId));                result.put("currentStateGeo", currentStateGeo);            }        } catch (GenericEntityException e) {            String errMsg = "Error looking up current stateProvinceGeo: " + e.toString();            Debug.logError(e, errMsg, module);            return ServiceUtil.returnError(errMsg);        }        // set the page parameters        int viewIndex = 1;        try {            viewIndex = Integer.parseInt((String) context.get("VIEW_INDEX"));

⌨️ 快捷键说明

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