You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2009/11/13 04:15:00 UTC

svn commit: r835719 [2/2] - /ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java

Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=835719&r1=835718&r2=835719&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Fri Nov 13 03:14:59 2009
@@ -19,7 +19,6 @@
 package org.ofbiz.order.order;
 
 import java.math.BigDecimal;
-import org.ofbiz.base.util.UtilDateTime;
 import java.sql.Timestamp;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -34,8 +33,10 @@
 
 import javolution.util.FastList;
 import javolution.util.FastMap;
+import javolution.util.FastSet;
 
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilDateTime;
 import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilNumber;
@@ -74,20 +75,20 @@
     public static final BigDecimal percentage = (new BigDecimal("0.01")).setScale(scale, rounding);
 
     protected GenericValue orderHeader = null;
-    protected List orderItemAndShipGrp = null;
+    protected List<GenericValue> orderItemAndShipGrp = null;
     protected List<GenericValue> orderItems = null;
-    protected List adjustments = null;
+    protected List<GenericValue> adjustments = null;
     protected List<GenericValue> paymentPrefs = null;
-    protected List orderStatuses = null;
-    protected List orderItemPriceInfos = null;
-    protected List orderItemShipGrpInvResList = null;
-    protected List orderItemIssuances = null;
-    protected List orderReturnItems = null;
+    protected List<GenericValue> orderStatuses = null;
+    protected List<GenericValue> orderItemPriceInfos = null;
+    protected List<GenericValue> orderItemShipGrpInvResList = null;
+    protected List<GenericValue> orderItemIssuances = null;
+    protected List<GenericValue> orderReturnItems = null;
     protected BigDecimal totalPrice = null;
 
     protected OrderReadHelper() {}
 
