You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2011/02/01 21:42:31 UTC

svn commit: r1066196 - in /ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart: ShoppingCart.java ShoppingCartItem.java shipping/ShippingEstimateWrapper.java shipping/ShippingEvents.java

Author: mrisaliti
Date: Tue Feb  1 20:42:31 2011
New Revision: 1066196

URL: http://svn.apache.org/viewvc?rev=1066196&view=rev
Log:
Remove of the compilation warnings of ShippingEstimateWrapper/ShippingEvents and the invoked methods into ShoppingCart/ShoppingCartItem (OFBIZ-4102)

Modified:
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCart.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartItem.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java
    ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.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=1066196&r1=1066195&r2=1066196&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 Feb  1 20:42:31 2011
@@ -2939,9 +2939,9 @@ public class ShoppingCart implements Ite
     }
 
     /** Returns a List of shippable item's size for a specific ship group. */
-    public List getShippableSizes(int idx) {
+    public List<BigDecimal> getShippableSizes(int idx) {
         CartShipInfo info = this.getShipInfo(idx);
-        List shippableSizes = new LinkedList();
+        List<BigDecimal> shippableSizes = FastList.newInstance();
 
         for (ShoppingCartItem item : info.shipItemInfo.keySet()) {
             CartShipInfo.CartShipItemInfo csii = info.shipItemInfo.get(item);
@@ -2956,15 +2956,15 @@ public class ShoppingCart implements Ite
     }
 
     /** Returns a List of shippable item info (quantity, size, weight) for a specific ship group */
-    public List getShippableItemInfo(int idx) {
+    public List<Map<String, Object>> getShippableItemInfo(int idx) {
         CartShipInfo info = this.getShipInfo(idx);
-        List itemInfos = new LinkedList();
+        List<Map<String, Object>> itemInfos = FastList.newInstance();
 
         for (ShoppingCartItem item : info.shipItemInfo.keySet()) {
             CartShipInfo.CartShipItemInfo csii = info.shipItemInfo.get(item);
             if (csii != null && csii.quantity.compareTo(BigDecimal.ZERO) > 0) {
                 if (item.shippingApplies()) {
-                    Map itemInfo = item.getItemProductInfo();
+                    Map<String, Object> itemInfo = item.getItemProductInfo();
                     itemInfo.put("quantity", csii.quantity);
                     itemInfos.add(itemInfo);
                 }
@@ -3003,9 +3003,9 @@ public class ShoppingCart implements Ite
     }
 
     /** Returns a Map of all features applied to products in the cart with quantities for a specific ship group. */
-    public Map getFeatureIdQtyMap(int idx) {
+    public Map<String, BigDecimal> getFeatureIdQtyMap(int idx) {
         CartShipInfo info = this.getShipInfo(idx);
-        Map featureMap = new HashMap();
+        Map<String, BigDecimal> featureMap = FastMap.newInstance();
 
         for (ShoppingCartItem item : info.shipItemInfo.keySet()) {
             CartShipInfo.CartShipItemInfo csii = (CartShipInfo.CartShipItemInfo) info.shipItemInfo.get(item);

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=1066196&r1=1066195&r2=1066196&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 Feb  1 20:42:31 2011
@@ -49,6 +49,7 @@ import org.ofbiz.entity.GenericEntityExc
 import org.ofbiz.entity.GenericPK;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityExpr;
 import org.ofbiz.entity.condition.EntityOperator;
 import org.ofbiz.entity.util.EntityUtil;
 import org.ofbiz.order.order.OrderReadHelper;
@@ -1912,8 +1913,8 @@ public class ShoppingCartItem implements
     }
 
 
-    public Map getItemProductInfo() {
-        Map itemInfo = FastMap.newInstance();
+    public Map<String, Object> getItemProductInfo() {
+        Map<String, Object> itemInfo = FastMap.newInstance();
         itemInfo.put("productId", this.getProductId());
         itemInfo.put("weight", this.getWeight());
         itemInfo.put("weightUomId", this.getProduct().getString("weightUomId"));
@@ -2146,24 +2147,24 @@ public class ShoppingCartItem implements
         return this.additionalProductFeatureAndAppls;
     }
 
-    public Map getFeatureIdQtyMap(BigDecimal quantity) {
-        Map featureMap = FastMap.newInstance();
+    public Map<String, BigDecimal> getFeatureIdQtyMap(BigDecimal quantity) {
+        Map<String, BigDecimal> featureMap = FastMap.newInstance();
         GenericValue product = this.getProduct();
         if (product != null) {
-            List featureAppls = null;
+            List<GenericValue> featureAppls = null;
             try {
                 featureAppls = product.getRelated("ProductFeatureAppl");
-                List filterExprs = UtilMisc.toList(EntityCondition.makeCondition("productFeatureApplTypeId", EntityOperator.EQUALS, "STANDARD_FEATURE"));
+                List<EntityExpr> filterExprs = UtilMisc.toList(EntityCondition.makeCondition("productFeatureApplTypeId", EntityOperator.EQUALS, "STANDARD_FEATURE"));
                 filterExprs.add(EntityCondition.makeCondition("productFeatureApplTypeId", EntityOperator.EQUALS, "REQUIRED_FEATURE"));
                 featureAppls = EntityUtil.filterByOr(featureAppls, filterExprs);
             } catch (GenericEntityException e) {
                 Debug.logError(e, "Unable to get features from product : " + product.get("productId"), module);
             }
             if (featureAppls != null) {
-                Iterator fai = featureAppls.iterator();
+                Iterator<GenericValue> fai = featureAppls.iterator();
                 while (fai.hasNext()) {
-                    GenericValue appl = (GenericValue) fai.next();
-                    BigDecimal lastQuantity = (BigDecimal) featureMap.get(appl.getString("productFeatureId"));
+                    GenericValue appl = fai.next();
+                    BigDecimal lastQuantity = featureMap.get(appl.getString("productFeatureId"));
                     if (lastQuantity == null) {
                         lastQuantity = BigDecimal.ZERO;
                     }
@@ -2173,10 +2174,10 @@ public class ShoppingCartItem implements
             }
         }
         if (this.additionalProductFeatureAndAppls != null) {
-            Iterator aapi = this.additionalProductFeatureAndAppls.values().iterator();
+            Iterator<GenericValue> aapi = this.additionalProductFeatureAndAppls.values().iterator();
             while (aapi.hasNext()) {
-                GenericValue appl = (GenericValue) aapi.next();
-                BigDecimal lastQuantity = (BigDecimal) featureMap.get(appl.getString("productFeatureId"));
+                GenericValue appl = aapi.next();
+                BigDecimal lastQuantity = featureMap.get(appl.getString("productFeatureId"));
                 if (lastQuantity == null) {
                     lastQuantity = BigDecimal.ZERO;
                 }

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java?rev=1066196&r1=1066195&r2=1066196&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEstimateWrapper.java Tue Feb  1 20:42:31 2011
@@ -43,9 +43,9 @@ public class ShippingEstimateWrapper {
     protected List<GenericValue> shippingMethods = null;
 
     protected GenericValue shippingAddress = null;
-    protected Map shippableItemFeatures = null;
-    protected List shippableItemSizes = null;
-    protected List shippableItemInfo = null;
+    protected Map<String, BigDecimal> shippableItemFeatures = null;
+    protected List<BigDecimal> shippableItemSizes = null;
+    protected List<Map<String, Object>> shippableItemInfo = null;
     protected String productStoreId = null;
     protected BigDecimal shippableQuantity = BigDecimal.ZERO;
     protected BigDecimal shippableWeight = BigDecimal.ZERO;
@@ -95,7 +95,7 @@ public class ShippingEstimateWrapper {
                 String productStoreShipMethId = shipMethod.getString("productStoreShipMethId");
                 String shippingCmId = shippingAddress != null ? shippingAddress.getString("contactMechId") : null;
 
-                Map estimateMap = ShippingEvents.getShipGroupEstimate(dispatcher, delegator, "SALES_ORDER",
+                Map<String, Object> estimateMap = ShippingEvents.getShipGroupEstimate(dispatcher, delegator, "SALES_ORDER",
                         shippingMethodTypeId, carrierPartyId, carrierRoleTypeId, shippingCmId, productStoreId,
                         supplierPartyId, shippableItemInfo, shippableWeight, shippableQuantity, shippableTotal, partyId, productStoreShipMethId);
 

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java?rev=1066196&r1=1066195&r2=1066196&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/shipping/ShippingEvents.java Tue Feb  1 20:42:31 2011
@@ -19,14 +19,15 @@
 package org.ofbiz.order.shoppingcart.shipping;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilMisc;
@@ -66,7 +67,7 @@ public class ShippingEvents {
             if (UtilValidate.isEmpty(shipmentMethodTypeId)) {
                 continue;
             }
-            Map result = getShipGroupEstimate(dispatcher, delegator, cart, i);
+            Map<String, Object> result = getShipGroupEstimate(dispatcher, delegator, cart, i);
             ServiceUtil.getMessages(request, result, null, "", "", "", "", null, null);
             if (result.get(ModelService.RESPONSE_MESSAGE).equals(ModelService.RESPOND_ERROR)) {
                 return "error";
@@ -101,10 +102,10 @@ public class ShippingEvents {
                 cart.getShippableWeight(groupNo), cart.getShippableQuantity(groupNo), cart.getShippableTotal(groupNo), cart.getPartyId(), productStoreShipMethId);
     }
 
-    public static Map getShipEstimate(LocalDispatcher dispatcher, Delegator delegator, OrderReadHelper orh, String shipGroupSeqId) {
+    public static Map<String, Object> getShipEstimate(LocalDispatcher dispatcher, Delegator delegator, OrderReadHelper orh, String shipGroupSeqId) {
         // check for shippable items
         if (!orh.shippingApplies()) {
-            Map responseResult = ServiceUtil.returnSuccess();
+            Map<String, Object> responseResult = ServiceUtil.returnSuccess();
             responseResult.put("shippingTotal", BigDecimal.ZERO);
             return responseResult;
         }
@@ -117,7 +118,7 @@ public class ShippingEvents {
 
         GenericValue shipAddr = orh.getShippingAddress(shipGroupSeqId);
         if (shipAddr == null) {
-            return UtilMisc.toMap("shippingTotal", BigDecimal.ZERO);
+            return UtilMisc.<String, Object>toMap("shippingTotal", BigDecimal.ZERO);
         }
 
         String contactMechId = shipAddr.getString("contactMechId");
@@ -132,21 +133,21 @@ public class ShippingEvents {
     }
 
     // version with no support for using the supplier's address as the origin
-    public static Map getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId,
+    public static Map<String, Object> getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId,
             String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId,
-            String productStoreId, List itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity,
+            String productStoreId, List<Map<String, Object>> itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity,
             BigDecimal shippableTotal, String partyId, String productStoreShipMethId) {
         return getShipGroupEstimate(dispatcher, delegator, orderTypeId, shipmentMethodTypeId, carrierPartyId,
                 carrierRoleTypeId, shippingContactMechId, productStoreId, null, itemInfo,
                 shippableWeight, shippableQuantity, shippableTotal, partyId,productStoreShipMethId);
     }
 
-    public static Map getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId,
+    public static Map<String, Object> getShipGroupEstimate(LocalDispatcher dispatcher, Delegator delegator, String orderTypeId,
             String shipmentMethodTypeId, String carrierPartyId, String carrierRoleTypeId, String shippingContactMechId,
-            String productStoreId, String supplierPartyId, List itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity,
+            String productStoreId, String supplierPartyId, List<Map<String, Object>> itemInfo, BigDecimal shippableWeight, BigDecimal shippableQuantity,
             BigDecimal shippableTotal, String partyId, String productStoreShipMethId) {
         String standardMessage = "A problem occurred calculating shipping. Fees will be calculated offline.";
-        List errorMessageList = new ArrayList();
+        List<String> errorMessageList = FastList.newInstance();
 
         if ("NO_SHIPPING".equals(shipmentMethodTypeId)) {
             return ServiceUtil.returnSuccess();
@@ -188,7 +189,7 @@ public class ShippingEvents {
 
         // no shippable items; we won't change any shipping at all
         if (shippableQuantity.compareTo(BigDecimal.ZERO) == 0) {
-            Map result = ServiceUtil.returnSuccess();
+            Map<String, Object> result = ServiceUtil.returnSuccess();
             result.put("shippingTotal", BigDecimal.ZERO);
             return result;
         }
@@ -206,7 +207,7 @@ public class ShippingEvents {
         BigDecimal shippingTotal = BigDecimal.ZERO;
 
         // prepare the service invocation fields
-        Map serviceFields = new HashMap();
+        Map<String, Object> serviceFields = FastMap.newInstance();
         serviceFields.put("initialEstimateAmt", shippingTotal);
         serviceFields.put("shippableTotal", shippableTotal);
         serviceFields.put("shippableQuantity", shippableQuantity);
@@ -248,14 +249,14 @@ public class ShippingEvents {
         }
 
         // return the totals
-        Map responseResult = ServiceUtil.returnSuccess();
+        Map<String, Object> responseResult = ServiceUtil.returnSuccess();
         responseResult.put("shippingTotal", shippingTotal);
         return responseResult;
     }
 
-    public static BigDecimal getGenericShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map context) throws GeneralException {
+    public static BigDecimal getGenericShipEstimate(LocalDispatcher dispatcher, GenericValue storeShipMeth, Map <String, ? extends Object>context) throws GeneralException {
         // invoke the generic estimate service next -- append to estimate amount
-        Map genericEstimate = null;
+        Map<String, Object> genericEstimate = null;
         BigDecimal genericShipAmt = null;
         try {
             genericEstimate = dispatcher.runSync("calcShipmentCostEstimate", context);