Author: doogie
Date: Tue Mar 9 20:00:24 2010
New Revision: 921092
URL: http://svn.apache.org/viewvc?rev=921092&view=rev
Log:
Make all adjustment lists use generic syntax.
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.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=921092&r1=921091&r2=921092&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 Mar 9 20:00:24 2010
@@ -102,7 +102,7 @@ public class ShoppingCart implements Ite
private String autoSaveListId = null;
/** Holds value of order adjustments. */
- private List adjustments = new LinkedList();
+ private List<GenericValue> adjustments = FastList.newInstance();
// OrderTerms
private boolean orderTermSet = false;
private List orderTerms = new LinkedList();
@@ -185,7 +185,7 @@ public class ShoppingCart implements Ite
this.agreementId = cart.getAgreementId();
this.quoteId = cart.getQuoteId();
this.orderAdditionalEmails = cart.getOrderAdditionalEmails();
- this.adjustments = new LinkedList(cart.getAdjustments());
+ this.adjustments.addAll(cart.getAdjustments());
this.contactMechIdsMap = new HashMap(cart.getOrderContactMechIds());
this.freeShippingProductPromoActions = new
ArrayList(cart.getFreeShippingProductPromoActions());
this.desiredAlternateGiftByAction =
cart.getAllDesiredAlternateGiftByActionCopy();
@@ -2660,7 +2660,7 @@ public class ShoppingCart implements Ite
}
/** Get a List of adjustments on the order (ie cart) */
- public List getAdjustments() {
+ public List<GenericValue> getAdjustments() {
return adjustments;
}
@@ -2743,11 +2743,9 @@ public class ShoppingCart implements Ite
if (orderAdjustmentTypeId == null) return;
// make a list of adjustment lists including the cart adjustments and
the cartItem adjustments for each item
- List adjsLists = new LinkedList();
+ List<List<GenericValue>> adjsLists = FastList.newInstance();
- if (this.getAdjustments() != null) {
- adjsLists.add(this.getAdjustments());
- }
+ adjsLists.add(this.getAdjustments());
Iterator cartIterator = this.iterator();
while (cartIterator.hasNext()) {
@@ -2758,14 +2756,11 @@ public class ShoppingCart implements Ite
}
}
- Iterator adjsListsIter = adjsLists.iterator();
-
- while (adjsListsIter.hasNext()) {
- List adjs = (List) adjsListsIter.next();
+ for (List<GenericValue> adjs: adjsLists) {
if (adjs != null) {
for (int i = 0; i < adjs.size();) {
- GenericValue orderAdjustment = (GenericValue) adjs.get(i);
+ GenericValue orderAdjustment = adjs.get(i);
if
(orderAdjustmentTypeId.equals(orderAdjustment.getString("orderAdjustmentTypeId")))
{
adjs.remove(i);
@@ -3119,11 +3114,11 @@ public class ShoppingCart implements Ite
public void clearAllPromotionAdjustments() {
// remove cart adjustments from promo actions
- List cartAdjustments = this.getAdjustments();
+ List<GenericValue> cartAdjustments = this.getAdjustments();
if (cartAdjustments != null) {
- Iterator cartAdjustmentIter = cartAdjustments.iterator();
+ Iterator<GenericValue> cartAdjustmentIter =
cartAdjustments.iterator();
while (cartAdjustmentIter.hasNext()) {
- GenericValue checkOrderAdjustment = (GenericValue)
cartAdjustmentIter.next();
+ GenericValue checkOrderAdjustment = cartAdjustmentIter.next();
if
(UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoId")) &&
UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoRuleId")) &&
UtilValidate.isNotEmpty(checkOrderAdjustment.getString("productPromoActionSeqId")))
{
@@ -3514,14 +3509,11 @@ public class ShoppingCart implements Ite
}
/** make a list of all adjustments including order adjustments, order line
adjustments, and special adjustments (shipping and tax if applicable) */
- public List makeAllAdjustments() {
- List allAdjs = new LinkedList();
+ public List<GenericValue> makeAllAdjustments() {
+ List<GenericValue> allAdjs = FastList.newInstance();
// before returning adjustments, go through them to find all that need
counter adjustments (for instance: free shipping)
- Iterator allAdjsIter = this.getAdjustments().iterator();
-
- while (allAdjsIter.hasNext()) {
- GenericValue orderAdjustment = (GenericValue) allAdjsIter.next();
+ for (GenericValue orderAdjustment: this.getAdjustments()) {
allAdjs.add(orderAdjustment);
@@ -3557,13 +3549,10 @@ public class ShoppingCart implements Ite
// add all of the item adjustments to this list too
for (ShoppingCartItem item : cartLines) {
- Collection adjs = item.getAdjustments();
+ Collection<GenericValue> adjs = item.getAdjustments();
if (adjs != null) {
- Iterator adjIter = adjs.iterator();
-
- while (adjIter.hasNext()) {
- GenericValue orderAdjustment = (GenericValue)
adjIter.next();
+ for (GenericValue orderAdjustment: adjs) {
orderAdjustment.set("orderItemSeqId",
item.getOrderItemSeqId());
allAdjs.add(orderAdjustment);
@@ -3606,14 +3595,10 @@ public class ShoppingCart implements Ite
/** make a list of all quote adjustments including header adjustments,
line adjustments, and special adjustments (shipping and tax if applicable).
* Internally, the quote adjustments are created from the order
adjustments.
*/
- public List makeAllQuoteAdjustments() {
- List quoteAdjs = new LinkedList();
-
- List orderAdjs = makeAllAdjustments();
- Iterator orderAdjsIter = orderAdjs.iterator();
+ public List<GenericValue> makeAllQuoteAdjustments() {
+ List<GenericValue> quoteAdjs = FastList.newInstance();
- while (orderAdjsIter.hasNext()) {
- GenericValue orderAdj = (GenericValue) orderAdjsIter.next();
+ for (GenericValue orderAdj: makeAllAdjustments()) {
GenericValue quoteAdj =
this.getDelegator().makeValue("QuoteAdjustment");
quoteAdj.put("quoteAdjustmentId",
orderAdj.get("orderAdjustmentId"));
quoteAdj.put("quoteAdjustmentTypeId",
orderAdj.get("orderAdjustmentTypeId"));
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java?rev=921092&r1=921091&r2=921092&view=diff
==============================================================================
---
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
(original)
+++
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
Tue Mar 9 20:00:24 2010
@@ -32,6 +32,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import javolution.util.FastList;
import javolution.util.FastMap;
import org.ofbiz.base.util.Debug;
@@ -137,7 +138,7 @@ public class ShoppingCartItem implements
private Map contactMechIdsMap = FastMap.newInstance();
private List orderItemPriceInfos = null;
- private List itemAdjustments = new LinkedList();
+ private List<GenericValue> itemAdjustments = FastList.newInstance();
private boolean isPromo = false;
private BigDecimal promoQuantityUsed = BigDecimal.ZERO;
private Map quantityUsedPerPromoCandidate = new HashMap();
@@ -676,7 +677,7 @@ public class ShoppingCartItem implements
this.attributes = item.getAttributes() == null ? new HashMap() : new
HashMap(item.getAttributes());
this.contactMechIdsMap = item.getOrderItemContactMechIds() == null ?
null : new HashMap(item.getOrderItemContactMechIds());
this.orderItemPriceInfos = item.getOrderItemPriceInfos() == null ?
null : new LinkedList(item.getOrderItemPriceInfos());
- this.itemAdjustments = item.getAdjustments() == null ? null : new
LinkedList(item.getAdjustments());
+ this.itemAdjustments.addAll(item.getAdjustments());
if (this._product == null) {
this.itemDescription = item.getName();
}
@@ -2195,16 +2196,16 @@ public class ShoppingCartItem implements
itemAdjustments.remove(index);
}
- public List getAdjustments() {
+ public List<GenericValue> getAdjustments() {
return itemAdjustments;
}
public void removeFeatureAdjustment(String productFeatureId) {
if (productFeatureId == null) return;
- Iterator itemAdjustmentsIter = itemAdjustments.iterator();
+ Iterator<GenericValue> itemAdjustmentsIter =
itemAdjustments.iterator();
while (itemAdjustmentsIter.hasNext()) {
- GenericValue itemAdjustment = (GenericValue)
itemAdjustmentsIter.next();
+ GenericValue itemAdjustment = itemAdjustmentsIter.next();
if
(productFeatureId.equals(itemAdjustment.getString("productFeatureId"))) {
itemAdjustmentsIter.remove();
@@ -2434,11 +2435,8 @@ public class ShoppingCartItem implements
// now copy/calc the adjustments
Debug.logInfo("Clone's adj: " + item.getAdjustments(), module);
if (UtilValidate.isNotEmpty(item.getAdjustments())) {
- List adjustments = new LinkedList(item.getAdjustments());
- Iterator adjIterator = adjustments.iterator();
-
- while (adjIterator.hasNext()) {
- GenericValue adjustment = (GenericValue)
adjIterator.next();
+ List<GenericValue> adjustments =
UtilMisc.makeListWritable(item.getAdjustments());
+ for (GenericValue adjustment: adjustments) {
if (adjustment != null) {
item.removeAdjustment(adjustment);
@@ -2466,11 +2464,8 @@ public class ShoppingCartItem implements
// re-calc this item's adjustments
if (UtilValidate.isNotEmpty(this.getAdjustments())) {
- List adjustments = new LinkedList(this.getAdjustments());
- Iterator adjIterator = adjustments.iterator();
-
- while (adjIterator.hasNext()) {
- GenericValue adjustment = (GenericValue)
adjIterator.next();
+ List<GenericValue> adjustments =
UtilMisc.makeListWritable(this.getAdjustments());
+ for (GenericValue adjustment: adjustments) {
if (adjustment != null) {
this.removeAdjustment(adjustment);