📄 findparty.bsh
字号:
// ----
// PostalAddress fields
// ----
if (extraInfo != null && extraInfo.equals("P")) {
// 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
address1 = request.getParameter("address1");
if (address1 != null && address1.length() > 0) {
paramList = paramList + "&address1=" + address1;
andExprs.add(new EntityExpr("address1", true, EntityOperator.LIKE, "%"+address1+"%", true));
}
// filter on address2
address2 = request.getParameter("address2");
if (address2 != null && address2.length() > 0) {
paramList = paramList + "&address2=" + address2;
andExprs.add(new EntityExpr("address2", true, EntityOperator.LIKE, "%"+address2+"%", true));
}
// filter on city
city = request.getParameter("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
stateGeo = request.getParameter("stateProvinceGeoId");
if (stateGeo != null && !"ANY".equals(stateGeo)) {
paramList = paramList + "&stateGeo=" + stateGeo;
andExprs.add(new EntityExpr("stateProvinceGeoId", EntityOperator.EQUALS, stateGeo));
}
// filter on postal code
postalCode = request.getParameter("postalCode");
if (postalCode != null && postalCode.length() > 0) {
paramList = paramList + "&postalCode=" + postalCode;
andExprs.add(new EntityExpr("postalCode", true, EntityOperator.EQUALS, postalCode, true));
}
}
// ----
// Generic CM Fields
// ----
if (extraInfo != null && extraInfo.equals("O")) {
// 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
infoString = request.getParameter("infoString");
if (infoString != null && infoString.length() > 0) {
paramList = paramList + "&infoString=" + infoString;
andExprs.add(new EntityExpr("infoString", true, EntityOperator.LIKE, "%"+infoString+"%", true));
}
}
// ----
// TelecomNumber Fields
// ----
if (extraInfo != null && extraInfo.equals("T")) {
// 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
countryCode = request.getParameter("countryCode");
if (countryCode != null && countryCode.length() > 0) {
paramList = paramList + "&countryCode=" + countryCode;
andExprs.add(new EntityExpr("countryCode", true, EntityOperator.EQUALS, countryCode, true));
}
// filter on areaCode
areaCode = request.getParameter("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
contactNumber = request.getParameter("contactNumber");
if (contactNumber != null && contactNumber.length() > 0) {
paramList = paramList + "&contactNumber=" + contactNumber;
andExprs.add(new EntityExpr("contactNumber", true, EntityOperator.EQUALS, contactNumber, true));
}
}
// ---- End of Dynamic View Creation
// build the main condition
if (andExprs.size() > 0 || showAll.equalsIgnoreCase("Y")) mainCond = new EntityConditionList(andExprs, EntityOperator.AND);
// do the lookup
if (lookupErrorMessage == null && mainCond != null) {
// fields we need to select; will be used to set distinct
List fieldsToSelect = new ArrayList();
List orderBy = new ArrayList();
fieldsToSelect.add("partyId");
fieldsToSelect.add("partyTypeId");
// UserLogin
if (userLoginId != null && userLoginId.length() > 0) {
fieldsToSelect.add("userLoginId");
}
// Person
if ((firstName != null && firstName.length() > 0) || (lastName != null && lastName.length() > 0)) {
fieldsToSelect.add("firstName");
fieldsToSelect.add("lastName");
orderBy.add("lastName");
orderBy.add("firstName");
}
// PartyGroup
if (groupName != null && groupName.length() > 0) {
fieldsToSelect.add("groupName");
orderBy.add("groupName");
}
// RoleType
if (roleType != null && !"ANY".equals(roleType)) {
fieldsToSelect.add("roleTypeId");
}
// PostalAddress
if (extraInfo != null && extraInfo.equals("P")) {
fieldsToSelect.add("postalCode");
}
// TelecomNumber
if (extraInfo != null && extraInfo.equals("T")) {
fieldsToSelect.add("areaCode");
}
// ContactMech
if (extraInfo != null && extraInfo.equals("O")) {
fieldsToSelect.add("infoString");
}
// 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);
if (partyList == null) {
partyList = new ArrayList();
}
// attempt to get the full size
pli.last();
partyListSize = pli.currentIndex();
if (highIndex > partyListSize) {
highIndex = partyListSize;
}
// close the list iterator
pli.close();
} else {
partyList = new ArrayList();
partyListSize = 0;
}
context.put("partyList", partyList);
context.put("partyListSize", partyListSize);
if (lookupErrorMessage != null) {
context.put("lookupErrorMessage", lookupErrorMessage);
}
}
context.put("paramList", paramList);
context.put("highIndex", highIndex);
context.put("lowIndex", lowIndex);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -