You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2013/05/30 15:21:29 UTC

svn commit: r1487854 - in /ofbiz/trunk/applications/order: config/OrderErrorUiLabels.xml src/org/ofbiz/order/order/OrderLookupServices.java

Author: jleroux
Date: Thu May 30 13:21:28 2013
New Revision: 1487854

URL: http://svn.apache.org/r1487854
Log:
A slightly modified patch from Parimal Gain for "Find Order functions - Not working when junk values entered for product Id" https://issues.apache.org/jira/browse/OFBIZ-5201

Problem specification and step -
1) Go to Order Manager app > Find Orders
2) Enter valid product id for which order exists
3) Relevant orders with entered product value would be shown in search results
4) Enter invalid product id - JUNK value
5) Error behvaior:All orders on the system would be highlighted 
6) Actual behavior: No order should be shown as search results, as no order exists with this JUNK product id on system

Observation -
When looked into code level found that system apply check for two condition -
1) If passes productId starts or ends with % or * then add that in condition list as it is and it returns all order that contains the word for product Ids.
2) If the above condition is failed the check if the product corresponding to product id is present or not.
3) If exists then check for variants (if its virtual)all this.
4) If product not exists then the action is missing i.e. no condition is added and it returns all order available.

Recommendation -
There are two ways to solve the issue -
1) If product corresponding to passes productId is not present then return message to user that order is not present.
2) If the thought process for current behavior is show all record if product not available then user should get a message as well that "Order is not available for your search product but we have all these order in system" to convey the correct message to user. 

jleroux: The 1st solution is used. I simply added in label that no productId entered would return all the orders, also in French


Modified:
    ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml
    ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderLookupServices.java

Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml?rev=1487854&r1=1487853&r2=1487854&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml (original)
+++ ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml Thu May 30 13:21:28 2013
@@ -1631,6 +1631,10 @@
         <value xml:lang="zh">激活 wfDelegateAndAcceptAssignment 服务时失败。 </value>
         <value xml:lang="zh_TW">啟動 wfDelegateAndAcceptAssignment 服務時失敗。 </value>
     </property>
+    <property key="OrderFindOrderProductInvalid">
+        <value xml:lang="en">Product ID [${productId}] is not valid. Please enter a valid productId to get related orders (or nothing for all).</value>
+        <value xml:lang="fr">Le produit [${productId}] n'existe pas. Entrez une réf. de produit existante, ou laissez vide pour obtenir toutes les commandes.</value>
+    </property>
     <property key="OrderFixedAssetNotFoundFixedAssetId">
         <value xml:lang="de">Anlage ${fixedAssetId} nicht gefunden</value>
         <value xml:lang="en">fixed_Asset_not_found. Fixed AssetId : ${fixedAssetId}</value>

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=1487854&r1=1487853&r2=1487854&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 30 13:21:28 2013
@@ -21,6 +21,7 @@ package org.ofbiz.order.order;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import javolution.util.FastList;
@@ -31,6 +32,7 @@ import org.ofbiz.base.util.ObjectType;
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.entity.Delegator;
 import org.ofbiz.entity.GenericEntityException;
@@ -67,6 +69,7 @@ public class OrderLookupServices {
         Integer viewSize = (Integer) context.get("viewSize");
         String showAll = (String) context.get("showAll");
         String useEntryDate = (String) context.get("useEntryDate");
+        Locale locale = (Locale) context.get("locale");
         if (showAll == null) {
             showAll = "N";
         }
@@ -392,6 +395,9 @@ public class OrderLookupServices {
                     } else {
                         conditions.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId));
                     }
+                } else {
+                    String failMsg = UtilProperties.getMessage("OrderErrorUiLabels", "OrderFindOrderProductInvalid", UtilMisc.toMap("productId", productId), locale);
+                    return ServiceUtil.returnFailure(failMsg);
                 }
             }
         }