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 2008/12/16 19:35:26 UTC

svn commit: r727112 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java

Author: jleroux
Date: Tue Dec 16 10:35:25 2008
New Revision: 727112

URL: http://svn.apache.org/viewvc?rev=727112&view=rev
Log:
A modified patch from Stephen Rufle "ShoppingCartServices.loadCartFromOrder"  '(https://issues.apache.org/jira/browse/OFBIZ-2085) - OFBIZ-2085
I changed for java 1.5 feature (new for loop style, genericization in general)

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

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java?rev=727112&r1=727111&r2=727112&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.java Tue Dec 16 10:35:25 2008
@@ -227,6 +227,22 @@
             cart.setOrderPartyId(endUserParty.getString("partyId"));
         }
 
+        // load order attributes
+        List<GenericValue> orderAttributesList = null;
+        try {
+            orderAttributesList = delegator.findByAnd("OrderAttribute", UtilMisc.toMap("orderId", orderId));
+            if (UtilValidate.isNotEmpty(orderAttributesList)) {
+                for (GenericValue orderAttr : orderAttributesList) {
+                    String name = orderAttr.getString("attrName");
+                    String value = orderAttr.getString("attrValue");
+                    cart.setOrderAttribute(name, value);
+                }
+            }
+        } catch (GenericEntityException e) {
+            Debug.logError(e, module);
+            return ServiceUtil.returnError(e.getMessage());
+        }
+
         // load the payment infos
         List orderPaymentPrefs = null;
         try {
@@ -402,6 +418,22 @@
                 cartItem.setShoppingList(item.getString("shoppingListId"), item.getString("shoppingListItemSeqId"));
                 cartItem.setIsModifiedPrice("Y".equals(item.getString("isModifiedPrice")));
                 
+                // load order item attributes
+                List<GenericValue> orderItemAttributesList = null;
+                try {
+                    orderItemAttributesList = delegator.findByAnd("OrderItemAttribute", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
+                    if (UtilValidate.isNotEmpty(orderAttributesList)) {
+                        for(GenericValue orderItemAttr : orderItemAttributesList) {
+                            String name = orderItemAttr.getString("attrName");
+                            String value = orderItemAttr.getString("attrValue");
+                            cartItem.setOrderItemAttribute(name, value);
+                        }
+                    }
+                } catch (GenericEntityException e) {
+                    Debug.logError(e, module);
+                    return ServiceUtil.returnError(e.getMessage());
+                }
+
                 // set the PO number on the cart
                 cart.setPoNumber(item.getString("correspondingPoId"));