[ofbiz-framework] branch trunk updated: Improved: Refactor PickListServices#isBinComplete method to remove unnecessary iterations(OFBIZ-11823)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Refactor PickListServices#isBinComplete method to remove unnecessary iterations(OFBIZ-11823)

Pawan Verma-2
This is an automated email from the ASF dual-hosted git repository.

pawan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9cf6ec8  Improved: Refactor PickListServices#isBinComplete method to remove unnecessary iterations(OFBIZ-11823)
9cf6ec8 is described below

commit 9cf6ec8c909998a3b808a4de9c34085e36bd775b
Author: Pawan Verma <[hidden email]>
AuthorDate: Sat Jun 27 11:27:51 2020 +0530

    Improved: Refactor PickListServices#isBinComplete method to remove unnecessary iterations(OFBIZ-11823)
   
    Thanks: Suraj and Jacques for the review.
---
 .../ofbiz/shipment/picklist/PickListServices.java  | 26 ++++++++--------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/applications/product/src/main/java/org/apache/ofbiz/shipment/picklist/PickListServices.java b/applications/product/src/main/java/org/apache/ofbiz/shipment/picklist/PickListServices.java
index f53ce44..98b74d2 100644
--- a/applications/product/src/main/java/org/apache/ofbiz/shipment/picklist/PickListServices.java
+++ b/applications/product/src/main/java/org/apache/ofbiz/shipment/picklist/PickListServices.java
@@ -25,7 +25,7 @@ import java.util.Map;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.GeneralException;
 import org.apache.ofbiz.base.util.UtilGenerics;
-import org.apache.ofbiz.base.util.UtilValidate;
+import org.apache.ofbiz.base.util.UtilMisc;
 import org.apache.ofbiz.entity.Delegator;
 import org.apache.ofbiz.entity.GenericEntityException;
 import org.apache.ofbiz.entity.GenericValue;
@@ -86,27 +86,19 @@ public class PickListServices {
     }
 
     public static boolean isBinComplete(Delegator delegator, String picklistBinId) throws GeneralException {
-        // lookup the items in the bin
-        List<GenericValue> items;
         try {
-            items = EntityQuery.use(delegator).from("PicklistItem").where("picklistBinId", picklistBinId).queryList();
+            EntityCondition cond = EntityCondition.makeCondition(
+                    EntityCondition.makeCondition("itemStatusId", EntityOperator.NOT_IN, UtilMisc.toList("PICKITEM_COMPLETED", "PICKITEM_CANCELLED")),
+                    EntityCondition.makeCondition("picklistBinId", picklistBinId));
+            long picklistItemCount = EntityQuery.use(delegator).from("PicklistItem").where(cond).queryCount();
+            if (picklistItemCount != 0) {
+                return false;
+            }
         } catch (GenericEntityException e) {
             Debug.logError(e, MODULE);
             throw e;
         }
 
-        if (UtilValidate.isNotEmpty(items)) {
-            for (GenericValue v: items) {
-                String itemStatus = v.getString("itemStatusId");
-                if (itemStatus != null) {
-                    if (!"PICKITEM_COMPLETED".equals(itemStatus)) {
-                        return false;
-                    }
-                }
-            }
-            return true;
-        }
-
-        return false;
+        return true;
     }
 }