svn commit: r574601 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java

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

svn commit: r574601 - /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java

hansbak-2
Author: hansbak
Date: Tue Sep 11 07:08:40 2007
New Revision: 574601

URL: http://svn.apache.org/viewvc?rev=574601&view=rev
Log:
add a new class to be able to add additional shoppinglists to an existing shoppingcart

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=574601&r1=574600&r2=574601&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppinglist/ShoppingListServices.java Tue Sep 11 07:08:40 2007
@@ -391,10 +391,27 @@
             }
         }
     }
-
+    /**
+     * Create a new shoppingCart form a shoppingList
+     * @param dispatcher
+     * @param shoppingList
+     * @param locale
+     * @return
+     */
     public static ShoppingCart makeShoppingListCart(LocalDispatcher dispatcher, GenericValue shoppingList, Locale locale) {
+     return makeShoppingListCart(null, dispatcher, shoppingList, locale); }
+
+    /**
+     * Add a shoppinglist to an existing shoppingcart
+     *
+     * @param shoppingCart
+     * @param dispatcher
+     * @param shoppingList
+     * @param locale
+     * @return
+     */
+    public static ShoppingCart makeShoppingListCart(ShoppingCart listCart, LocalDispatcher dispatcher, GenericValue shoppingList, Locale locale) {
         GenericDelegator delegator = dispatcher.getDelegator();
-        ShoppingCart listCart = null;
         if (shoppingList != null && shoppingList.get("productStoreId") != null) {
             String productStoreId = shoppingList.getString("productStoreId");
             String currencyUom = shoppingList.getString("currencyUom");
@@ -417,9 +434,20 @@
             }
 
             if (UtilValidate.isNotEmpty(items)) {
-                listCart = new ShoppingCart(delegator, productStoreId, locale, currencyUom);
-                listCart.setOrderPartyId(shoppingList.getString("partyId"));
-                listCart.setAutoOrderShoppingListId(shoppingList.getString("shoppingListId"));
+             if (listCart == null) {
+             listCart = new ShoppingCart(delegator, productStoreId, locale, currencyUom);
+             listCart.setOrderPartyId(shoppingList.getString("partyId"));
+             listCart.setAutoOrderShoppingListId(shoppingList.getString("shoppingListId"));
+             } else {
+             if (!listCart.getPartyId().equals(shoppingList.getString("partyId"))){
+             Debug.logError("CANNOT add shoppingList: " + shoppingList.getString("shoppingListId")
+             + " of partyId: " + shoppingList.getString("partyId")
+             + " to a shoppingcart with a different orderPartyId: "
+             + listCart.getPartyId(), module);
+                 return listCart;
+             }
+             }
+            
 
                 Iterator i = items.iterator();
                 while (i.hasNext()) {
@@ -431,7 +459,7 @@
                     if (shoppingListItem.get("reservLength") != null) {
                         reservLength = shoppingListItem.getDouble("reservLength");
                     }
-                    Double reservPersons = null;;
+                    Double reservPersons = null;
                     if (shoppingListItem.get("reservPersons") != null) {
                         reservPersons = shoppingListItem.getDouble("reservPersons");
                     }