svn commit: r1680288 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

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

svn commit: r1680288 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

mbrohl
Author: mbrohl
Date: Tue May 19 13:41:03 2015
New Revision: 1680288

URL: http://svn.apache.org/r1680288
Log:
Applied patch from jira issue OFBIZ-6258: Trivial perfomance improvement for creating OrderItemAttributes during store/update Order.

Thanks Martin Becker for reporting the issue and providing the patch.

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java?rev=1680288&r1=1680287&r2=1680288&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java Tue May 19 13:41:03 2015
@@ -4017,32 +4017,18 @@ public class ShoppingCart implements Ite
                 for (String key : orderItemAttributes.keySet()) {
                     String value = orderItemAttributes.get(key);
 
-                    GenericValue orderItemAttribute = getDelegator().makeValue("OrderItemAttribute");
-                    if (UtilValidate.isNotEmpty(orderId)) {
-                        orderItemAttribute.set("orderId", orderId);
-                    }
-
-                    orderItemAttribute.set("orderItemSeqId", item.getOrderItemSeqId());
-                    orderItemAttribute.set("attrName", key);
-                    orderItemAttribute.set("attrValue", value);
-
-                    switch (mode) {
-                    case ALL:
-                        result.add(orderItemAttribute);
-                        break;
-                    case FILLED_ONLY:
-                        if (UtilValidate.isNotEmpty(value)) {
-                            result.add(orderItemAttribute);
-                        }
-                        break;
-                    case EMPTY_ONLY:
-                        if (UtilValidate.isEmpty(value)) {
-                            result.add(orderItemAttribute);
+                    if (ALL == mode || (FILLED_ONLY == mode && UtilValidate.isNotEmpty(value)) || (EMPTY_ONLY == mode && UtilValidate.isEmpty(value))
+                            || (mode != ALL && mode != FILLED_ONLY && mode != EMPTY_ONLY)) {
+                            
+                        GenericValue orderItemAttribute = getDelegator().makeValue("OrderItemAttribute");
+                        if (UtilValidate.isNotEmpty(orderId)) {
+                            orderItemAttribute.set("orderId", orderId);
                         }
-                        break;
-                    default:
+                        orderItemAttribute.set("orderItemSeqId", item.getOrderItemSeqId());
+                        orderItemAttribute.set("attrName", key);
+                        orderItemAttribute.set("attrValue", value);
+
                         result.add(orderItemAttribute);
-                        break;
                     }
                 }
             }