-    public OrderReadHelper(GenericValue orderHeader, List adjustments, List orderItems) {
+    public OrderReadHelper(GenericValue orderHeader, List<GenericValue> adjustments, List<GenericValue> orderItems) {
         this.orderHeader = orderHeader;
         this.adjustments = adjustments;
         this.orderItems = orderItems;
@@ -117,7 +118,7 @@
         this(orderHeader, null, null);
     }
 
-    public OrderReadHelper(List adjustments, List orderItems) {
+    public OrderReadHelper(List<GenericValue> adjustments, List<GenericValue> orderItems) {
         this.adjustments = adjustments;
         this.orderItems = orderItems;
     }
@@ -178,7 +179,7 @@
         return orderHeader.getString("orderName");
     }
 
-    public List getAdjustments() {
+    public List<GenericValue> getAdjustments() {
         if (adjustments == null) {
             try {
                 adjustments = orderHeader.getRelated("OrderAdjustment");
@@ -186,7 +187,7 @@
                 Debug.logError(e, module);
             }
             if (adjustments == null)
-                adjustments = new ArrayList();
+                adjustments = FastList.newInstance();
         }
         return adjustments;
     }
@@ -206,19 +207,19 @@
      * Returns a Map of paymentMethodId -> amount charged (BigDecimal) based on PaymentGatewayResponse.
      * @return
      */
-    public Map getReceivedPaymentTotalsByPaymentMethod() {
-        Map paymentMethodAmounts = FastMap.newInstance();
-        List paymentPrefs = getPaymentPreferences();
-        Iterator ppit = paymentPrefs.iterator();
+    public Map<String, BigDecimal> getReceivedPaymentTotalsByPaymentMethod() {
+        Map<String, BigDecimal> paymentMethodAmounts = FastMap.newInstance();
+        List<GenericValue> paymentPrefs = getPaymentPreferences();
+        Iterator<GenericValue> ppit = paymentPrefs.iterator();
         while (ppit.hasNext()) {
-            GenericValue paymentPref = (GenericValue) ppit.next();
-            List payments = FastList.newInstance();
+            GenericValue paymentPref = ppit.next();
+            List<GenericValue> payments = FastList.newInstance();
             try {
-                List exprs = UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_RECEIVED"),
+                List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_RECEIVED"),
                                             EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_CONFIRMED"));
                 payments = paymentPref.getRelated("Payment");
                 payments = EntityUtil.filterByOr(payments, exprs);
-                List conds = UtilMisc.toList(EntityCondition.makeCondition("paymentTypeId", EntityOperator.EQUALS, "CUSTOMER_PAYMENT"),
+                List<EntityExpr> conds = UtilMisc.toList(EntityCondition.makeCondition("paymentTypeId", EntityOperator.EQUALS, "CUSTOMER_PAYMENT"),
                                             EntityCondition.makeCondition("paymentTypeId", EntityOperator.EQUALS, "CUSTOMER_DEPOSIT"),
                                             EntityCondition.makeCondition("paymentTypeId", EntityOperator.EQUALS, "INTEREST_RECEIPT"),
                                             EntityCondition.makeCondition("paymentTypeId", EntityOperator.EQUALS, "GC_DEPOSIT"),
@@ -229,9 +230,9 @@
             }
 
             BigDecimal chargedToPaymentPref = ZERO;
-            Iterator payit = payments.iterator();
+            Iterator<GenericValue> payit = payments.iterator();
             while (payit.hasNext()) {
-                GenericValue payment = (GenericValue) payit.next();
+                GenericValue payment = payit.next();
                 if (payment.get("amount") != null) {
                     chargedToPaymentPref = chargedToPaymentPref.add(payment.getBigDecimal("amount")).setScale(scale+1, rounding);
                 }
@@ -242,7 +243,7 @@
                 // key of the resulting map is paymentMethodId or paymentMethodTypeId if the paymentMethodId is not available
                 String paymentMethodKey = paymentPref.getString("paymentMethodId") != null ? paymentPref.getString("paymentMethodId") : paymentPref.getString("paymentMethodTypeId");
                 if (paymentMethodAmounts.containsKey(paymentMethodKey)) {
-                    BigDecimal value = (BigDecimal) paymentMethodAmounts.get(paymentMethodKey);
+                    BigDecimal value = paymentMethodAmounts.get(paymentMethodKey);
                     if (value != null) chargedToPaymentPref = chargedToPaymentPref.add(value);
                 }
                 paymentMethodAmounts.put(paymentMethodKey, chargedToPaymentPref.setScale(scale, rounding));
@@ -255,22 +256,22 @@
      * Returns a Map of paymentMethodId -> amount refunded
      * @return
      */
-    public Map getReturnedTotalsByPaymentMethod() {
-        Map paymentMethodAmounts = FastMap.newInstance();
-        List paymentPrefs = getPaymentPreferences();
-        Iterator ppit = paymentPrefs.iterator();
+    public Map<String, BigDecimal> getReturnedTotalsByPaymentMethod() {
+        Map<String, BigDecimal> paymentMethodAmounts = FastMap.newInstance();
+        List<GenericValue> paymentPrefs = getPaymentPreferences();
+        Iterator<GenericValue> ppit = paymentPrefs.iterator();
         while (ppit.hasNext()) {
-            GenericValue paymentPref = (GenericValue) ppit.next();
-            List returnItemResponses = new ArrayList();
+            GenericValue paymentPref = ppit.next();
+            List<GenericValue> returnItemResponses = FastList.newInstance();
             try {
                 returnItemResponses = orderHeader.getDelegator().findByAnd("ReturnItemResponse", UtilMisc.toMap("orderPaymentPreferenceId", paymentPref.getString("orderPaymentPreferenceId")));
             } catch (GenericEntityException e) {
                 Debug.logError(e, module);
             }
             BigDecimal refundedToPaymentPref = ZERO;
-            Iterator ririt = returnItemResponses.iterator();
+            Iterator<GenericValue> ririt = returnItemResponses.iterator();
             while (ririt.hasNext()) {
-                GenericValue returnItemResponse = (GenericValue) ririt.next();
+                GenericValue returnItemResponse = ririt.next();
                 refundedToPaymentPref = refundedToPaymentPref.add(returnItemResponse.getBigDecimal("responseAmount")).setScale(scale+1, rounding);
             }
 
@@ -283,13 +284,13 @@
         return paymentMethodAmounts;
     }
 
-    public List getOrderPayments() {
+    public List<GenericValue> getOrderPayments() {
         return getOrderPayments(null);
     }
 
-    public List getOrderPayments(GenericValue orderPaymentPreference) {
-        List orderPayments = new ArrayList();
-        List prefs = null;
+    public List<GenericValue> getOrderPayments(GenericValue orderPaymentPreference) {
+        List<GenericValue> orderPayments = FastList.newInstance();
+        List<GenericValue> prefs = null;
 
         if (orderPaymentPreference == null) {
             prefs = getPaymentPreferences();
@@ -297,9 +298,9 @@
             prefs = UtilMisc.toList(orderPaymentPreference);
         }
         if (prefs != null) {
-            Iterator i = prefs.iterator();
+            Iterator<GenericValue> i = prefs.iterator();
             while (i.hasNext()) {
-                GenericValue payPref = (GenericValue) i.next();
+                GenericValue payPref = i.next();
                 try {
                     orderPayments.addAll(payPref.getRelated("Payment"));
                 } catch (GenericEntityException e) {
@@ -311,7 +312,7 @@
         return orderPayments;
     }
 
-    public List getOrderStatuses() {
+    public List<GenericValue> getOrderStatuses() {
         if (orderStatuses == null) {
             try {
                 orderStatuses = orderHeader.getRelated("OrderStatus");
@@ -322,7 +323,7 @@
         return orderStatuses;
     }
 
-    public List getOrderTerms() {
+    public List<GenericValue> getOrderTerms() {
         try {
            return orderHeader.getRelated("OrderTerm");
         } catch (GenericEntityException e) {
@@ -335,13 +336,13 @@
      * @return Long number of days from termDays of first FIN_PAYMENT_TERM
      */
     public Long getOrderTermNetDays() {
-        List orderTerms = EntityUtil.filterByAnd(getOrderTerms(), UtilMisc.toMap("termTypeId", "FIN_PAYMENT_TERM"));
+        List<GenericValue> orderTerms = EntityUtil.filterByAnd(getOrderTerms(), UtilMisc.toMap("termTypeId", "FIN_PAYMENT_TERM"));
         if ((orderTerms == null) || (orderTerms.size() == 0)) {
             return null;
         } else if (orderTerms.size() > 1) {
             Debug.logWarning("Found " + orderTerms.size() + " FIN_PAYMENT_TERM order terms for orderId [" + getOrderId() + "], using the first one ", module);
         }
-        return ((GenericValue) orderTerms.get(0)).getLong("termDays");
+        return orderTerms.get(0).getLong("termDays");
     }
 
     public String getShippingMethod(String shipGroupSeqId) {
@@ -399,9 +400,9 @@
     }
 
     public boolean hasPhysicalProductItems() throws GenericEntityException {
-        Iterator orderItemIter = this.getOrderItems().iterator();
+        Iterator<GenericValue> orderItemIter = this.getOrderItems().iterator();
         while (orderItemIter.hasNext()) {
-            GenericValue orderItem = (GenericValue) orderItemIter.next();
+            GenericValue orderItem = orderItemIter.next();
             GenericValue product = orderItem.getRelatedOneCache("Product");
             if (product != null) {
                 GenericValue productType = product.getRelatedOneCache("ProductType");
@@ -423,7 +424,7 @@
         return null;
     }
 
-    public List getOrderItemShipGroups() {
+    public List<GenericValue> getOrderItemShipGroups() {
         try {
             return orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipGroupSeqId"));
         } catch (GenericEntityException e) {
@@ -432,13 +433,13 @@
         return null;
     }
 
-    public List getShippingLocations() {
-        List shippingLocations = FastList.newInstance();
-        List shippingCms = this.getOrderContactMechs("SHIPPING_LOCATION");
+    public List<GenericValue> getShippingLocations() {
+        List<GenericValue> shippingLocations = FastList.newInstance();
+        List<GenericValue> shippingCms = this.getOrderContactMechs("SHIPPING_LOCATION");
         if (shippingCms != null) {
-            Iterator i = shippingCms.iterator();
+            Iterator<GenericValue> i = shippingCms.iterator();
             while (i.hasNext()) {
-                GenericValue ocm = (GenericValue) i.next();
+                GenericValue ocm = i.next();
                 if (ocm != null) {
                     try {
                         GenericValue addr = ocm.getDelegator().findByPrimaryKey("PostalAddress",
@@ -490,13 +491,13 @@
         return null;
     }
 
-    public List getBillingLocations() {
-        List billingLocations = FastList.newInstance();
-        List billingCms = this.getOrderContactMechs("BILLING_LOCATION");
+    public List<GenericValue> getBillingLocations() {
+        List<GenericValue> billingLocations = FastList.newInstance();
+        List<GenericValue> billingCms = this.getOrderContactMechs("BILLING_LOCATION");
         if (billingCms != null) {
-            Iterator i = billingCms.iterator();
+            Iterator<GenericValue> i = billingCms.iterator();
             while (i.hasNext()) {
-                GenericValue ocm = (GenericValue) i.next();
+                GenericValue ocm = i.next();
                 if (ocm != null) {
                     try {
                         GenericValue addr = ocm.getDelegator().findByPrimaryKey("PostalAddress",
@@ -566,7 +567,7 @@
         return billingAddress;
     }
 
-    public List getOrderContactMechs(String purposeTypeId) {
+    public List<GenericValue> getOrderContactMechs(String purposeTypeId) {
         try {
             return orderHeader.getRelatedByAnd("OrderContactMech",
                     UtilMisc.toMap("contactMechPurposeTypeId", purposeTypeId));
@@ -578,9 +579,9 @@
 
     public Timestamp getEarliestShipByDate() {
         try {
-            List groups = orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipByDate"));
+            List<GenericValue> groups = orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipByDate"));
             if (groups.size() > 0) {
-                GenericValue group = (GenericValue) groups.get(0);
+                GenericValue group = groups.get(0);
                 return group.getTimestamp("shipByDate");
             }
         } catch (GenericEntityException e) {
@@ -591,9 +592,9 @@
 
     public Timestamp getLatestShipAfterDate() {
         try {
-            List groups = orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipAfterDate DESC"));
+            List<GenericValue> groups = orderHeader.getRelated("OrderItemShipGroup", UtilMisc.toList("shipAfterDate DESC"));
             if (groups.size() > 0) {
-                GenericValue group = (GenericValue) groups.get(0);
+                GenericValue group = groups.get(0);
                 return group.getTimestamp("shipAfterDate");
             }
         } catch (GenericEntityException e) {
@@ -617,17 +618,17 @@
     }
 
     public String getStatusString(Locale locale) {
-        List orderStatusList = this.getOrderHeaderStatuses();
+        List<GenericValue> orderStatusList = this.getOrderHeaderStatuses();
 
         if (orderStatusList == null || orderStatusList.size() == 0) return "";
 
-        Iterator orderStatusIter = orderStatusList.iterator();
+        Iterator<GenericValue> orderStatusIter = orderStatusList.iterator();
         StringBuilder orderStatusString = new StringBuilder(50);
 
         try {
             boolean isCurrent = true;
             while (orderStatusIter.hasNext()) {
-                GenericValue orderStatus = (GenericValue) orderStatusIter.next();
+                GenericValue orderStatus = orderStatusIter.next();
                 GenericValue statusItem = orderStatus.getRelatedOneCache("StatusItem");
 
                 if (statusItem != null) {
@@ -674,7 +675,7 @@
         if (getBillingAccount() == null) {
             return BigDecimal.ZERO;
         } else {
-            List paymentPreferences = getPaymentPreferences();
+            List<GenericValue> paymentPreferences = getPaymentPreferences();
             GenericValue billingAccountPaymentPreference = EntityUtil.getFirst(EntityUtil.filterByAnd(paymentPreferences, UtilMisc.toMap("paymentMethodTypeId", "EXT_BILLACT")));
             if ((billingAccountPaymentPreference != null) && (billingAccountPaymentPreference.getBigDecimal("maxAmount") != null)) {
                 return billingAccountPaymentPreference.getBigDecimal("maxAmount");
@@ -779,38 +780,38 @@
         return OrderReadHelper.calcOrderAdjustments(getAdjustments(), getOrderItemsSubTotal(), false, true, false);
     }
 
-    public Set getItemFeatureSet(GenericValue item) {
-        Set featureSet = new LinkedHashSet();
-        List featureAppls = null;
+    public Set<String> getItemFeatureSet(GenericValue item) {
+        Set<String> featureSet = new LinkedHashSet<String>();
+        List<GenericValue> featureAppls = null;
         if (item.get("productId") != null) {
             try {
                 featureAppls = item.getDelegator().findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", item.getString("productId")));
-                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 ProductFeatureAppl for item : " + item, module);
             }
             if (featureAppls != null) {
-                Iterator fai = featureAppls.iterator();
+                Iterator<GenericValue> fai = featureAppls.iterator();
                 while (fai.hasNext()) {
-                    GenericValue appl = (GenericValue) fai.next();
+                    GenericValue appl = fai.next();
                     featureSet.add(appl.getString("productFeatureId"));
                 }
             }
         }
 
         // get the ADDITIONAL_FEATURE adjustments
-        List additionalFeatures = null;
+        List<GenericValue> additionalFeatures = null;
         try {
             additionalFeatures = item.getRelatedByAnd("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "ADDITIONAL_FEATURE"));
         } catch (GenericEntityException e) {
             Debug.logError(e, "Unable to get OrderAdjustment from item : " + item, module);
         }
         if (additionalFeatures != null) {
-            Iterator afi = additionalFeatures.iterator();
+            Iterator<GenericValue> afi = additionalFeatures.iterator();
             while (afi.hasNext()) {
-                GenericValue adj = (GenericValue) afi.next();
+                GenericValue adj = afi.next();
                 String featureId = adj.getString("productFeatureId");
                 if (featureId != null) {
                     featureSet.add(featureId);
@@ -821,28 +822,28 @@
         return featureSet;
     }
 
-    public Map getFeatureIdQtyMap(String shipGroupSeqId) {
-        Map featureMap = FastMap.newInstance();
-        List validItems = getValidOrderItems(shipGroupSeqId);
+    public Map<String, BigDecimal> getFeatureIdQtyMap(String shipGroupSeqId) {
+        Map<String, BigDecimal> featureMap = FastMap.newInstance();
+        List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
-                List featureAppls = null;
+                GenericValue item = i.next();
+                List<GenericValue> featureAppls = null;
                 if (item.get("productId") != null) {
                     try {
                         featureAppls = item.getDelegator().findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", item.getString("productId")));
-                        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 ProductFeatureAppl for item : " + item, 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;
                             }
@@ -853,19 +854,19 @@
                 }
 
                 // get the ADDITIONAL_FEATURE adjustments
-                List additionalFeatures = null;
+                List<GenericValue> additionalFeatures = null;
                 try {
                     additionalFeatures = item.getRelatedByAnd("OrderAdjustment", UtilMisc.toMap("orderAdjustmentTypeId", "ADDITIONAL_FEATURE"));
                 } catch (GenericEntityException e) {
                     Debug.logError(e, "Unable to get OrderAdjustment from item : " + item, module);
                 }
                 if (additionalFeatures != null) {
-                    Iterator afi = additionalFeatures.iterator();
+                    Iterator<GenericValue> afi = additionalFeatures.iterator();
                     while (afi.hasNext()) {
-                        GenericValue adj = (GenericValue) afi.next();
+                        GenericValue adj = afi.next();
                         String featureId = adj.getString("productFeatureId");
                         if (featureId != null) {
-                            BigDecimal lastQuantity = (BigDecimal) featureMap.get(featureId);
+                            BigDecimal lastQuantity = featureMap.get(featureId);
                             if (lastQuantity == null) {
                                 lastQuantity = BigDecimal.ZERO;
                             }
@@ -882,11 +883,11 @@
 
     public boolean shippingApplies() {
         boolean shippingApplies = false;
-        List validItems = this.getValidOrderItems();
+        List<GenericValue> validItems = this.getValidOrderItems();
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 GenericValue product = null;
                 try {
                     product = item.getRelatedOne("Product");
@@ -906,11 +907,11 @@
 
     public boolean taxApplies() {
         boolean taxApplies = false;
-        List validItems = this.getValidOrderItems();
+        List<GenericValue> validItems = this.getValidOrderItems();
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 GenericValue product = null;
                 try {
                     product = item.getRelatedOne("Product");
@@ -930,11 +931,11 @@
 
     public BigDecimal getShippableTotal(String shipGroupSeqId) {
         BigDecimal shippableTotal = ZERO;
-        List validItems = getValidOrderItems(shipGroupSeqId);
+        List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 GenericValue product = null;
                 try {
                     product = item.getRelatedOne("Product");
@@ -954,11 +955,11 @@
 
     public BigDecimal getShippableQuantity() {
         BigDecimal shippableQuantity = ZERO;
-        List shipGroups = getOrderItemShipGroups();
+        List<GenericValue> shipGroups = getOrderItemShipGroups();
         if (UtilValidate.isNotEmpty(shipGroups)) {
-            Iterator shipGroupsIt = shipGroups.iterator();
+            Iterator<GenericValue> shipGroupsIt = shipGroups.iterator();
             while (shipGroupsIt.hasNext()) {
-                GenericValue shipGroup = (GenericValue)shipGroupsIt.next();
+                GenericValue shipGroup = shipGroupsIt.next();
                 shippableQuantity = shippableQuantity.add(getShippableQuantity(shipGroup.getString("shipGroupSeqId")));
             }
         }
@@ -967,11 +968,11 @@
 
     public BigDecimal getShippableQuantity(String shipGroupSeqId) {
         BigDecimal shippableQuantity = ZERO;
-        List validItems = getValidOrderItems(shipGroupSeqId);
+        List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 GenericValue product = null;
                 try {
                     product = item.getRelatedOne("Product");
@@ -991,11 +992,11 @@
 
     public BigDecimal getShippableWeight(String shipGroupSeqId) {
         BigDecimal shippableWeight = ZERO;
-        List validItems = getValidOrderItems(shipGroupSeqId);
+        List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 shippableWeight = shippableWeight.add(this.getItemWeight(item).multiply(getOrderItemQuantity(item))).setScale(scale, rounding);
             }
         }
@@ -1042,14 +1043,14 @@
         return itemWeight;
     }
 
-    public List getShippableSizes() {
-        List shippableSizes = FastList.newInstance();
+    public List<BigDecimal> getShippableSizes() {
+        List<BigDecimal> shippableSizes = FastList.newInstance();
 
-        List validItems = getValidOrderItems();
+        List<GenericValue> validItems = getValidOrderItems();
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 shippableSizes.add(this.getItemSize(item));
             }
         }
@@ -1062,8 +1063,8 @@
      */
     public BigDecimal getOrderPaymentPreferenceTotalByType(String paymentMethodTypeId) {
         BigDecimal total = ZERO;
-        for (Iterator iter = getPaymentPreferences().iterator(); iter.hasNext();) {
-            GenericValue preference = (GenericValue) iter.next();
+        for (Iterator<GenericValue> iter = getPaymentPreferences().iterator(); iter.hasNext();) {
+            GenericValue preference = iter.next();
             if (preference.get("maxAmount") == null) continue;
             if (paymentMethodTypeId == null || paymentMethodTypeId.equals(preference.get("paymentMethodTypeId"))) {
                 total = total.add(preference.getBigDecimal("maxAmount")).setScale(scale, rounding);
@@ -1094,25 +1095,25 @@
 
         try {
             // get a set of invoice IDs that belong to the order
-            List orderItemBillings = orderHeader.getRelatedCache("OrderItemBilling");
-            Set invoiceIds = new HashSet();
-            for (Iterator iter = orderItemBillings.iterator(); iter.hasNext();) {
-                GenericValue orderItemBilling = (GenericValue) iter.next();
-                invoiceIds.add(orderItemBilling.get("invoiceId"));
+            List<GenericValue> orderItemBillings = orderHeader.getRelatedCache("OrderItemBilling");
+            Set<String> invoiceIds = new HashSet<String>();
+            for (Iterator<GenericValue> iter = orderItemBillings.iterator(); iter.hasNext();) {
+                GenericValue orderItemBilling = iter.next();
+                invoiceIds.add(orderItemBilling.getString("invoiceId"));
             }
 
             // get the payments of the desired type for these invoices TODO: in models where invoices can have many orders, this needs to be refined
-            List conditions = UtilMisc.toList(
+            List<EntityExpr> conditions = UtilMisc.toList(
                     EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "PMNT_RECEIVED"),
                     EntityCondition.makeCondition("invoiceId", EntityOperator.IN, invoiceIds));
             if (paymentMethodTypeId != null) {
                 conditions.add(EntityCondition.makeCondition("paymentMethodTypeId", EntityOperator.EQUALS, paymentMethodTypeId));
             }
-            EntityConditionList ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND);
-            List payments = orderHeader.getDelegator().findList("PaymentAndApplication", ecl, null, null, null, true);
+            EntityConditionList<EntityExpr> ecl = EntityCondition.makeCondition(conditions, EntityOperator.AND);
+            List<GenericValue> payments = orderHeader.getDelegator().findList("PaymentAndApplication", ecl, null, null, null, true);
 
-            for (Iterator iter = payments.iterator(); iter.hasNext();) {
-                GenericValue payment = (GenericValue) iter.next();
+            for (Iterator<GenericValue> iter = payments.iterator(); iter.hasNext();) {
+                GenericValue payment = iter.next();
                 if (payment.get("amountApplied") == null) continue;
                 total = total.add(payment.getBigDecimal("amountApplied")).setScale(scale, rounding);
             }
@@ -1190,7 +1191,7 @@
                     // get the virtual product and check its weight
                     GenericValue virtual = null;
                     try {
-                        List virtuals = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", product.getString("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"));
+                        List<GenericValue> virtuals = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", product.getString("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"));
                         virtuals = EntityUtil.filterByDate(virtuals);
                         virtual = EntityUtil.getFirst(virtuals);
                     } catch (GenericEntityException e) {
@@ -1215,14 +1216,14 @@
         return piecesIncluded;
     }
 
-   public List getShippableItemInfo(String shipGroupSeqId) {
-        List shippableInfo = FastList.newInstance();
+   public List<Map<String, Object>> getShippableItemInfo(String shipGroupSeqId) {
+        List<Map<String, Object>> shippableInfo = FastList.newInstance();
 
-        List validItems = getValidOrderItems(shipGroupSeqId);
+        List<GenericValue> validItems = getValidOrderItems(shipGroupSeqId);
         if (validItems != null) {
-            Iterator i = validItems.iterator();
+            Iterator<GenericValue> i = validItems.iterator();
             while (i.hasNext()) {
-                GenericValue item = (GenericValue) i.next();
+                GenericValue item = i.next();
                 shippableInfo.add(this.getItemInfoMap(item));
             }
         }
@@ -1230,8 +1231,8 @@
         return shippableInfo;
     }
 
-    public Map getItemInfoMap(GenericValue item) {
-        Map itemInfo = FastMap.newInstance();
+    public Map<String, Object> getItemInfoMap(GenericValue item) {
+        Map<String, Object> itemInfo = FastMap.newInstance();
         itemInfo.put("productId", item.getString("productId"));
         itemInfo.put("quantity", getOrderItemQuantity(item));
         itemInfo.put("weight", this.getItemWeight(item));
@@ -1244,9 +1245,9 @@
     public String getOrderEmailString() {
         Delegator delegator = orderHeader.getDelegator();
         // get the email addresses from the order contact mech(s)
-        List orderContactMechs = null;
+        List<GenericValue> orderContactMechs = null;
         try {
-            Map ocFields = UtilMisc.toMap("orderId", orderHeader.get("orderId"), "contactMechPurposeTypeId", "ORDER_EMAIL");
+            Map<String, Object> ocFields = UtilMisc.toMap("orderId", orderHeader.get("orderId"), "contactMechPurposeTypeId", "ORDER_EMAIL");
             orderContactMechs = delegator.findByAnd("OrderContactMech", ocFields);
         } catch (GenericEntityException e) {
             Debug.logWarning(e, "Problems getting order contact mechs", module);
@@ -1254,10 +1255,10 @@
 
         StringBuilder emails = new StringBuilder();
         if (orderContactMechs != null) {
-            Iterator oci = orderContactMechs.iterator();
+            Iterator<GenericValue> oci = orderContactMechs.iterator();
             while (oci.hasNext()) {
                 try {
-                    GenericValue orderContactMech = (GenericValue) oci.next();
+                    GenericValue orderContactMech = oci.next();
                     GenericValue contactMech = orderContactMech.getRelatedOne("ContactMech");
                     emails.append(emails.length() > 0 ? "," : "").append(contactMech.getString("infoString"));
                 } catch (GenericEntityException e) {
@@ -1281,28 +1282,27 @@
      * amounts received and refunded as payments for the settled ones.
      */
     public BigDecimal getOrderOpenAmount() throws GenericEntityException {
-        Delegator delegator = orderHeader.getDelegator();
         BigDecimal total = getOrderGrandTotal();
         BigDecimal openAmount = BigDecimal.ZERO;
-        List prefs = getPaymentPreferences();
+        List<GenericValue> prefs = getPaymentPreferences();
 
         // add up the covered amount, but skip preferences which are declined or cancelled
-        for (Iterator iter = prefs.iterator(); iter.hasNext();) {
-            GenericValue pref = (GenericValue) iter.next();
+        for (Iterator<GenericValue> iter = prefs.iterator(); iter.hasNext();) {
+            GenericValue pref = iter.next();
             if ("PAYMENT_CANCELLED".equals(pref.get("statusId")) || "PAYMENT_DECLINED".equals(pref.get("statusId"))) {
                 continue;
             } else if ("PAYMENT_SETTLED".equals(pref.get("statusId"))) {
-                List responses = pref.getRelatedByAnd("PaymentGatewayResponse", UtilMisc.toMap("transCodeEnumId", "PGT_CAPTURE"));
-                for (Iterator respIter = responses.iterator(); respIter.hasNext();) {
-                    GenericValue response = (GenericValue) respIter.next();
+                List<GenericValue> responses = pref.getRelatedByAnd("PaymentGatewayResponse", UtilMisc.toMap("transCodeEnumId", "PGT_CAPTURE"));
+                for (Iterator<GenericValue> respIter = responses.iterator(); respIter.hasNext();) {
+                    GenericValue response = respIter.next();
                     BigDecimal amount = response.getBigDecimal("amount");
                     if (amount != null) {
                         openAmount = openAmount.add(amount);
                     }
                 }
                 responses = pref.getRelatedByAnd("PaymentGatewayResponse", UtilMisc.toMap("transCodeEnumId", "PGT_REFUND"));
-                for (Iterator respIter = responses.iterator(); respIter.hasNext();) {
-                    GenericValue response = (GenericValue) respIter.next();
+                for (Iterator<GenericValue> respIter = responses.iterator(); respIter.hasNext();) {
+                    GenericValue response = respIter.next();
                     BigDecimal amount = response.getBigDecimal("amount");
                     if (amount != null) {
                         openAmount = openAmount.subtract(amount);
@@ -1321,19 +1321,19 @@
         return openAmount.compareTo(BigDecimal.ZERO) > 0 ? openAmount : BigDecimal.ZERO;
     }
 
-    public List getOrderHeaderAdjustments() {
+    public List<GenericValue> getOrderHeaderAdjustments() {
         return getOrderHeaderAdjustments(getAdjustments(), null);
     }
 
-    public List getOrderHeaderAdjustments(String shipGroupSeqId) {
+    public List<GenericValue> getOrderHeaderAdjustments(String shipGroupSeqId) {
         return getOrderHeaderAdjustments(getAdjustments(), shipGroupSeqId);
     }
 
-    public List getOrderHeaderAdjustmentsToShow() {
+    public List<GenericValue> getOrderHeaderAdjustmentsToShow() {
         return filterOrderAdjustments(getOrderHeaderAdjustments(), true, false, false, false, false);
     }
 
-    public List getOrderHeaderStatuses() {
+    public List<GenericValue> getOrderHeaderStatuses() {
         return getOrderHeaderStatuses(getOrderStatuses());
     }
 
@@ -1347,7 +1347,7 @@
 
     public int hasSurvey() {
         Delegator delegator = orderHeader.getDelegator();
-        List surveys = null;
+        List<GenericValue> surveys = null;
         try {
             surveys = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("orderId", orderHeader.getString("orderId")));
         } catch (GenericEntityException e) {
@@ -1376,7 +1376,7 @@
         return orderItems;
     }
 
-    public List getOrderItemAndShipGroupAssoc() {
+    public List<GenericValue> getOrderItemAndShipGroupAssoc() {
         if (orderItemAndShipGrp == null) {
             try {
                 orderItemAndShipGrp = orderHeader.getDelegator().findByAnd("OrderItemAndShipGroupAssoc",
@@ -1388,13 +1388,13 @@
         return orderItemAndShipGrp;
     }
 
-    public List getOrderItemAndShipGroupAssoc(String shipGroupSeqId) {
-        List exprs = UtilMisc.toList(EntityCondition.makeCondition("shipGroupSeqId", EntityOperator.EQUALS, shipGroupSeqId));
+    public List<GenericValue> getOrderItemAndShipGroupAssoc(String shipGroupSeqId) {
+        List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("shipGroupSeqId", EntityOperator.EQUALS, shipGroupSeqId));
         return EntityUtil.filterByAnd(getOrderItemAndShipGroupAssoc(), exprs);
     }
 
     public List<GenericValue> getValidOrderItems() {
-        List exprs = UtilMisc.toList(
+        List<EntityExpr> exprs = UtilMisc.toList(
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"),
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED"));
         return EntityUtil.filterByAnd(getOrderItems(), exprs);
@@ -1413,7 +1413,7 @@
         }
         return false;
     }*/
-    Delegator delegator = orderHeader.getDelegator();
+        Delegator delegator = orderHeader.getDelegator();
         GenericValue orderDeliverySchedule = null;
         try {
             orderDeliverySchedule = delegator.findByPrimaryKey("OrderDeliverySchedule", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", "_NA_"));
@@ -1430,20 +1430,20 @@
     }
 
     public boolean getRejectedOrderItems() {
-        List items = getOrderItems();
-        Iterator i = items.iterator();
+        List<GenericValue> items = getOrderItems();
+        Iterator<GenericValue> i = items.iterator();
         while (i.hasNext()) {
-            GenericValue item = (GenericValue) i.next();
-            List receipts = null;
+            GenericValue item = i.next();
+            List<GenericValue> receipts = null;
             try {
-            receipts = item.getRelated("ShipmentReceipt");
+                receipts = item.getRelated("ShipmentReceipt");
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
             if (UtilValidate.isNotEmpty(receipts)) {
-                Iterator recIter = receipts.iterator();
+                Iterator<GenericValue> recIter = receipts.iterator();
                 while (recIter.hasNext()) {
-                    GenericValue rec = (GenericValue) recIter.next();
+                    GenericValue rec = recIter.next();
                     BigDecimal rejected = rec.getBigDecimal("quantityRejected");
                     if (rejected != null && rejected.compareTo(BigDecimal.ZERO) > 0) {
                         return true;
@@ -1468,24 +1468,24 @@
         }
         return false;
     }*/
-        List items = getOrderItems();
-        Iterator i = items.iterator();
+        List<GenericValue> items = getOrderItems();
+        Iterator<GenericValue> i = items.iterator();
         while (i.hasNext()) {
-            GenericValue item = (GenericValue) i.next();
-            List receipts = null;
+            GenericValue item = i.next();
+            List<GenericValue> receipts = null;
             try {
-            receipts = item.getRelated("ShipmentReceipt");
+                receipts = item.getRelated("ShipmentReceipt");
             } catch (GenericEntityException e) {
                 Debug.logWarning(e, module);
             }
             if (UtilValidate.isNotEmpty(receipts)) {
-                Iterator recIter = receipts.iterator();
+                Iterator<GenericValue> recIter = receipts.iterator();
                 while (recIter.hasNext()) {
-                    GenericValue rec = (GenericValue) recIter.next();
+                    GenericValue rec = recIter.next();
                     BigDecimal acceptedQuantity = rec.getBigDecimal("quantityAccepted");
                     BigDecimal orderedQuantity = (BigDecimal) item.get("quantity");
                     if (acceptedQuantity.intValue() != orderedQuantity.intValue() && acceptedQuantity.intValue()  > 0) {
-                    return true;
+                        return true;
                     }
                 }
             }
@@ -1493,9 +1493,9 @@
         return false;
     }
 
-    public List getValidOrderItems(String shipGroupSeqId) {
+    public List<GenericValue> getValidOrderItems(String shipGroupSeqId) {
         if (shipGroupSeqId == null) return getValidOrderItems();
-        List exprs = UtilMisc.toList(
+        List<EntityExpr> exprs = UtilMisc.toList(
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED"),
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED"),
                 EntityCondition.makeCondition("shipGroupSeqId", EntityOperator.EQUALS, shipGroupSeqId));
@@ -1503,20 +1503,20 @@
     }
 
     public GenericValue getOrderItem(String orderItemSeqId) {
-        List exprs = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, orderItemSeqId));
+        List<EntityExpr> exprs = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, orderItemSeqId));
         return EntityUtil.getFirst(EntityUtil.filterByAnd(getOrderItems(), exprs));
     }
 
-    public List getValidDigitalItems() {
-        List digitalItems = new ArrayList();
+    public List<GenericValue> getValidDigitalItems() {
+        List<GenericValue> digitalItems = FastList.newInstance();
         // only approved or complete items apply
-        List exprs = UtilMisc.toList(
+        List<EntityExpr> exprs = UtilMisc.toList(
                 EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_APPROVED"),
                 EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, "ITEM_COMPLETED"));
-        List items = EntityUtil.filterByOr(getOrderItems(), exprs);
-        Iterator i = items.iterator();
+        List<GenericValue> items = EntityUtil.filterByOr(getOrderItems(), exprs);
+        Iterator<GenericValue> i = items.iterator();
         while (i.hasNext()) {
-            GenericValue item = (GenericValue) i.next();
+            GenericValue item = i.next();
             if (item.get("productId") != null) {
                 GenericValue product = null;
                 try {
@@ -1537,7 +1537,7 @@
 
                         if (isDigital != null && "Y".equalsIgnoreCase(isDigital)) {
                             // make sure we have an OrderItemBilling record
-                            List orderItemBillings = null;
+                            List<GenericValue> orderItemBillings = null;
                             try {
                                 orderItemBillings = item.getRelated("OrderItemBilling");
                             } catch (GenericEntityException e) {
@@ -1546,13 +1546,13 @@
 
                             if (UtilValidate.isNotEmpty(orderItemBillings)) {
                                 // get the ProductContent records
-                                List productContents = null;
+                                List<GenericValue> productContents = null;
                                 try {
                                     productContents = product.getRelated("ProductContent");
                                 } catch (GenericEntityException e) {
                                     Debug.logError("Unable to get ProductContent from Product", module);
                                 }
-                                List cExprs = UtilMisc.toList(
+                                List<EntityExpr> cExprs = UtilMisc.toList(
                                         EntityCondition.makeCondition("productContentTypeId", EntityOperator.EQUALS, "DIGITAL_DOWNLOAD"),
                                         EntityCondition.makeCondition("productContentTypeId", EntityOperator.EQUALS, "FULFILLMENT_EMAIL"),
                                         EntityCondition.makeCondition("productContentTypeId", EntityOperator.EQUALS, "FULFILLMENT_EXTERNAL"));
@@ -1562,9 +1562,9 @@
 
                                 if (UtilValidate.isNotEmpty(productContents)) {
                                     // make sure we are still within the allowed timeframe and use limits
-                                    Iterator pci = productContents.iterator();
+                                    Iterator<GenericValue> pci = productContents.iterator();
                                     while (pci.hasNext()) {
-                                        GenericValue productContent = (GenericValue) pci.next();
+                                        GenericValue productContent = pci.next();
                                         Timestamp fromDate = productContent.getTimestamp("purchaseFromDate");
                                         Timestamp thruDate = productContent.getTimestamp("purchaseThruDate");
                                         if (fromDate == null || item.getTimestamp("orderDate").after(fromDate)) {
@@ -1584,7 +1584,7 @@
         return digitalItems;
     }
 
-    public List getOrderItemAdjustments(GenericValue orderItem) {
+    public List<GenericValue> getOrderItemAdjustments(GenericValue orderItem) {
         return getOrderItemAdjustmentList(orderItem, getAdjustments());
     }
 
@@ -1595,7 +1595,7 @@
         GenericValue workOrderItemFulFillment = null;
         GenericValue workEffort = null;
         try {
-            List workOrderItemFulFillments = delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
+            List<GenericValue> workOrderItemFulFillments = delegator.findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
             if (!UtilValidate.isEmpty(workOrderItemFulFillments)) {
                 workOrderItemFulFillment = EntityUtil.getFirst(workOrderItemFulFillments);
                 workEffort = workOrderItemFulFillment.getRelatedOne("WorkEffort");
@@ -1624,7 +1624,7 @@
         }
     }
 
-    public List getOrderItemPriceInfos(GenericValue orderItem) {
+    public List<GenericValue> getOrderItemPriceInfos(GenericValue orderItem) {
         if (orderItem == null) return null;
         if (this.orderItemPriceInfos == null) {
             Delegator delegator = orderHeader.getDelegator();
@@ -1651,7 +1651,7 @@
         return null;
     }
 
-    public List getOrderItemShipGrpInvResList(GenericValue orderItem) {
+    public List<GenericValue> getOrderItemShipGrpInvResList(GenericValue orderItem) {
         if (orderItem == null) return null;
         if (this.orderItemShipGrpInvResList == null) {
             Delegator delegator = orderItem.getDelegator();
@@ -1664,11 +1664,11 @@
         return EntityUtil.filterByAnd(orderItemShipGrpInvResList, UtilMisc.toMap("orderItemSeqId", orderItem.getString("orderItemSeqId")));
     }
 
-    public List getOrderItemIssuances(GenericValue orderItem) {
+    public List<GenericValue> getOrderItemIssuances(GenericValue orderItem) {
         return this.getOrderItemIssuances(orderItem, null);
     }
 
-    public List getOrderItemIssuances(GenericValue orderItem, String shipmentId) {
+    public List<GenericValue> getOrderItemIssuances(GenericValue orderItem, String shipmentId) {
         if (orderItem == null) return null;
         if (this.orderItemIssuances == null) {
             Delegator delegator = orderItem.getDelegator();
@@ -1681,7 +1681,7 @@
         }
 
         // filter the issuances
-        Map filter = UtilMisc.toMap("orderItemSeqId", orderItem.get("orderItemSeqId"));
+        Map<String, Object> filter = UtilMisc.toMap("orderItemSeqId", orderItem.get("orderItemSeqId"));
         if (shipmentId != null) {
             filter.put("shipmentId", shipmentId);
         }
@@ -1689,15 +1689,15 @@
     }
 
     /** Get a set of productIds in the order. */
-    public Collection getOrderProductIds() {
-        Set productIds = new HashSet();
-        for (Iterator iter = getOrderItems().iterator(); iter.hasNext();) {
-            productIds.add(((GenericValue) iter.next()).getString("productId"));
+    public Collection<String> getOrderProductIds() {
+        Set<String> productIds = FastSet.newInstance();
+        for (Iterator<GenericValue> iter = getOrderItems().iterator(); iter.hasNext();) {
+            productIds.add(iter.next().getString("productId"));
         }
         return productIds;
     }
 
-    public List getOrderReturnItems() {
+    public List<GenericValue> getOrderReturnItems() {
         Delegator delegator = orderHeader.getDelegator();
         if (this.orderReturnItems == null) {
             try {
@@ -1717,27 +1717,27 @@
     *
     * @return  Map of returned quantities as BigDecimals keyed to the orderItemSeqId
     */
-   public Map getOrderItemReturnedQuantities() {
-       List returnItems = getOrderReturnItems();
+   public Map<String, BigDecimal> getOrderItemReturnedQuantities() {
+       List<GenericValue> returnItems = getOrderReturnItems();
 
        // since we don't have a handy grouped view entity, we'll have to group the return items by hand
-       Map returnMap = FastMap.newInstance();
-       for (Iterator iter = this.getValidOrderItems().iterator(); iter.hasNext();) {
-           GenericValue orderItem = (GenericValue) iter.next();
-           List group = EntityUtil.filterByAnd(returnItems,
+       Map<String, BigDecimal> returnMap = FastMap.newInstance();
+       for (Iterator<GenericValue> iter = this.getValidOrderItems().iterator(); iter.hasNext();) {
+           GenericValue orderItem = iter.next();
+           List<GenericValue> group = EntityUtil.filterByAnd(returnItems,
                    UtilMisc.toMap("orderId", orderItem.get("orderId"), "orderItemSeqId", orderItem.get("orderItemSeqId")));
 
            // add up the returned quantities for this group TODO: received quantity should be used eventually
            BigDecimal returned = BigDecimal.ZERO;
-           for (Iterator groupiter = group.iterator(); groupiter.hasNext();) {
-               GenericValue returnItem = (GenericValue) groupiter.next();
+           for (Iterator<GenericValue> groupiter = group.iterator(); groupiter.hasNext();) {
+               GenericValue returnItem = groupiter.next();
                if (returnItem.getBigDecimal("returnQuantity") != null) {
                    returned = returned.add(returnItem.getBigDecimal("returnQuantity"));
                }
            }
 
            // the quantity returned per order item
-           returnMap.put(orderItem.get("orderItemSeqId"), returned);
+           returnMap.put(orderItem.getString("orderItemSeqId"), returned);
        }
        return returnMap;
    }
@@ -1747,11 +1747,11 @@
     * only the ReturnItems that are directly correlated to an OrderItem.
     */
     public BigDecimal getOrderReturnedQuantity() {
-        List returnedItemsBase = getOrderReturnItems();
-        List returnedItems = new ArrayList(returnedItemsBase.size());
+        List<GenericValue> returnedItemsBase = getOrderReturnItems();
+        List<GenericValue> returnedItems = new ArrayList<GenericValue>(returnedItemsBase.size());
 
         // filter just order items
-        List orderItemExprs = UtilMisc.toList(EntityCondition.makeCondition("returnItemTypeId", EntityOperator.EQUALS, "RET_PROD_ITEM"));
+        List<EntityExpr> orderItemExprs = UtilMisc.toList(EntityCondition.makeCondition("returnItemTypeId", EntityOperator.EQUALS, "RET_PROD_ITEM"));
         orderItemExprs.add(EntityCondition.makeCondition("returnItemTypeId", EntityOperator.EQUALS, "RET_FPROD_ITEM"));
         orderItemExprs.add(EntityCondition.makeCondition("returnItemTypeId", EntityOperator.EQUALS, "RET_DPROD_ITEM"));
         orderItemExprs.add(EntityCondition.makeCondition("returnItemTypeId", EntityOperator.EQUALS, "RET_FDPROD_ITEM"));
@@ -1766,13 +1766,11 @@
         returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_COMPLETED")));
 
         BigDecimal returnedQuantity = ZERO;
-        if (returnedItems != null) {
-            Iterator i = returnedItems.iterator();
-            while (i.hasNext()) {
-                GenericValue returnedItem = (GenericValue) i.next();
-                if (returnedItem.get("returnQuantity") != null) {
-                    returnedQuantity = returnedQuantity.add(returnedItem.getBigDecimal("returnQuantity")).setScale(scale, rounding);
-                }
+        Iterator<GenericValue> i = returnedItems.iterator();
+        while (i.hasNext()) {
+            GenericValue returnedItem = i.next();
+            if (returnedItem.get("returnQuantity") != null) {
+                returnedQuantity = returnedQuantity.add(returnedItem.getBigDecimal("returnQuantity")).setScale(scale, rounding);
             }
         }
         return returnedQuantity.setScale(scale, rounding);
@@ -1784,11 +1782,11 @@
      * = false to sum up over ACCEPTED,RECEIVED And COMPLETED returns.
      */
     public BigDecimal getOrderReturnedTotalByTypeBd(String returnTypeId, boolean includeAll) {
-        List returnedItemsBase = getOrderReturnItems();
+        List<GenericValue> returnedItemsBase = getOrderReturnItems();
         if (returnTypeId != null) {
             returnedItemsBase = EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("returnTypeId", returnTypeId));
         }
-        List returnedItems = new ArrayList(returnedItemsBase.size());
+        List<GenericValue> returnedItems = new ArrayList<GenericValue>(returnedItemsBase.size());
 
         // get only the RETURN_RECEIVED and RETURN_COMPLETED statusIds
         if (!includeAll) {
@@ -1801,25 +1799,25 @@
                     UtilMisc.toList(EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "RETURN_CANCELLED"))));
         }
         BigDecimal returnedAmount = ZERO;
-        Iterator i = returnedItems.iterator();
+        Iterator<GenericValue> i = returnedItems.iterator();
         String orderId = orderHeader.getString("orderId");
-        List returnHeaderList = new ArrayList();
+        List<String> returnHeaderList = FastList.newInstance();
         while (i.hasNext()) {
-            GenericValue returnedItem = (GenericValue) i.next();
+            GenericValue returnedItem = i.next();
             if ((returnedItem.get("returnPrice") != null) && (returnedItem.get("returnQuantity") != null)) {
                 returnedAmount = returnedAmount.add(returnedItem.getBigDecimal("returnPrice").multiply(returnedItem.getBigDecimal("returnQuantity")).setScale(scale, rounding));
             }
-            Map itemAdjustmentCondition = UtilMisc.toMap("returnId", returnedItem.get("returnId"), "returnItemSeqId", returnedItem.get("returnItemSeqId"));
+            Map<String, Object> itemAdjustmentCondition = UtilMisc.toMap("returnId", returnedItem.get("returnId"), "returnItemSeqId", returnedItem.get("returnItemSeqId"));
             returnedAmount = returnedAmount.add(getReturnAdjustmentTotal(orderHeader.getDelegator(), itemAdjustmentCondition));
             if (orderId.equals(returnedItem.getString("orderId")) && (!returnHeaderList.contains(returnedItem.getString("returnId")))) {
                 returnHeaderList.add(returnedItem.getString("returnId"));
             }
         }
         //get  returnedAmount from returnHeader adjustments whose orderId must equals to current orderHeader.orderId
-        Iterator returnHeaderIterator = returnHeaderList.iterator();
+        Iterator<String> returnHeaderIterator = returnHeaderList.iterator();
         while (returnHeaderIterator.hasNext()) {
-            String returnId = (String) returnHeaderIterator.next();
-            Map returnHeaderAdjFilter = UtilMisc.toMap("returnId", returnId, "returnItemSeqId", "_NA_");
+            String returnId = returnHeaderIterator.next();
+            Map<String, Object> returnHeaderAdjFilter = UtilMisc.toMap("returnId", returnId, "returnItemSeqId", "_NA_");
             returnedAmount =returnedAmount.add(getReturnAdjustmentTotal(orderHeader.getDelegator(), returnHeaderAdjFilter)).setScale(scale, rounding);
         }
         return returnedAmount.setScale(scale, rounding);
@@ -1850,21 +1848,21 @@
 
     public BigDecimal getOrderNonReturnedTaxAndShipping() {
         // first make a Map of orderItemSeqId key, returnQuantity value
-        List returnedItemsBase = getOrderReturnItems();
-        List returnedItems = new ArrayList(returnedItemsBase.size());
+        List<GenericValue> returnedItemsBase = getOrderReturnItems();
+        List<GenericValue> returnedItems = new ArrayList<GenericValue>(returnedItemsBase.size());
 
         // get only the RETURN_RECEIVED and RETURN_COMPLETED statusIds
         returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_RECEIVED")));
         returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_COMPLETED")));
 
-        Map itemReturnedQuantities = FastMap.newInstance();
-        Iterator i = returnedItems.iterator();
+        Map<String, BigDecimal> itemReturnedQuantities = FastMap.newInstance();
+        Iterator<GenericValue> i = returnedItems.iterator();
         while (i.hasNext()) {
-            GenericValue returnedItem = (GenericValue) i.next();
+            GenericValue returnedItem = i.next();
             String orderItemSeqId = returnedItem.getString("orderItemSeqId");
             BigDecimal returnedQuantity = returnedItem.getBigDecimal("returnQuantity");
             if (orderItemSeqId != null && returnedQuantity != null) {
-                BigDecimal existingQuantity =  (BigDecimal) itemReturnedQuantities.get(orderItemSeqId);
+                BigDecimal existingQuantity =  itemReturnedQuantities.get(orderItemSeqId);
                 if (existingQuantity == null) {
                     itemReturnedQuantities.put(orderItemSeqId, returnedQuantity);
                 } else {
@@ -1878,9 +1876,9 @@
         BigDecimal totalTaxNotReturned = ZERO;
         BigDecimal totalShippingNotReturned = ZERO;
 
-        Iterator orderItems = this.getValidOrderItems().iterator();
+        Iterator<GenericValue> orderItems = this.getValidOrderItems().iterator();
         while (orderItems.hasNext()) {
-            GenericValue orderItem = (GenericValue) orderItems.next();
+            GenericValue orderItem = orderItems.next();
 
             BigDecimal itemQuantityDbl = orderItem.getBigDecimal("quantity");
             if (itemQuantityDbl == null || itemQuantityDbl.compareTo(ZERO) == 0) {
@@ -1891,7 +1889,7 @@
             BigDecimal itemTaxes = this.getOrderItemTax(orderItem);
             BigDecimal itemShipping = this.getOrderItemShipping(orderItem);
 
-            BigDecimal quantityReturned = (BigDecimal) itemReturnedQuantities.get(orderItem.get("orderItemSeqId"));
+            BigDecimal quantityReturned = itemReturnedQuantities.get(orderItem.get("orderItemSeqId"));
             if (quantityReturned == null) {
                 quantityReturned = BigDecimal.ZERO;
             }
@@ -1928,11 +1926,11 @@
     /** Gets the total refunded to the order billing account by type.  Specify null to get total over all types. */
     public BigDecimal getBillingAccountReturnedTotalByTypeBd(String returnTypeId) {
         BigDecimal returnedAmount = ZERO;
-        List returnedItemsBase = getOrderReturnItems();
+        List<GenericValue> returnedItemsBase = getOrderReturnItems();
         if (returnTypeId != null) {
             returnedItemsBase = EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("returnTypeId", returnTypeId));
         }
-        List returnedItems = new ArrayList(returnedItemsBase.size());
+        List<GenericValue> returnedItems = new ArrayList<GenericValue>(returnedItemsBase.size());
 
         // get only the RETURN_RECEIVED and RETURN_COMPLETED statusIds
         returnedItems.addAll(EntityUtil.filterByAnd(returnedItemsBase, UtilMisc.toMap("statusId", "RETURN_RECEIVED")));
@@ -1940,8 +1938,8 @@
 
         // sum up the return items that have a return item response with a billing account defined
         try {
-            for (Iterator iter = returnedItems.iterator(); iter.hasNext();) {
-                GenericValue returnItem = (GenericValue) iter.next();
+            for (Iterator<GenericValue> iter = returnedItems.iterator(); iter.hasNext();) {
+                GenericValue returnItem = iter.next();
                 GenericValue returnItemResponse = returnItem.getRelatedOne("ReturnItemResponse");
                 if (returnItemResponse == null) continue;
                 if (returnItemResponse.get("billingAccountId") == null) continue;
@@ -1977,16 +1975,16 @@
 
     public BigDecimal getOrderBackorderQuantity() {
         BigDecimal backorder = ZERO;
-        List items = this.getValidOrderItems();
+        List<GenericValue> items = this.getValidOrderItems();
         if (items != null) {
-            Iterator ii = items.iterator();
+            Iterator<GenericValue> ii = items.iterator();
             while (ii.hasNext()) {
-                GenericValue item = (GenericValue) ii.next();
-                List reses = this.getOrderItemShipGrpInvResList(item);
+                GenericValue item = ii.next();
+                List<GenericValue> reses = this.getOrderItemShipGrpInvResList(item);
                 if (reses != null) {
-                    Iterator ri = reses.iterator();
+                    Iterator<GenericValue> ri = reses.iterator();
                     while (ri.hasNext()) {
-                        GenericValue res = (GenericValue) ri.next();
+                        GenericValue res = ri.next();
                         BigDecimal nav = res.getBigDecimal("quantityNotAvailable");
                         if (nav != null) {
                             backorder = backorder.add(nav).setScale(scale, rounding);
@@ -2000,13 +1998,13 @@
 
     public BigDecimal getItemPickedQuantityBd(GenericValue orderItem) {
         BigDecimal quantityPicked = ZERO;
-        EntityConditionList pickedConditions = EntityCondition.makeCondition(UtilMisc.toList(
+        EntityConditionList<EntityExpr> pickedConditions = EntityCondition.makeCondition(UtilMisc.toList(
                 EntityCondition.makeCondition("orderId", EntityOperator.EQUALS, orderItem.get("orderId")),
                 EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, orderItem.getString("orderItemSeqId")),
                 EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "PICKLIST_CANCELLED")),
                 EntityOperator.AND);
 
-        List picked = null;
+        List<GenericValue> picked = null;
         try {
             picked = orderHeader.getDelegator().findList("PicklistAndBinAndItem", pickedConditions, null, null, null, false);
         } catch (GenericEntityException e) {
@@ -2015,9 +2013,9 @@
         }
 
         if (picked != null) {
-            Iterator i = picked.iterator();
+            Iterator<GenericValue> i = picked.iterator();
             while (i.hasNext()) {
-                GenericValue pickedItem = (GenericValue) i.next();
+                GenericValue pickedItem = i.next();
                 BigDecimal issueQty = pickedItem.getBigDecimal("quantity");
                 if (issueQty != null) {
                     quantityPicked = quantityPicked.add(issueQty).setScale(scale, rounding);
@@ -2029,11 +2027,11 @@
 
     public BigDecimal getItemShippedQuantity(GenericValue orderItem) {
         BigDecimal quantityShipped = ZERO;
-        List issuance = getOrderItemIssuances(orderItem);
+        List<GenericValue> issuance = getOrderItemIssuances(orderItem);
         if (issuance != null) {
-            Iterator i = issuance.iterator();
+            Iterator<GenericValue> i = issuance.iterator();
             while (i.hasNext()) {
-                GenericValue issue = (GenericValue) i.next();
+                GenericValue issue = i.next();
                 BigDecimal issueQty = issue.getBigDecimal("quantity");
                 BigDecimal cancelQty = issue.getBigDecimal("cancelQuantity");
                 if (cancelQty == null) {
@@ -2051,11 +2049,11 @@
     public BigDecimal getItemReservedQuantity(GenericValue orderItem) {
         BigDecimal reserved = ZERO;
 
-        List reses = getOrderItemShipGrpInvResList(orderItem);
+        List<GenericValue> reses = getOrderItemShipGrpInvResList(orderItem);
         if (reses != null) {
-            Iterator i = reses.iterator();
+            Iterator<GenericValue> i = reses.iterator();
             while (i.hasNext()) {
-                GenericValue res = (GenericValue) i.next();
+                GenericValue res = i.next();
                 BigDecimal quantity = res.getBigDecimal("quantity");
                 if (quantity != null) {
                     reserved = reserved.add(quantity).setScale(scale, rounding);
@@ -2071,11 +2069,11 @@
         Timestamp shipDate = orderItem.getTimestamp("estimatedShipDate");
         Timestamp autoCancel = orderItem.getTimestamp("autoCancelDate");
 
-        List reses = getOrderItemShipGrpInvResList(orderItem);
+        List<GenericValue> reses = getOrderItemShipGrpInvResList(orderItem);
         if (reses != null) {
-            Iterator i = reses.iterator();
+            Iterator<GenericValue> i = reses.iterator();
             while (i.hasNext()) {
-                GenericValue res = (GenericValue) i.next();
+                GenericValue res = i.next();
                 Timestamp promised = res.getTimestamp("currentPromisedDate");
                 if (promised == null) {
                     promised = res.getTimestamp("promisedDatetime");
@@ -2104,11 +2102,11 @@
     }
 
     public BigDecimal getTotalOrderItemsQuantity() {
-        List orderItems = getValidOrderItems();
+        List<GenericValue> orderItems = getValidOrderItems();
         BigDecimal totalItems = ZERO;
 
         for (int i = 0; i < orderItems.size(); i++) {
-            GenericValue oi = (GenericValue) orderItems.get(i);
+            GenericValue oi = orderItems.get(i);
 
             totalItems = totalItems.add(getOrderItemQuantity(oi)).setScale(scale, rounding);
         }
@@ -2116,11 +2114,11 @@
     }
 
     public BigDecimal getTotalOrderItemsOrderedQuantity() {
-        List orderItems = getValidOrderItems();
+        List<GenericValue> orderItems = getValidOrderItems();
         BigDecimal totalItems = ZERO;
 
         for (int i = 0; i < orderItems.size(); i++) {
-            GenericValue oi = (GenericValue) orderItems.get(i);
+            GenericValue oi = orderItems.get(i);
 
             totalItems = totalItems.add(oi.getBigDecimal("quantity")).setScale(scale, rounding);
         }
@@ -2177,7 +2175,7 @@
         }
     }
 
-    public List getOrderItemStatuses(GenericValue orderItem) {
+    public List<GenericValue> getOrderItemStatuses(GenericValue orderItem) {
         return getOrderItemStatuses(orderItem, getOrderStatuses());
     }
 
@@ -2196,7 +2194,7 @@
     }
 
     /** Fetches the set of order items with the given EntityCondition. */
-    public List getOrderItemsByCondition(EntityCondition entityCondition) {
+    public List<GenericValue> getOrderItemsByCondition(EntityCondition entityCondition) {
         return EntityUtil.filterByCondition(getOrderItems(), entityCondition);
     }
 
@@ -2268,7 +2266,7 @@
         }
         Delegator delegator = orderHeader.getDelegator();
         GenericValue productStore = null;
-        if (orderHeader != null && orderHeader.get("productStoreId") != null) {
+        if (orderHeader.get("productStoreId") != null) {
             try {
                 productStore = delegator.findByPrimaryKeyCache("ProductStore", UtilMisc.toMap("productStoreId", orderHeader.getString("productStoreId")));
             } catch (GenericEntityException e) {
@@ -2280,9 +2278,8 @@
         return productStore;
     }
 
-    public static BigDecimal getOrderGrandTotal(List orderItems, List adjustments) {
-        Map orderTaxByTaxAuthGeoAndParty = getOrderTaxByTaxAuthGeoAndParty(adjustments);
-        List taxByTaxAuthGeoAndPartyList = (List) orderTaxByTaxAuthGeoAndParty.get("taxByTaxAuthGeoAndPartyList");
+    public static BigDecimal getOrderGrandTotal(List<GenericValue> orderItems, List<GenericValue> adjustments) {
+        Map<String, Object> orderTaxByTaxAuthGeoAndParty = getOrderTaxByTaxAuthGeoAndParty(adjustments);
         BigDecimal taxGrandTotal = (BigDecimal) orderTaxByTaxAuthGeoAndParty.get("taxGrandTotal");
         adjustments = EntityUtil.filterByAnd(adjustments, UtilMisc.toList(EntityCondition.makeCondition("orderAdjustmentTypeId", EntityOperator.NOT_EQUAL, "SALES_TAX")));
         BigDecimal total = getOrderItemsTotal(orderItems, adjustments);
@@ -2291,16 +2288,16 @@
         return total.add(adj).setScale(scale,rounding);
     }
 
-    public static List getOrderHeaderAdjustments(List adjustments, String shipGroupSeqId) {
-        List contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, null));
-        List contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, DataModelConstants.SEQ_ID_NA));
-        List contraints3 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, ""));
-        List contraints4 = FastList.newInstance();
+    public static List<GenericValue> getOrderHeaderAdjustments(List<GenericValue> adjustments, String shipGroupSeqId) {
+        List<EntityExpr> contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, null));
+        List<EntityExpr> contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, DataModelConstants.SEQ_ID_NA));
+        List<EntityExpr> contraints3 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, ""));
+        List<EntityExpr> contraints4 = FastList.newInstance();
         if (shipGroupSeqId != null) {
             contraints4.add(EntityCondition.makeCondition("shipGroupSeqId", EntityOperator.EQUALS, shipGroupSeqId));
         }
-        List toFilter = null;
-        List adj = FastList.newInstance();
+        List<GenericValue> toFilter = null;
+        List<GenericValue> adj = FastList.newInstance();
 
         if (shipGroupSeqId != null) {
             toFilter = EntityUtil.filterByAnd(adjustments, contraints4);
@@ -2314,28 +2311,28 @@
         return adj;
     }
 
-    public static List getOrderHeaderStatuses(List orderStatuses) {
-        List contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, null));
+    public static List<GenericValue> getOrderHeaderStatuses(List<GenericValue> orderStatuses) {
+        List<EntityExpr> contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, null));
         contraints1.add(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, DataModelConstants.SEQ_ID_NA));
         contraints1.add(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, ""));
 
-        List contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, null));
+        List<EntityExpr> contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, null));
         contraints2.add(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, DataModelConstants.SEQ_ID_NA));
         contraints2.add(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, ""));
 
-        List newOrderStatuses = FastList.newInstance();
+        List<GenericValue> newOrderStatuses = FastList.newInstance();
         newOrderStatuses.addAll(EntityUtil.filterByOr(orderStatuses, contraints1));
         return EntityUtil.orderBy(EntityUtil.filterByOr(newOrderStatuses, contraints2), UtilMisc.toList("-statusDatetime"));
     }
 
-    public static BigDecimal getOrderAdjustmentsTotal(List orderItems, List adjustments) {
+    public static BigDecimal getOrderAdjustmentsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments) {
         return calcOrderAdjustments(getOrderHeaderAdjustments(adjustments, null), getOrderItemsSubTotal(orderItems, adjustments), true, true, true);
     }
 
-    public static List getOrderSurveyResponses(GenericValue orderHeader) {
+    public static List<GenericValue> getOrderSurveyResponses(GenericValue orderHeader) {
         Delegator delegator = orderHeader.getDelegator();
         String orderId = orderHeader.getString("orderId");
-         List responses = null;
+        List<GenericValue> responses = null;
         try {
             responses = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", "_NA_"));
         } catch (GenericEntityException e) {
@@ -2348,11 +2345,11 @@
         return responses;
     }
 
-    public static List getOrderItemSurveyResponse(GenericValue orderItem) {
+    public static List<GenericValue> getOrderItemSurveyResponse(GenericValue orderItem) {
         Delegator delegator = orderItem.getDelegator();
         String orderItemSeqId = orderItem.getString("orderItemSeqId");
         String orderId = orderItem.getString("orderId");
-        List responses = null;
+        List<GenericValue> responses = null;
         try {
             responses = delegator.findByAnd("SurveyResponse", UtilMisc.toMap("orderId", orderId, "orderItemSeqId", orderItemSeqId));
         } catch (GenericEntityException e) {
@@ -2367,15 +2364,15 @@
 
     // ================= Order Adjustments =================
 
-    public static BigDecimal calcOrderAdjustments(List orderHeaderAdjustments, BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) {
+    public static BigDecimal calcOrderAdjustments(List<GenericValue> orderHeaderAdjustments, BigDecimal subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) {
         BigDecimal adjTotal = ZERO;
 
         if (UtilValidate.isNotEmpty(orderHeaderAdjustments)) {
-            List filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false);
-            Iterator adjIt = filteredAdjs.iterator();
+            List<GenericValue> filteredAdjs = filterOrderAdjustments(orderHeaderAdjustments, includeOther, includeTax, includeShipping, false, false);
+            Iterator<GenericValue> adjIt = filteredAdjs.iterator();
 
             while (adjIt.hasNext()) {
-                GenericValue orderAdjustment = (GenericValue) adjIt.next();
+                GenericValue orderAdjustment = adjIt.next();
 
                 adjTotal = adjTotal.add(OrderReadHelper.calcOrderAdjustment(orderAdjustment, subTotal)).setScale(scale, rounding);
             }
@@ -2401,23 +2398,23 @@
     }
 
     // ================= Order Item Adjustments =================
-    public static BigDecimal getOrderItemsSubTotal(List orderItems, List adjustments) {
+    public static BigDecimal getOrderItemsSubTotal(List<GenericValue> orderItems, List<GenericValue> adjustments) {
         return getOrderItemsSubTotal(orderItems, adjustments, null);
     }
 
-    public static BigDecimal getOrderItemsSubTotal(List orderItems, List adjustments, List workEfforts) {
+    public static BigDecimal getOrderItemsSubTotal(List<GenericValue> orderItems, List<GenericValue> adjustments, List<GenericValue> workEfforts) {
         BigDecimal result = ZERO;
-        Iterator itemIter = UtilMisc.toIterator(orderItems);
+        Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems);
 
         while (itemIter != null && itemIter.hasNext()) {
-            GenericValue orderItem = (GenericValue) itemIter.next();
+            GenericValue orderItem = itemIter.next();
             BigDecimal itemTotal = getOrderItemSubTotal(orderItem, adjustments);
             // Debug.log("Item : " + orderItem.getString("orderId") + " / " + orderItem.getString("orderItemSeqId") + " = " + itemTotal, module);
 
             if (workEfforts != null && orderItem.getString("orderItemTypeId").compareTo("RENTAL_ORDER_ITEM") == 0) {
-                Iterator weIter = UtilMisc.toIterator(workEfforts);
+                Iterator<GenericValue> weIter = UtilMisc.toIterator(workEfforts);
                 while (weIter != null && weIter.hasNext()) {
-                    GenericValue workEffort = (GenericValue) weIter.next();
+                    GenericValue workEffort = weIter.next();
                     if (workEffort.getString("workEffortId").compareTo(orderItem.getString("orderItemSeqId")) == 0)    {
                         itemTotal = itemTotal.multiply(getWorkEffortRentalQuantity(workEffort)).setScale(scale, rounding);
                         break;
@@ -2432,12 +2429,12 @@
     }
 
     /** The passed adjustments can be all adjustments for the order, ie for all line items */
-    public static BigDecimal getOrderItemSubTotal(GenericValue orderItem, List adjustments) {
+    public static BigDecimal getOrderItemSubTotal(GenericValue orderItem, List<GenericValue> adjustments) {
         return getOrderItemSubTotal(orderItem, adjustments, false, false);
     }
 
     /** The passed adjustments can be all adjustments for the order, ie for all line items */
-    public static BigDecimal getOrderItemSubTotal(GenericValue orderItem, List adjustments, boolean forTax, boolean forShipping) {
+    public static BigDecimal getOrderItemSubTotal(GenericValue orderItem, List<GenericValue> adjustments, boolean forTax, boolean forShipping) {
         BigDecimal unitPrice = orderItem.getBigDecimal("unitPrice");
         BigDecimal quantity = getOrderItemQuantity(orderItem);
         BigDecimal result = ZERO;
@@ -2450,18 +2447,20 @@
 
             if ("RENTAL_ORDER_ITEM".equals(orderItem.getString("orderItemTypeId"))) {
                 // retrieve related work effort when required.
-                List WorkOrderItemFulfillments = null;
+                List<GenericValue> workOrderItemFulfillments = null;
                 try {
-                    WorkOrderItemFulfillments = orderItem.getDelegator().findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId")));
+                    workOrderItemFulfillments = orderItem.getDelegator().findByAndCache("WorkOrderItemFulfillment", UtilMisc.toMap("orderId", orderItem.getString("orderId"), "orderItemSeqId", orderItem.getString("orderItemSeqId")));
                 } catch (GenericEntityException e) {}
-                Iterator iter = WorkOrderItemFulfillments.iterator();
-                if (iter.hasNext())    {
-                    GenericValue WorkOrderItemFulfillment = (GenericValue) iter.next();
-                    GenericValue workEffort = null;
-                    try {
-                        workEffort = WorkOrderItemFulfillment.getRelatedOneCache("WorkEffort");
-                    } catch (GenericEntityException e) {}
-                    result = result.multiply(getWorkEffortRentalQuantity(workEffort));
+                if (workOrderItemFulfillments != null) {
+                    Iterator<GenericValue> iter = workOrderItemFulfillments.iterator();
+                    if (iter.hasNext())    {
+                        GenericValue WorkOrderItemFulfillment = iter.next();
+                        GenericValue workEffort = null;
+                        try {
+                            workEffort = WorkOrderItemFulfillment.getRelatedOneCache("WorkEffort");
+                        } catch (GenericEntityException e) {}
+                        result = result.multiply(getWorkEffortRentalQuantity(workEffort));
+                    }
                 }
             }
         }
@@ -2472,31 +2471,31 @@
         return result.setScale(scale, rounding);
     }
 
-    public static BigDecimal getOrderItemsTotal(List orderItems, List adjustments) {
+    public static BigDecimal getOrderItemsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments) {
         BigDecimal result = ZERO;
-        Iterator itemIter = UtilMisc.toIterator(orderItems);
+        Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems);
 
         while (itemIter != null && itemIter.hasNext()) {
-            result = result.add(getOrderItemTotal((GenericValue) itemIter.next(), adjustments));
+            result = result.add(getOrderItemTotal(itemIter.next(), adjustments));
         }
         return result.setScale(scale,  rounding);
     }
 
-    public static BigDecimal getOrderItemTotal(GenericValue orderItem, List adjustments) {
+    public static BigDecimal getOrderItemTotal(GenericValue orderItem, List<GenericValue> adjustments) {
         // add tax and shipping to subtotal
         return getOrderItemSubTotal(orderItem, adjustments).add(getOrderItemAdjustmentsTotal(orderItem, adjustments, false, true, true));
     }
 
-    public static BigDecimal calcOrderPromoAdjustmentsBd(List allOrderAdjustments) {
+    public static BigDecimal calcOrderPromoAdjustmentsBd(List<GenericValue> allOrderAdjustments) {
         BigDecimal promoAdjTotal = ZERO;
 
-        List promoAdjustments = EntityUtil.filterByAnd(allOrderAdjustments, UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT"));
+        List<GenericValue> promoAdjustments = EntityUtil.filterByAnd(allOrderAdjustments, UtilMisc.toMap("orderAdjustmentTypeId", "PROMOTION_ADJUSTMENT"));
 
         if (!promoAdjustments.isEmpty()) {
 
-            Iterator promoAdjIter = promoAdjustments.iterator();
+            Iterator<GenericValue> promoAdjIter = promoAdjustments.iterator();
             while (promoAdjIter.hasNext()) {
-                GenericValue promoAdjustment = (GenericValue) promoAdjIter.next();
+                GenericValue promoAdjustment = promoAdjIter.next();
 
                 if (promoAdjustment != null) {
                     BigDecimal amount = promoAdjustment.getBigDecimal("amount").setScale(taxCalcScale, taxRounding);
@@ -2548,39 +2547,39 @@
         return rentalAdjustment; // return total rental adjustment
         }
 
-    public static BigDecimal getAllOrderItemsAdjustmentsTotal(List orderItems, List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) {
+    public static BigDecimal getAllOrderItemsAdjustmentsTotal(List<GenericValue> orderItems, List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) {
         BigDecimal result = ZERO;
-        Iterator itemIter = UtilMisc.toIterator(orderItems);
+        Iterator<GenericValue> itemIter = UtilMisc.toIterator(orderItems);
 
         while (itemIter != null && itemIter.hasNext()) {
-            result = result.add(getOrderItemAdjustmentsTotal((GenericValue) itemIter.next(), adjustments, includeOther, includeTax, includeShipping));
+            result = result.add(getOrderItemAdjustmentsTotal(itemIter.next(), adjustments, includeOther, includeTax, includeShipping));
         }
         return result.setScale(scale, rounding);
     }
 
     /** The passed adjustments can be all adjustments for the order, ie for all line items */
-    public static BigDecimal getOrderItemAdjustmentsTotal(GenericValue orderItem, List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) {
+    public static BigDecimal getOrderItemAdjustmentsTotal(GenericValue orderItem, List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping) {
         return getOrderItemAdjustmentsTotal(orderItem, adjustments, includeOther, includeTax, includeShipping, false, false);
     }
 
     /** The passed adjustments can be all adjustments for the order, ie for all line items */
-    public static BigDecimal getOrderItemAdjustmentsTotal(GenericValue orderItem, List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) {
+    public static BigDecimal getOrderItemAdjustmentsTotal(GenericValue orderItem, List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) {
         return calcItemAdjustments(getOrderItemQuantity(orderItem), orderItem.getBigDecimal("unitPrice"),
                 getOrderItemAdjustmentList(orderItem, adjustments),
                 includeOther, includeTax, includeShipping, forTax, forShipping);
     }
 
-    public static List getOrderItemAdjustmentList(GenericValue orderItem, List adjustments) {
+    public static List<GenericValue> getOrderItemAdjustmentList(GenericValue orderItem, List<GenericValue> adjustments) {
         return EntityUtil.filterByAnd(adjustments, UtilMisc.toMap("orderItemSeqId", orderItem.get("orderItemSeqId")));
     }
 
-    public static List getOrderItemStatuses(GenericValue orderItem, List orderStatuses) {
-        List contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, orderItem.get("orderItemSeqId")));
-        List contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, null));
+    public static List<GenericValue> getOrderItemStatuses(GenericValue orderItem, List<GenericValue> orderStatuses) {
+        List<EntityExpr> contraints1 = UtilMisc.toList(EntityCondition.makeCondition("orderItemSeqId", EntityOperator.EQUALS, orderItem.get("orderItemSeqId")));
+        List<EntityExpr> contraints2 = UtilMisc.toList(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, null));
         contraints2.add(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, DataModelConstants.SEQ_ID_NA));
         contraints2.add(EntityCondition.makeCondition("orderPaymentPreferenceId", EntityOperator.EQUALS, ""));

[... 204 lines stripped ...]