Make all adjustment lists use generic syntax.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@921092 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -102,7 +102,7 @@ public class ShoppingCart implements Iterable<ShoppingCartItem>, Serializable {
|
||||
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 Iterable<ShoppingCartItem>, Serializable {
|
||||
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 Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
/** 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 Iterable<ShoppingCartItem>, Serializable {
|
||||
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 Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
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 Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
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 Iterable<ShoppingCartItem>, Serializable {
|
||||
}
|
||||
|
||||
/** 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 Iterable<ShoppingCartItem>, Serializable {
|
||||
|
||||
// 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 Iterable<ShoppingCartItem>, Serializable {
|
||||
/** 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();
|
||||
public List<GenericValue> makeAllQuoteAdjustments() {
|
||||
List<GenericValue> quoteAdjs = FastList.newInstance();
|
||||
|
||||
List orderAdjs = makeAllAdjustments();
|
||||
Iterator orderAdjsIter = orderAdjs.iterator();
|
||||
|
||||
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"));
|
||||
|
||||
@@ -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 java.io.Serializable {
|
||||
|
||||
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 java.io.Serializable {
|
||||
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 java.io.Serializable {
|
||||
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 java.io.Serializable {
|
||||
// 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 java.io.Serializable {
|
||||
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user