You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mo...@apache.org on 2009/05/21 12:28:29 UTC
svn commit: r777040 -
/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
Author: mor
Date: Thu May 21 10:28:28 2009
New Revision: 777040
URL: http://svn.apache.org/viewvc?rev=777040&view=rev
Log:
Misc. code improvements recently added for new filters on find order page
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java?rev=777040&r1=777039&r2=777040&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java Thu May 21 10:28:28 2009
@@ -467,52 +467,34 @@
}
}
- //Get all orders according to specific ship to country with "Only Include" or "Do not Include".
+ // Get all orders according to specific ship to country with "Only Include" or "Do not Include".
String countryGeoId = (String) context.get("countryGeoId");
String includeCountry = (String) context.get("includeCountry");
if (UtilValidate.isNotEmpty(countryGeoId) && UtilValidate.isNotEmpty(includeCountry)) {
paramList.add("countryGeoId=" + countryGeoId);
paramList.add("includeCountry=" + includeCountry);
- boolean hasRecord = false;
- List orExprs = FastList.newInstance();
- EntityCondition condition = null;
- List<GenericValue> postalAddresses = null;
- List<GenericValue> orderContactMechs = null;
- try {
- EntityConditionList andExprs = null;
- condition = EntityCondition.makeCondition("contactMechPurposeTypeId", EntityOperator.EQUALS, "SHIPPING_LOCATION");
- orderContactMechs = delegator.findList("OrderContactMech", condition, null, null, null, false);
- if (UtilValidate.isNotEmpty(orderContactMechs)) {
- for (GenericValue orderContactMech : orderContactMechs) {
- if ("Y".equals(includeCountry)) {
- andExprs = EntityCondition.makeCondition( UtilMisc.toList(
- EntityCondition.makeCondition("contactMechId", orderContactMech.get("contactMechId")),
- EntityCondition.makeCondition("countryGeoId", EntityOperator.EQUALS, countryGeoId)
- ), EntityOperator.AND);
- }
- else {
- andExprs = EntityCondition.makeCondition( UtilMisc.toList(
- EntityCondition.makeCondition("contactMechId", orderContactMech.get("contactMechId")),
- EntityCondition.makeCondition("countryGeoId", EntityOperator.NOT_EQUAL, countryGeoId)
- ), EntityOperator.AND);
- }
- postalAddresses = delegator.findList("PostalAddress", andExprs, null, null, null, false);
- if (UtilValidate.isNotEmpty(postalAddresses)) {
- GenericValue postalAddress = EntityUtil.getFirst(postalAddresses);
- if (UtilValidate.isNotEmpty(postalAddress)) {
- orExprs.add(EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderContactMech.get("orderId")));
- hasRecord = true;
- }
- }
- }
- }
- } catch (GenericEntityException e) {
- Debug.logError(e, module);
- }
- EntityCondition shipCountryFilter = EntityCondition.makeCondition(orExprs, EntityOperator.OR);
- if (hasRecord) {
- conditions.add(shipCountryFilter);
+ // add condition to dynamic view
+ dve.addMemberEntity("OCM", "OrderContactMech");
+ dve.addMemberEntity("PA", "PostalAddress");
+ dve.addAlias("OCM", "contactMechId");
+ dve.addAlias("OCM", "contactMechPurposeTypeId");
+ dve.addAlias("PA", "countryGeoId");
+ dve.addViewLink("OH", "OCM", Boolean.FALSE, ModelKeyMap.makeKeyMapList("orderId"));
+ dve.addViewLink("OCM", "PA", Boolean.FALSE, ModelKeyMap.makeKeyMapList("contactMechId"));
+
+ EntityConditionList exprs = null;
+ if ("Y".equals(includeCountry)) {
+ exprs = EntityCondition.makeCondition(UtilMisc.toList(
+ EntityCondition.makeCondition("contactMechPurposeTypeId", "SHIPPING_LOCATION"),
+ EntityCondition.makeCondition("countryGeoId", countryGeoId)
+ ), EntityOperator.AND);
+ } else {
+ exprs = EntityCondition.makeCondition(UtilMisc.toList(
+ EntityCondition.makeCondition("contactMechPurposeTypeId", "SHIPPING_LOCATION"),
+ EntityCondition.makeCondition("countryGeoId", EntityOperator.NOT_EQUAL, countryGeoId)
+ ), EntityOperator.AND);
}
+ conditions.add(exprs);
}
// set distinct on so we only get one row per order
@@ -523,7 +505,7 @@
if (conditions.size() > 0 || showAll.equalsIgnoreCase("Y")) {
cond = EntityCondition.makeCondition(conditions, EntityOperator.AND);
}
-
+
if (Debug.verboseOn()) {
Debug.log("Find order query: " + cond.toString());
}