You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2010/04/02 18:50:32 UTC
svn commit: r930325 - in
/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart:
ShoppingCart.java ShoppingCartServices.java
Author: doogie
Date: Fri Apr 2 16:50:32 2010
New Revision: 930325
URL: http://svn.apache.org/viewvc?rev=930325&view=rev
Log:
Add support to loadCartFromOrder for reading of the OrderItemShipGroup
information from the database.
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartServices.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=930325&r1=930324&r2=930325&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 Fri Apr 2 16:50:32 2010
@@ -925,6 +925,24 @@ public class ShoppingCart implements Ite
return newGroup.getGroupNumber();
}
+ public ShoppingCartItemGroup addItemGroup(GenericValue itemGroupValue) throws GenericEntityException {
+ if (itemGroupValue == null) {
+ return null;
+ }
+ String itemGroupNumber = itemGroupValue.getString("orderItemGroupSeqId");
+ ShoppingCartItemGroup itemGroup = this.getItemGroupByNumber(itemGroupNumber);
+ if (itemGroup == null) {
+ ShoppingCartItemGroup parentGroup = addItemGroup(itemGroupValue.getRelatedOneCache("ParentOrderItemGroup"));
+ itemGroup = new ShoppingCartItemGroup(itemGroupNumber, itemGroupValue.getString("groupName"), parentGroup);
+ int parsedGroupNumber = Integer.parseInt(itemGroupNumber);
+ if (parsedGroupNumber > this.nextGroupNumber) {
+ this.nextGroupNumber = parsedGroupNumber + 1;
+ }
+ this.itemGroupByNumberMap.put(itemGroupNumber, itemGroup);
+ }
+ return itemGroup;
+ }
+
public List getCartItemsInNoGroup() {
List cartItemList = FastList.newInstance();
for (ShoppingCartItem cartItem : cartLines) {
@@ -4214,7 +4232,11 @@ public class ShoppingCart implements Ite
/** Note that to avoid foreign key issues when the groups are created a parentGroup should have a lower number than the child group. */
protected ShoppingCartItemGroup(long groupNumber, String groupName, ShoppingCartItemGroup parentGroup) {
- this.groupNumber = UtilFormatOut.formatPaddedNumber(groupNumber, 2);
+ this(UtilFormatOut.formatPaddedNumber(groupNumber, 2), groupName, parentGroup);
+ }
+
+ protected ShoppingCartItemGroup(String groupNumber, String groupName, ShoppingCartItemGroup parentGroup) {
+ this.groupNumber = groupNumber;
this.groupName = groupName;
this.parentGroup = parentGroup;
}
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=930325&r1=930324&r2=930325&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 Fri Apr 2 16:50:32 2010
@@ -473,6 +473,12 @@ public class ShoppingCartServices {
ShoppingCartItem cartItem = cart.findCartItem(itemIndex);
cartItem.setOrderItemSeqId(item.getString("orderItemSeqId"));
+ try {
+ cartItem.setItemGroup(cart.addItemGroup(item.getRelatedOneCache("OrderItemGroup")));
+ } catch (GenericEntityException e) {
+ Debug.logError(e, module);
+ return ServiceUtil.returnError(e.getMessage());
+ }
// attach surveyResponseId for each item
if (UtilValidate.isNotEmpty(surveyResponseResult)){
cartItem.setAttribute("surveyResponseId",surveyResponseResult.get("surveyResponseId"));