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

📄 partyservices.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        } catch (Exception e) {            viewIndex = 1;        }        result.put("viewIndex", new Integer(viewIndex));        int viewSize = 20;        try {            viewSize = Integer.parseInt((String) context.get("VIEW_SIZE"));        } catch (Exception e) {            viewSize = 20;        }        result.put("viewSize", new Integer(viewSize));        // get the lookup flag        String lookupFlag = (String) context.get("lookupFlag");        // blank param list        String paramList = "";        List partyList = null;        int partyListSize = 0;        int lowIndex = 0;        int highIndex = 0;        if ("Y".equals(lookupFlag)) {            String showAll = (context.get("showAll") != null ? (String) context.get("showAll") : "N");            paramList = paramList + "&lookupFlag=" + lookupFlag + "&showAll=" + showAll + "&extInfo=" + extInfo;            // create the dynamic view entity            DynamicViewEntity dynamicView = new DynamicViewEntity();            // default view settings            dynamicView.addMemberEntity("PT", "Party");            dynamicView.addAlias("PT", "partyId");            dynamicView.addAlias("PT", "partyTypeId");            dynamicView.addRelation("one-nofk", "", "PartyType", ModelKeyMap.makeKeyMapList("partyTypeId"));            dynamicView.addRelation("many", "", "UserLogin", ModelKeyMap.makeKeyMapList("partyId"));            // define the main condition & expression list            List andExprs = FastList.newInstance();            EntityCondition mainCond = null;            List orderBy = FastList.newInstance();            List fieldsToSelect = FastList.newInstance();            // fields we need to select; will be used to set distinct            fieldsToSelect.add("partyId");            fieldsToSelect.add("partyTypeId");            // get the params            String partyId = (String) context.get("partyId");            String userLoginId = (String) context.get("userLoginId");            String firstName = (String) context.get("firstName");            String lastName = (String) context.get("lastName");            String groupName = (String) context.get("groupName");            if (!"Y".equals(showAll)) {                // check for a partyId                if (partyId != null && partyId.length() > 0) {                    paramList = paramList + "&partyId=" + partyId;                    andExprs.add(new EntityExpr("partyId", true, EntityOperator.LIKE, "%"+partyId+"%", true));                }                // ----                // UserLogin Fields                // ----                // filter on user login                if (userLoginId != null && userLoginId.length() > 0) {                    paramList = paramList + "&userLoginId=" + userLoginId;                    // modify the dynamic view                    dynamicView.addMemberEntity("UL", "UserLogin");                    dynamicView.addAlias("UL", "userLoginId");                    dynamicView.addViewLink("PT", "UL", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    // add the expr                    andExprs.add(new EntityExpr("userLoginId", true, EntityOperator.LIKE, "%"+userLoginId+"%", true));                    fieldsToSelect.add("userLoginId");                }                // ----                // PartyGroup Fields                // ----                // filter on groupName                if (groupName != null && groupName.length() > 0) {                    paramList = paramList + "&groupName=" + groupName;                    // modify the dynamic view                    dynamicView.addMemberEntity("PG", "PartyGroup");                    dynamicView.addAlias("PG", "groupName");                    dynamicView.addViewLink("PT", "PG", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    // add the expr                    andExprs.add(new EntityExpr("groupName", true, EntityOperator.LIKE, "%"+groupName+"%", true));                }                // ----                // Person Fields                // ----                // modify the dynamic view                if ((firstName != null && firstName.length() > 0) || (lastName != null && lastName.length() > 0)) {                    dynamicView.addMemberEntity("PE", "Person");                    dynamicView.addAlias("PE", "firstName");                    dynamicView.addAlias("PE", "lastName");                    dynamicView.addViewLink("PT", "PE", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    fieldsToSelect.add("firstName");                    fieldsToSelect.add("lastName");                    orderBy.add("lastName");                    orderBy.add("firstName");                }                // filter on firstName                if (firstName != null && firstName.length() > 0) {                    paramList = paramList + "&firstName=" + firstName;                    andExprs.add(new EntityExpr("firstName", true, EntityOperator.LIKE, "%"+firstName+"%", true));                }                // filter on lastName                if (lastName != null && lastName.length() > 0) {                    paramList = paramList + "&lastName=" + lastName;                    andExprs.add(new EntityExpr("lastName", true, EntityOperator.LIKE, "%"+lastName+"%", true));                }                // ----                // RoleType Fields                // ----                // filter on role member                if (roleTypeId != null && !"ANY".equals(roleTypeId)) {                    paramList = paramList + "&roleTypeId=" + roleTypeId;                    // add role to view                    dynamicView.addMemberEntity("PR", "PartyRole");                    dynamicView.addAlias("PR", "roleTypeId");                    dynamicView.addViewLink("PT", "PR", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    // add the expr                    andExprs.add(new EntityExpr("roleTypeId", EntityOperator.EQUALS, roleTypeId));                    fieldsToSelect.add("roleTypeId");                }                // ----                // PostalAddress fields                // ----                if ("P".equals(extInfo)) {                    // add address to dynamic view                    dynamicView.addMemberEntity("PC", "PartyContactMech");                    dynamicView.addMemberEntity("PA", "PostalAddress");                    dynamicView.addAlias("PC", "contactMechId");                    dynamicView.addAlias("PA", "address1");                    dynamicView.addAlias("PA", "address2");                    dynamicView.addAlias("PA", "city");                    dynamicView.addAlias("PA", "stateProvinceGeoId");                    dynamicView.addAlias("PA", "countryGeoId");                    dynamicView.addAlias("PA", "postalCode");                    dynamicView.addViewLink("PT", "PC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    dynamicView.addViewLink("PC", "PA", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId"));                    // filter on address1                    String address1 = (String) context.get("address1");                    if (address1 != null && address1.length() > 0) {                        paramList = paramList + "&address1=" + address1;                        andExprs.add(new EntityExpr("address1", true, EntityOperator.LIKE, "%" + address1 + "%", true));                    }                    // filter on address2                    String address2 = (String) context.get("address2");                    if (address2 != null && address2.length() > 0) {                        paramList = paramList + "&address2=" + address2;                        andExprs.add(new EntityExpr("address2", true, EntityOperator.LIKE, "%" + address2 + "%", true));                    }                    // filter on city                    String city = (String) context.get("city");                    if (city != null && city.length() > 0) {                        paramList = paramList + "&city=" + city;                        andExprs.add(new EntityExpr("city", true, EntityOperator.EQUALS, city, true));                    }                    // filter on state geo                    if (stateProvinceGeoId != null && !"ANY".equals(stateProvinceGeoId)) {                        paramList = paramList + "&stateProvinceGeoId=" + stateProvinceGeoId;                        andExprs.add(new EntityExpr("stateProvinceGeoId", EntityOperator.EQUALS, stateProvinceGeoId));                    }                    // filter on postal code                    String postalCode = (String) context.get("postalCode");                    if (postalCode != null && postalCode.length() > 0) {                        paramList = paramList + "&postalCode=" + postalCode;                        andExprs.add(new EntityExpr("postalCode", true, EntityOperator.LIKE, "%" + postalCode + "%", true));                    }                    fieldsToSelect.add("postalCode");                }                // ----                // Generic CM Fields                // ----                if ("O".equals(extInfo)) {                    // add info to dynamic view                    dynamicView.addMemberEntity("PC", "PartyContactMech");                    dynamicView.addMemberEntity("CM", "ContactMech");                    dynamicView.addAlias("PC", "contactMechId");                    dynamicView.addAlias("CM", "infoString");                    dynamicView.addViewLink("PT", "PC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    dynamicView.addViewLink("PC", "CM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId"));                    // filter on infoString                    String infoString = (String) context.get("infoString");                    if (infoString != null && infoString.length() > 0) {                        paramList = paramList + "&infoString=" + infoString;                        andExprs.add(new EntityExpr("infoString", true, EntityOperator.LIKE, "%"+infoString+"%", true));                    }                    fieldsToSelect.add("infoString");                }                // ----                // TelecomNumber Fields                // ----                if ("T".equals(extInfo)) {                    // add telecom to dynamic view                    dynamicView.addMemberEntity("PC", "PartyContactMech");                    dynamicView.addMemberEntity("TM", "TelecomNumber");                    dynamicView.addAlias("PC", "contactMechId");                    dynamicView.addAlias("TM", "countryCode");                    dynamicView.addAlias("TM", "areaCode");                    dynamicView.addAlias("TM", "contactNumber");                    dynamicView.addViewLink("PT", "PC", Boolean.FALSE, ModelKeyMap.makeKeyMapList("partyId"));                    dynamicView.addViewLink("PC", "TM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId"));                    // filter on countryCode                    String countryCode = (String) context.get("countryCode");                    if (countryCode != null && countryCode.length() > 0) {                        paramList = paramList + "&countryCode=" + countryCode;                        andExprs.add(new EntityExpr("countryCode", true, EntityOperator.EQUALS, countryCode, true));                    }                    // filter on areaCode                    String areaCode = (String) context.get("areaCode");                    if (areaCode != null && areaCode.length() > 0) {                        paramList = paramList + "&areaCode=" + areaCode;                        andExprs.add(new EntityExpr("areaCode", true, EntityOperator.EQUALS, areaCode, true));                    }                    // filter on contact number                    String contactNumber = (String) context.get("contactNumber");                    if (contactNumber != null && contactNumber.length() > 0) {                        paramList = paramList + "&contactNumber=" + contactNumber;                        andExprs.add(new EntityExpr("contactNumber", true, EntityOperator.EQUALS, contactNumber, true));                    }                    fieldsToSelect.add("contactNumber");                    fieldsToSelect.add("areaCode");                }                // ---- End of Dynamic View Creation                // build the main condition                if (andExprs.size() > 0) mainCond = new EntityConditionList(andExprs, EntityOperator.AND);            }            Debug.logInfo("In findParty mainCond=" + mainCond, module);            // do the lookup            if (mainCond != null || "Y".equals(showAll)) {                try {                    // set distinct on so we only get one row per order                    EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true);                    // using list iterator                    EntityListIterator pli = delegator.findListIteratorByCondition(dynamicView, mainCond, null, fieldsToSelect, orderBy, findOpts);                    // get the indexes for the partial list                    lowIndex = (((viewIndex - 1) * viewSize) + 1);                    highIndex = viewIndex * viewSize;                    // get the partial list for this page                    partyList = pli.getPartialList(lowIndex, viewSize);                    // attempt to get the full size                    pli.last();                    partyListSize = pli.currentIndex();                    if (highIndex > partyListSize) {                        highIndex = partyListSize;                    }                    // close the list iterator                    pli.close();                } catch (GenericEntityException e) {                    String errMsg = "Failure in party find operation, rolling back transaction: " + e.toString();                    Debug.logError(e, errMsg, module);                    return ServiceUtil.returnError(errMsg);                }            } else {                partyListSize = 0;            }        }        if (partyList == null) partyList = FastList.newInstance();        result.put("partyList", partyList);        result.put("partyListSize", new Integer(partyListSize));        result.put("paramList", paramList);        result.put("highIndex", new Integer(highIndex));        result.put("lowIndex", new Integer(lowIndex));        return result;    }}

⌨️ 快捷键说明

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