svn commit: r712916 [3/3] - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r712916 [3/3] - /ofbiz/trunk/applications/product/src/org/ofbiz/product/product/

doogie-3
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java?rev=712916&r1=712915&r2=712916&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java Mon Nov 10 18:16:46 2008
@@ -63,7 +63,7 @@
     public static final String resource = "ProductUiLabels";
 
     /** First expire all ProductAssocs for all disc variants, then disc all virtuals that have all expired variant ProductAssocs */
-    public static Map discVirtualsWithDiscVariants(DispatchContext dctx, Map context) {
+    public static Map<String, Object> discVirtualsWithDiscVariants(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
         Locale locale = (Locale) context.get("locale");
@@ -78,18 +78,18 @@
             EntityListIterator eliOne = delegator.find("Product", conditionOne, null, null, null, null);
             GenericValue productOne = null;
             int numSoFarOne = 0;
-            while ((productOne = (GenericValue) eliOne.next()) != null) {
+            while ((productOne = eliOne.next()) != null) {
                 String virtualProductId = ProductWorker.getVariantVirtualId(productOne);
                 GenericValue virtualProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", virtualProductId));
                 if (virtualProduct == null) {
                     continue;
                 }
-                List passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"));
+                List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"));
                 passocList = EntityUtil.filterByDate(passocList);
                 if (passocList.size() > 0) {
-                    Iterator passocIter = passocList.iterator();
+                    Iterator<GenericValue> passocIter = passocList.iterator();
                     while (passocIter.hasNext()) {
-                        GenericValue passoc = (GenericValue) passocIter.next();
+                        GenericValue passoc = passocIter.next();
                         passoc.set("thruDate", nowTimestamp);
                         passoc.store();
                     }
@@ -110,8 +110,8 @@
             EntityListIterator eli = delegator.find("Product", condition, null, null, null, null);
             GenericValue product = null;
             int numSoFar = 0;
-            while ((product = (GenericValue) eli.next()) != null) {
-                List passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"));
+            while ((product = eli.next()) != null) {
+                List<GenericValue> passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT"));
                 passocList = EntityUtil.filterByDate(passocList);
                 if (passocList.size() == 0) {
                     product.set("salesDiscontinuationDate", nowTimestamp);
@@ -124,7 +124,7 @@
             }
             eli.close();
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_discVirtualsWithDiscVariants", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -134,7 +134,7 @@
     }
 
     /** for all disc products, remove from category memberships */
-    public static Map removeCategoryMembersOfDiscProducts(DispatchContext dctx, Map context) {
+    public static Map<String, Object> removeCategoryMembersOfDiscProducts(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
         Locale locale = (Locale) context.get("locale");
@@ -148,13 +148,13 @@
             EntityListIterator eli = delegator.find("Product", condition, null, null, null, null);
             GenericValue product = null;
             int numSoFar = 0;
-            while ((product = (GenericValue) eli.next()) != null) {
+            while ((product = eli.next()) != null) {
                 String productId = product.getString("productId");
-                List productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", productId));
+                List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", productId));
                 if (productCategoryMemberList.size() > 0) {
-                    Iterator productCategoryMemberIter = productCategoryMemberList.iterator();
+                    Iterator<GenericValue> productCategoryMemberIter = productCategoryMemberList.iterator();
                     while (productCategoryMemberIter.hasNext()) {
-                        GenericValue productCategoryMember = (GenericValue) productCategoryMemberIter.next();
+                        GenericValue productCategoryMember = productCategoryMemberIter.next();
                         // coded this way rather than a removeByAnd so it can be easily changed...
                         productCategoryMember.remove();
                     }
@@ -167,7 +167,7 @@
             eli.close();
             Debug.logInfo("Completed - Removed category members for " + numSoFar + " sales discontinued products.", module);
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_removeCategoryMembersOfDiscProducts", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -176,7 +176,7 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map removeDuplicateOpenEndedCategoryMembers(DispatchContext dctx, Map context) {
+    public static Map<String, Object> removeDuplicateOpenEndedCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
         Locale locale = (Locale) context.get("locale");
@@ -199,14 +199,14 @@
             EntityListIterator eli = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productCategoryId", "productIdCount"), null, null);
             GenericValue pcm = null;
             int numSoFar = 0;
-            while ((pcm = (GenericValue) eli.next()) != null) {
-                List productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")));
+            while ((pcm = eli.next()) != null) {
+                List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productId", pcm.get("productId"), "productCategoryId", pcm.get("productCategoryId")));
                 if (productCategoryMemberList.size() > 1) {
                     // remove all except the first...
                     productCategoryMemberList.remove(0);
-                    Iterator productCategoryMemberIter = productCategoryMemberList.iterator();
+                    Iterator<GenericValue> productCategoryMemberIter = productCategoryMemberList.iterator();
                     while (productCategoryMemberIter.hasNext()) {
-                        GenericValue productCategoryMember = (GenericValue) productCategoryMemberIter.next();
+                        GenericValue productCategoryMember = productCategoryMemberIter.next();
                         productCategoryMember.remove();
                     }
                     numSoFar++;
@@ -218,7 +218,7 @@
             eli.close();
             Debug.logInfo("Completed - Removed category members for " + numSoFar + " products with duplicate category members.", module);
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_removeDuplicateOpenEndedCategoryMembers", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -227,7 +227,7 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map makeStandAloneFromSingleVariantVirtuals(DispatchContext dctx, Map context) {
+    public static Map<String, Object> makeStandAloneFromSingleVariantVirtuals(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -258,19 +258,19 @@
                     ), EntityOperator.AND);
             EntityCondition havingCond = EntityCondition.makeCondition("productIdToCount", EntityOperator.EQUALS, Long.valueOf(1));
             EntityListIterator eliOne = delegator.findListIteratorByCondition(dve, condition, havingCond, UtilMisc.toList("productId", "productIdToCount"), null, null);
-            List valueList = eliOne.getCompleteList();
+            List<GenericValue> valueList = eliOne.getCompleteList();
             eliOne.close();
 
             Debug.logInfo("Found " + valueList.size() + " virtual products with one variant to turn into a stand alone product.", module);
 
             int numWithOneOnly = 0;
-            Iterator valueIter = valueList.iterator();
+            Iterator<GenericValue> valueIter = valueList.iterator();
             while (valueIter.hasNext()) {
                 // has only one variant period, is it valid? should already be discontinued if not
-                GenericValue value = (GenericValue) valueIter.next();
+                GenericValue value = valueIter.next();
 
                 String productId = value.getString("productId");
-                List paList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"));
+                List<GenericValue> paList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"));
                 paList = EntityUtil.filterByDate(paList);
                 // verify the query; tested on a bunch, looks good
                 if (paList.size() != 1) {
@@ -296,19 +296,19 @@
                     EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN_EQUAL_TO, nowTimestamp))
                     ), EntityOperator.AND);
             EntityListIterator eliMulti = delegator.findListIteratorByCondition(dve, conditionWithDates, havingCond, UtilMisc.toList("productId", "productIdToCount"), null, null);
-            List valueMultiList = eliMulti.getCompleteList();
+            List<GenericValue> valueMultiList = eliMulti.getCompleteList();
             eliMulti.close();
 
             Debug.logInfo("Found " + valueMultiList.size() + " virtual products with one VALID variant to pull the variant from to make a stand alone product.", module);
 
             int numWithOneValid = 0;
-            Iterator valueMultiIter = valueMultiList.iterator();
+            Iterator<GenericValue> valueMultiIter = valueMultiList.iterator();
             while (valueMultiIter.hasNext()) {
-                GenericValue value = (GenericValue) valueMultiIter.next();
+                GenericValue value = valueMultiIter.next();
                 // has only one valid variant
                 String productId = value.getString("productId");
 
-                List paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
+                List<GenericValue> paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
 
                 // verify the query; tested on a bunch, looks good
                 if (paList.size() != 1) {
@@ -326,12 +326,12 @@
 
             Debug.logInfo("Found virtual products with one valid variant: " + numWithOneValid + ", with one variant only: " + numWithOneOnly, module);
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_makeStandAloneFromSingleVariantVirtuals", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
         } catch (GenericServiceException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_makeStandAloneFromSingleVariantVirtuals", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -340,7 +340,7 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map mergeVirtualWithSingleVariant(DispatchContext dctx, Map context) {
+    public static Map<String, Object> mergeVirtualWithSingleVariant(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
 
@@ -360,16 +360,16 @@
             GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
             Debug.logInfo("Processing virtual product with one variant with ID: " + productId + " and name: " + product.getString("internalName"), module);
 
-            List paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
+            List<GenericValue> paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
             if (paList.size() > 1) {
-                Map messageMap = UtilMisc.toMap("productId", productId);
+                Map<String, String> messageMap = UtilMisc.toMap("productId", productId);
                 errMsg = UtilProperties.getMessage(resource,"productutilservices.found_more_than_one_valid_variant_for_virtual_ID", messageMap, locale);
                 Debug.logInfo(errMsg, module);
                 return ServiceUtil.returnError(errMsg);
             }
 
             if (paList.size() == 0) {
-                Map messageMap = UtilMisc.toMap("productId", productId);
+                Map<String, String> messageMap = UtilMisc.toMap("productId", productId);
                 errMsg = UtilProperties.getMessage(resource,"productutilservices.did_not_find_any_valid_variants_for_virtual_ID", messageMap, locale);
                 Debug.logInfo(errMsg, module);
                 return ServiceUtil.returnError(errMsg);
@@ -445,7 +445,7 @@
                 return ServiceUtil.returnError("Test mode - returning error to get a rollback");
             }
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_makeStandAloneFromSingleVariantVirtuals", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -455,10 +455,10 @@
     }
 
     protected static void duplicateRelated(GenericValue product, String title, String relatedEntityName, String productIdField, String variantProductId, Timestamp nowTimestamp, boolean removeOld, GenericDelegator delegator, boolean test) throws GenericEntityException {
-        List relatedList = EntityUtil.filterByDate(product.getRelated(title + relatedEntityName), nowTimestamp);
-        Iterator relatedIter = relatedList.iterator();
+        List<GenericValue> relatedList = EntityUtil.filterByDate(product.getRelated(title + relatedEntityName), nowTimestamp);
+        Iterator<GenericValue> relatedIter = relatedList.iterator();
         while (relatedIter.hasNext()) {
-            GenericValue relatedValue = (GenericValue) relatedIter.next();
+            GenericValue relatedValue = relatedIter.next();
             GenericValue newRelatedValue = (GenericValue) relatedValue.clone();
             newRelatedValue.set(productIdField, variantProductId);
 
@@ -469,7 +469,7 @@
                 // can't just set to null, need to remove the value so it isn't a constraint in the query
                 //findValue.set("fromDate", null);
                 findValue.remove("fromDate");
-                List existingValueList = EntityUtil.filterByDate(delegator.findByAnd(relatedEntityName, findValue), nowTimestamp);
+                List<GenericValue> existingValueList = EntityUtil.filterByDate(delegator.findByAnd(relatedEntityName, findValue), nowTimestamp);
                 if (existingValueList.size() > 0) {
                     if (test) {
                         Debug.logInfo("Found " + existingValueList.size() + " existing values for related entity name: " + relatedEntityName + ", not copying, findValue is: " + findValue, module);
@@ -500,7 +500,7 @@
     /** reset all product image names with a certain pattern, ex: /images/products/${size}/${productId}.jpg
      * NOTE: only works on fields of Product right now
      */
-    public static Map setAllProductImageNames(DispatchContext dctx, Map context) {
+    public static Map<String, Object> setAllProductImageNames(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
         String pattern = (String) context.get("pattern");
@@ -517,20 +517,20 @@
             EntityListIterator eli = delegator.find("Product", null, null, null, null, null);
             GenericValue product = null;
             int numSoFar = 0;
-            while ((product = (GenericValue) eli.next()) != null) {
+            while ((product = eli.next()) != null) {
                 String productId = (String) product.get("productId");
-                Map smallMap = UtilMisc.toMap("size", "small", "productId", productId);
-                Map mediumMap = UtilMisc.toMap("size", "medium", "productId", productId);
-                Map largeMap = UtilMisc.toMap("size", "large", "productId", productId);
-                Map detailMap = UtilMisc.toMap("size", "detail", "productId", productId);
+                Map<String, String> smallMap = UtilMisc.toMap("size", "small", "productId", productId);
+                Map<String, String> mediumMap = UtilMisc.toMap("size", "medium", "productId", productId);
+                Map<String, String> largeMap = UtilMisc.toMap("size", "large", "productId", productId);
+                Map<String, String> detailMap = UtilMisc.toMap("size", "detail", "productId", productId);
 
                 if ("Y".equals(product.getString("isVirtual"))) {
                     // find the first variant, use it's ID for the names...
-                    List productAssocList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
+                    List<GenericValue> productAssocList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")));
                     if (productAssocList.size() > 0) {
                         GenericValue productAssoc = EntityUtil.getFirst(productAssocList);
-                        smallMap.put("productId", productAssoc.get("productIdTo"));
-                        mediumMap.put("productId", productAssoc.get("productIdTo"));
+                        smallMap.put("productId", productAssoc.getString("productIdTo"));
+                        mediumMap.put("productId", productAssoc.getString("productIdTo"));
                         product.set("smallImageUrl", FlexibleStringExpander.expandString(pattern, smallMap));
                         product.set("mediumImageUrl", FlexibleStringExpander.expandString(pattern, mediumMap));
                     } else {
@@ -555,7 +555,7 @@
             eli.close();
             Debug.logInfo("Completed - Image URLs set for " + numSoFar + " products.", module);
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_setAllProductImageNames", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -564,7 +564,7 @@
         return ServiceUtil.returnSuccess();
     }
 
-    public static Map clearAllVirtualProductImageNames(DispatchContext dctx, Map context) {
+    public static Map<String, Object> clearAllVirtualProductImageNames(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         Locale locale = (Locale) context.get("locale");
         String errMsg = null;
@@ -573,7 +573,7 @@
             EntityListIterator eli = delegator.find("Product", EntityCondition.makeCondition("isVirtual", EntityOperator.EQUALS, "Y"), null, null, null, null);
             GenericValue product = null;
             int numSoFar = 0;
-            while ((product = (GenericValue) eli.next()) != null) {
+            while ((product = eli.next()) != null) {
                 product.set("smallImageUrl", null);
                 product.set("mediumImageUrl", null);
                 product.set("largeImageUrl", null);
@@ -587,7 +587,7 @@
             eli.close();
             Debug.logInfo("Completed - Image URLs set for " + numSoFar + " products.", module);
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.entity_error_running_clearAllVirtualProductImageNames", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -619,7 +619,7 @@
 
 
 
-    public static Map attachProductFeaturesToCategory(DispatchContext dctx, Map context) {
+    public static Map<String, Object> attachProductFeaturesToCategory(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         String productCategoryId = (String) context.get("productCategoryId");
         String doSubCategoriesStr = (String) context.get("doSubCategories");
@@ -630,17 +630,17 @@
         boolean doSubCategories = !"N".equals(doSubCategoriesStr);
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
 
-        Set productFeatureTypeIdsToExclude = FastSet.newInstance();
+        Set<String> productFeatureTypeIdsToExclude = FastSet.newInstance();
         String excludeProp = UtilProperties.getPropertyValue("prodsearch", "attach.feature.type.exclude");
         if (UtilValidate.isNotEmpty(excludeProp)) {
-            List typeList = StringUtil.split(excludeProp, ",");
+            List<String> typeList = StringUtil.split(excludeProp, ",");
             productFeatureTypeIdsToExclude.addAll(typeList);
         }
 
-        Set productFeatureTypeIdsToInclude = null;
+        Set<String> productFeatureTypeIdsToInclude = null;
         String includeProp = UtilProperties.getPropertyValue("prodsearch", "attach.feature.type.include");
         if (UtilValidate.isNotEmpty(includeProp)) {
-            List typeList = StringUtil.split(includeProp, ",");
+            List<String> typeList = StringUtil.split(includeProp, ",");
             if (typeList.size() > 0) {
                 productFeatureTypeIdsToInclude = UtilMisc.makeSetWritable(typeList);
             }
@@ -649,7 +649,7 @@
         try {
             attachProductFeaturesToCategory(productCategoryId, productFeatureTypeIdsToInclude, productFeatureTypeIdsToExclude, delegator, doSubCategories, nowTimestamp);
         } catch (GenericEntityException e) {
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"productutilservices.error_in_attachProductFeaturesToCategory", messageMap, locale);
             Debug.logError(e, errMsg, module);
             return ServiceUtil.returnError(errMsg);
@@ -661,27 +661,27 @@
     /** Get all features associated with products and associate them with a feature group attached to the category for each feature type;
      * includes products associated with this category only, but will also associate all feature groups of sub-categories with this category, optionally calls this method for all sub-categories too
      */
-    public static void attachProductFeaturesToCategory(String productCategoryId, Set productFeatureTypeIdsToInclude, Set productFeatureTypeIdsToExclude, GenericDelegator delegator, boolean doSubCategories, Timestamp nowTimestamp) throws GenericEntityException {
+    public static void attachProductFeaturesToCategory(String productCategoryId, Set<String> productFeatureTypeIdsToInclude, Set<String> productFeatureTypeIdsToExclude, GenericDelegator delegator, boolean doSubCategories, Timestamp nowTimestamp) throws GenericEntityException {
         if (nowTimestamp == null) {
             nowTimestamp = UtilDateTime.nowTimestamp();
         }
 
         // do sub-categories first so all feature groups will be in place
-        List subCategoryList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId));
+        List<GenericValue> subCategoryList = delegator.findByAnd("ProductCategoryRollup", UtilMisc.toMap("parentProductCategoryId", productCategoryId));
         if (doSubCategories) {
-            Iterator subCategoryIter = subCategoryList.iterator();
+            Iterator<GenericValue> subCategoryIter = subCategoryList.iterator();
             while (subCategoryIter.hasNext()) {
-                GenericValue productCategoryRollup = (GenericValue) subCategoryIter.next();
+                GenericValue productCategoryRollup = subCategoryIter.next();
                 attachProductFeaturesToCategory(productCategoryRollup.getString("productCategoryId"), productFeatureTypeIdsToInclude, productFeatureTypeIdsToExclude, delegator, true, nowTimestamp);
             }
         }
 
         // now get all features for this category and make associated feature groups
-        Map productFeatureIdByTypeIdSetMap = FastMap.newInstance();
-        List productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId));
-        Iterator productCategoryMemberIter = productCategoryMemberList.iterator();
+        Map<String, Set<String>> productFeatureIdByTypeIdSetMap = FastMap.newInstance();
+        List<GenericValue> productCategoryMemberList = delegator.findByAnd("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId));
+        Iterator<GenericValue> productCategoryMemberIter = productCategoryMemberList.iterator();
         while (productCategoryMemberIter.hasNext()) {
-            GenericValue productCategoryMember = (GenericValue) productCategoryMemberIter.next();
+            GenericValue productCategoryMember = productCategoryMemberIter.next();
             String productId = productCategoryMember.getString("productId");
             EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
                     EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId),
@@ -699,7 +699,7 @@
                 if (productFeatureTypeIdsToExclude != null && productFeatureTypeIdsToExclude.contains(productFeatureTypeId)) {
                     continue;
                 }
-                Set productFeatureIdSet = (Set) productFeatureIdByTypeIdSetMap.get(productFeatureTypeId);
+                Set<String> productFeatureIdSet = productFeatureIdByTypeIdSetMap.get(productFeatureTypeId);
                 if (productFeatureIdSet == null) {
                     productFeatureIdSet = FastSet.newInstance();
                     productFeatureIdByTypeIdSetMap.put(productFeatureTypeId, productFeatureIdSet);
@@ -709,11 +709,11 @@
             productFeatureAndApplEli.close();
         }
 
-        Iterator productFeatureIdByTypeIdSetIter = productFeatureIdByTypeIdSetMap.entrySet().iterator();
+        Iterator<Map.Entry<String, Set<String>>> productFeatureIdByTypeIdSetIter = productFeatureIdByTypeIdSetMap.entrySet().iterator();
         while (productFeatureIdByTypeIdSetIter.hasNext()) {
-            Map.Entry entry = (Map.Entry) productFeatureIdByTypeIdSetIter.next();
-            String productFeatureTypeId = (String) entry.getKey();
-            Set productFeatureIdSet = (Set) entry.getValue();
+            Map.Entry<String, Set<String>> entry = productFeatureIdByTypeIdSetIter.next();
+            String productFeatureTypeId = entry.getKey();
+            Set<String> productFeatureIdSet = entry.getValue();
 
             String productFeatureGroupId = productCategoryId + "_" + productFeatureTypeId;
             if (productFeatureGroupId.length() > 20) {
@@ -733,9 +733,9 @@
             }
 
             // now put all of the features in the group, if there is not already a valid feature placement there...
-            Iterator productFeatureIdIter = productFeatureIdSet.iterator();
+            Iterator<String> productFeatureIdIter = productFeatureIdSet.iterator();
             while (productFeatureIdIter.hasNext()) {
-                String productFeatureId = (String) productFeatureIdIter.next();
+                String productFeatureId = productFeatureIdIter.next();
                 EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
                         EntityCondition.makeCondition("productFeatureId", EntityOperator.EQUALS, productFeatureId),
                         EntityCondition.makeCondition("productFeatureGroupId", EntityOperator.EQUALS, productFeatureGroupId),
@@ -751,9 +751,9 @@
         }
 
         // now get all feature groups associated with sub-categories and associate them with this category
-        Iterator subCategoryIter = subCategoryList.iterator();
+        Iterator<GenericValue> subCategoryIter = subCategoryList.iterator();
         while (subCategoryIter.hasNext()) {
-            GenericValue productCategoryRollup = (GenericValue) subCategoryIter.next();
+            GenericValue productCategoryRollup = subCategoryIter.next();
             String subProductCategoryId = productCategoryRollup.getString("productCategoryId");
             EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toList(
                     EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, subProductCategoryId),
@@ -762,7 +762,7 @@
             ), EntityOperator.AND);
             EntityListIterator productFeatureCatGrpApplEli = delegator.find("ProductFeatureCatGrpAppl", condition, null, null, null, null);
             GenericValue productFeatureCatGrpAppl = null;
-            while ((productFeatureCatGrpAppl = (GenericValue) productFeatureCatGrpApplEli.next()) != null) {
+            while ((productFeatureCatGrpAppl = productFeatureCatGrpApplEli.next()) != null) {
                 String productFeatureGroupId = productFeatureCatGrpAppl.getString("productFeatureGroupId");
                 EntityCondition checkCondition = EntityCondition.makeCondition(UtilMisc.toList(
                         EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, productCategoryId),
@@ -780,11 +780,11 @@
         }
     }
 
-    public static Map removeAllFeatureGroupsForCategory(DispatchContext dctx, Map context) {
+    public static Map<String, Object> removeAllFeatureGroupsForCategory(DispatchContext dctx, Map<String, ? extends Object> context) {
         return ServiceUtil.returnSuccess();
     }
 
-    public static void getFeatureGroupsForCategory(String productCategoryId, Set productFeatureGroupIdsToRemove, GenericDelegator delegator, boolean doSubCategories, Timestamp nowTimestamp) throws GenericEntityException {
+    public static void getFeatureGroupsForCategory(String productCategoryId, Set<String> productFeatureGroupIdsToRemove, GenericDelegator delegator, boolean doSubCategories, Timestamp nowTimestamp) throws GenericEntityException {
 
     }
 }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java?rev=712916&r1=712915&r2=712916&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java Mon Nov 10 18:16:46 2008
@@ -87,24 +87,24 @@
     private static boolean isAllowedToAddress(GenericValue product, GenericValue postalAddress, String productGeoPrefix) {
         if (UtilValidate.isNotEmpty(product) && UtilValidate.isNotEmpty(postalAddress)) {
             GenericDelegator delegator = product.getDelegator();
-            List productGeos = null;
+            List<GenericValue> productGeos = null;
             try {
                 productGeos = product.getRelated("ProductGeo");
             } catch (GenericEntityException e) {
                 Debug.logError(e, module);
             }
-            List excludeGeos = EntityUtil.filterByAnd(productGeos, UtilMisc.toMap("productGeoEnumId", productGeoPrefix + "EXCLUDE"));
-            List includeGeos = EntityUtil.filterByAnd(productGeos, UtilMisc.toMap("productGeoEnumId", productGeoPrefix + "INCLUDE"));
+            List<GenericValue> excludeGeos = EntityUtil.filterByAnd(productGeos, UtilMisc.toMap("productGeoEnumId", productGeoPrefix + "EXCLUDE"));
+            List<GenericValue> includeGeos = EntityUtil.filterByAnd(productGeos, UtilMisc.toMap("productGeoEnumId", productGeoPrefix + "INCLUDE"));
             if (UtilValidate.isEmpty(excludeGeos) && UtilValidate.isEmpty(includeGeos)) {
                 // If no GEOs are configured the default is TRUE
                 return true;
             }
-            Iterator productGeosIt = null;
+            Iterator<GenericValue> productGeosIt = null;
             // exclusion
             productGeosIt = excludeGeos.iterator();
             while (productGeosIt.hasNext()) {
-                GenericValue productGeo = (GenericValue)productGeosIt.next();
-                List excludeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator);
+                GenericValue productGeo = productGeosIt.next();
+                List<GenericValue> excludeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator);
                 if (GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("countryGeoId"), delegator) ||
                       GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("stateProvinceGeoId"), delegator) ||
                       GeoWorker.containsGeo(excludeGeoGroup, postalAddress.getString("postalCodeGeoId"), delegator)) {
@@ -118,8 +118,8 @@
             // inclusion
             productGeosIt = includeGeos.iterator();
             while (productGeosIt.hasNext()) {
-                GenericValue productGeo = (GenericValue)productGeosIt.next();
-                List includeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator);
+                GenericValue productGeo = productGeosIt.next();
+                List<GenericValue> includeGeoGroup = GeoWorker.expandGeoGroup(productGeo.getString("geoId"), delegator);
                 if (GeoWorker.containsGeo(includeGeoGroup, postalAddress.getString("countryGeoId"), delegator) ||
                       GeoWorker.containsGeo(includeGeoGroup, postalAddress.getString("stateProvinceGeoId"), delegator) ||
                       GeoWorker.containsGeo(includeGeoGroup, postalAddress.getString("postalCodeGeoId"), delegator)) {
@@ -187,11 +187,11 @@
     }
 
     public static String getAggregatedInstanceId(GenericDelegator delegator, String  aggregatedProductId, String configId) throws GenericEntityException {
-        List productAssocs = getAggregatedAssocs(delegator, aggregatedProductId);
+        List<GenericValue> productAssocs = getAggregatedAssocs(delegator, aggregatedProductId);
         if (UtilValidate.isNotEmpty(productAssocs) && UtilValidate.isNotEmpty(configId)) {
-            Iterator pai = productAssocs.iterator();
+            Iterator<GenericValue> pai = productAssocs.iterator();
             while (pai.hasNext()) {
-                GenericValue productAssoc = (GenericValue) pai.next();
+                GenericValue productAssoc = pai.next();
                 GenericValue product = productAssoc.getRelatedOne("AssocProduct");
                 if (configId.equals(product.getString("configId"))) {
                     return productAssoc.getString("productIdTo");
@@ -201,11 +201,11 @@
         return null;
     }
     
-    public static List getAggregatedAssocs(GenericDelegator delegator, String  aggregatedProductId) throws GenericEntityException {
+    public static List<GenericValue> getAggregatedAssocs(GenericDelegator delegator, String  aggregatedProductId) throws GenericEntityException {
         GenericValue aggregatedProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", aggregatedProductId));
         
         if (UtilValidate.isNotEmpty(aggregatedProduct) && "AGGREGATED".equals(aggregatedProduct.getString("productTypeId"))) {
-            List productAssocs = EntityUtil.filterByDate(aggregatedProduct.getRelatedByAnd("MainProductAssoc",
+            List<GenericValue> productAssocs = EntityUtil.filterByDate(aggregatedProduct.getRelatedByAnd("MainProductAssoc",
                     UtilMisc.toMap("productAssocTypeId", "PRODUCT_CONF")));
             return productAssocs;
         }
@@ -213,7 +213,7 @@
     }
     
     public static String getVariantVirtualId(GenericValue variantProduct) throws GenericEntityException {
-        List productAssocs = getVariantVirtualAssocs(variantProduct);
+        List<GenericValue> productAssocs = getVariantVirtualAssocs(variantProduct);
         if (productAssocs == null) {
             return null;
         }
@@ -225,9 +225,9 @@
         }
     }
 
-    public static List getVariantVirtualAssocs(GenericValue variantProduct) throws GenericEntityException {
+    public static List<GenericValue> getVariantVirtualAssocs(GenericValue variantProduct) throws GenericEntityException {
         if (variantProduct != null && "Y".equals(variantProduct.getString("isVariant"))) {
-            List productAssocs = EntityUtil.filterByDate(variantProduct.getRelatedByAndCache("AssocProductAssoc",
+            List<GenericValue> productAssocs = EntityUtil.filterByDate(variantProduct.getRelatedByAndCache("AssocProductAssoc",
                     UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")));
             return productAssocs;
         }
@@ -242,7 +242,7 @@
         Double availableToPromise = null;
 
         try {
-            Map result = dispatcher.runSync("getInventoryAvailableByFacility",
+            Map<String, Object> result = dispatcher.runSync("getInventoryAvailableByFacility",
                                             UtilMisc.toMap("productId", productId, "facilityId", inventoryFacilityId));
 
             availableToPromise = (Double) result.get("availableToPromiseTotal");
@@ -272,14 +272,14 @@
      **/
     public static boolean isProductInventoryAvailableByFacility(ProductConfigWrapper productConfig, String inventoryFacilityId, double quantity, LocalDispatcher dispatcher) throws GenericServiceException {
         boolean available = true;
-        List options = productConfig.getSelectedOptions();
-        Iterator optionsIt = options.iterator();
+        List<ConfigOption> options = productConfig.getSelectedOptions();
+        Iterator<ConfigOption> optionsIt = options.iterator();
         while (optionsIt.hasNext()) {
-            ConfigOption ci = (ConfigOption)optionsIt.next();
-            List products = ci.getComponents();
-            Iterator productsIt = products.iterator();
+            ConfigOption ci = optionsIt.next();
+            List<GenericValue> products = ci.getComponents();
+            Iterator<GenericValue> productsIt = products.iterator();
             while (productsIt.hasNext()) {
-                GenericValue product = (GenericValue)productsIt.next();
+                GenericValue product = productsIt.next();
                 String productId = product.getString("productId");
                 Double cmpQuantity = product.getDouble("quantity");
                 double neededQty = 1.0;
@@ -305,16 +305,16 @@
             return;
 
         try {
-            List upgradeProducts = product.getRelatedByAndCache("MainProductAssoc",
+            List<GenericValue> upgradeProducts = product.getRelatedByAndCache("MainProductAssoc",
                     UtilMisc.toMap("productAssocTypeId", "PRODUCT_UPGRADE"));
 
-            List complementProducts = product.getRelatedByAndCache("MainProductAssoc",
+            List<GenericValue> complementProducts = product.getRelatedByAndCache("MainProductAssoc",
                     UtilMisc.toMap("productAssocTypeId", "PRODUCT_COMPLEMENT"));
 
-            List obsolescenceProducts = product.getRelatedByAndCache("AssocProductAssoc",
+            List<GenericValue> obsolescenceProducts = product.getRelatedByAndCache("AssocProductAssoc",
                     UtilMisc.toMap("productAssocTypeId", "PRODUCT_OBSOLESCENCE"));
 
-            List obsoleteByProducts = product.getRelatedByAndCache("MainProductAssoc",
+            List<GenericValue> obsoleteByProducts = product.getRelatedByAndCache("MainProductAssoc",
                     UtilMisc.toMap("productAssocTypeId", "PRODUCT_OBSOLESCENCE"));
 
             // since ProductAssoc records have a fromDate and thruDate, we can filter by now so that only assocs in the date range are included
@@ -340,7 +340,7 @@
      * Gets ProductFeature GenericValue for all distinguishing features of a variant product.
      * Distinguishing means all features that are selectable on the corresponding virtual product and standard on the variant plus all DISTINGUISHING_FEAT assoc type features on the variant.
      */
-    public static Set getVariantDistinguishingFeatures(GenericValue variantProduct) throws GenericEntityException {
+    public static Set<GenericValue> getVariantDistinguishingFeatures(GenericValue variantProduct) throws GenericEntityException {
         if (variantProduct == null) {
             return FastSet.newInstance();
         }
@@ -351,35 +351,35 @@
         String virtualProductId = getVariantVirtualId(variantProduct);
         
         // find all selectable features on the virtual product that are also standard features on the variant
-        Set distFeatures = FastSet.newInstance();
+        Set<GenericValue> distFeatures = FastSet.newInstance();
         
-        List variantDistinguishingFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT"));
+        List<GenericValue> variantDistinguishingFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "DISTINGUISHING_FEAT"));
         // Debug.logInfo("Found variantDistinguishingFeatures: " + variantDistinguishingFeatures, module);
 
-        Iterator variantDistinguishingFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(variantDistinguishingFeatures));
+        Iterator<GenericValue> variantDistinguishingFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(variantDistinguishingFeatures));
         while (variantDistinguishingFeatureIter != null && variantDistinguishingFeatureIter.hasNext()) {
-            GenericValue variantDistinguishingFeature = (GenericValue) variantDistinguishingFeatureIter.next();
+            GenericValue variantDistinguishingFeature = variantDistinguishingFeatureIter.next();
             GenericValue dummyFeature = delegator.makeValue("ProductFeature");
             dummyFeature.setAllFields(variantDistinguishingFeature, true, null, null);
             distFeatures.add(dummyFeature);
         }
 
-        List virtualSelectableFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"));
+        List<GenericValue> virtualSelectableFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", virtualProductId, "productFeatureApplTypeId", "SELECTABLE_FEATURE"));
         // Debug.logInfo("Found virtualSelectableFeatures: " + virtualSelectableFeatures, module);
 
-        Iterator virtualSelectableFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(virtualSelectableFeatures));
-        Set virtualSelectableFeatureIds = FastSet.newInstance();
+        Iterator<GenericValue> virtualSelectableFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(virtualSelectableFeatures));
+        Set<String> virtualSelectableFeatureIds = FastSet.newInstance();
         while (virtualSelectableFeatureIter != null && virtualSelectableFeatureIter.hasNext()) {
-            GenericValue virtualSelectableFeature = (GenericValue) virtualSelectableFeatureIter.next();
-            virtualSelectableFeatureIds.add(virtualSelectableFeature.get("productFeatureId"));
+            GenericValue virtualSelectableFeature = virtualSelectableFeatureIter.next();
+            virtualSelectableFeatureIds.add(virtualSelectableFeature.getString("productFeatureId"));
         }
         
-        List variantStandardFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE"));
+        List<GenericValue> variantStandardFeatures = delegator.findByAndCache("ProductFeatureAndAppl", UtilMisc.toMap("productId", variantProduct.get("productId"), "productFeatureApplTypeId", "STANDARD_FEATURE"));
         // Debug.logInfo("Found variantStandardFeatures: " + variantStandardFeatures, module);
 
-        Iterator variantStandardFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(variantStandardFeatures));
+        Iterator<GenericValue> variantStandardFeatureIter = UtilMisc.toIterator(EntityUtil.filterByDate(variantStandardFeatures));
         while (variantStandardFeatureIter != null && variantStandardFeatureIter.hasNext()) {
-            GenericValue variantStandardFeature = (GenericValue) variantStandardFeatureIter.next();
+            GenericValue variantStandardFeature = variantStandardFeatureIter.next();
             if (virtualSelectableFeatureIds.contains(variantStandardFeature.get("productFeatureId"))) {
                 GenericValue dummyFeature = delegator.makeValue("ProductFeature");
                 dummyFeature.setAllFields(variantStandardFeature, true, null, null);
@@ -399,14 +399,14 @@
             GenericValue alternativeOptionProduct = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", alternativeOptionProductId));
             if (alternativeOptionProduct != null) {
                 if ("Y".equals(alternativeOptionProduct.getString("isVariant"))) {
-                    Set distFeatures = getVariantDistinguishingFeatures(alternativeOptionProduct);
+                    Set<GenericValue> distFeatures = getVariantDistinguishingFeatures(alternativeOptionProduct);
                     if (UtilValidate.isNotEmpty(distFeatures)) {
                         // Debug.logInfo("Found distinguishing features: " + distFeatures, module);
                         
                         StringBuilder nameBuf = new StringBuilder();
-                        Iterator distFeatIter = distFeatures.iterator();
+                        Iterator<GenericValue> distFeatIter = distFeatures.iterator();
                         while (distFeatIter.hasNext()) {
-                            GenericValue productFeature = (GenericValue) distFeatIter.next();
+                            GenericValue productFeature = distFeatIter.next();
                             GenericValue productFeatureType = productFeature.getRelatedOneCache("ProductFeatureType");
                             if (productFeatureType != null) {
                                 nameBuf.append(productFeatureType.get("description", locale));
@@ -442,7 +442,7 @@
      * @param productFeatureApplTypeId - if null, returns ALL productFeatures, regardless of applType
      * @return List
      */
-    public static List getProductFeaturesByApplTypeId(GenericDelegator delegator, String productId, String productFeatureApplTypeId) {
+    public static List<GenericValue> getProductFeaturesByApplTypeId(GenericDelegator delegator, String productId, String productFeatureApplTypeId) {
         if (productId == null) {
             return null;
         }
@@ -455,14 +455,14 @@
         return null;
     }
 
-    public static List getProductFeaturesByApplTypeId(GenericValue product, String productFeatureApplTypeId) {
+    public static List<GenericValue> getProductFeaturesByApplTypeId(GenericValue product, String productFeatureApplTypeId) {
         if (product == null) {
             return null;
         }
-        List features = FastList.newInstance();
+        List<GenericValue> features = FastList.newInstance();
         try {
             if (product != null) {
-                List productAppls;
+                List<GenericValue> productAppls;
                 if (productFeatureApplTypeId == null) {
                     productAppls = product.getRelated("ProductFeatureAppl");
                 } else {
@@ -470,7 +470,7 @@
                             UtilMisc.toMap("productFeatureApplTypeId", productFeatureApplTypeId));
                 }
                 for (int i = 0; i < productAppls.size(); i++) {
-                    GenericValue productAppl = (GenericValue)productAppls.get(i);
+                    GenericValue productAppl = productAppls.get(i);
                     features.add(productAppl.getRelatedOne("ProductFeature"));
                 }
                 features = EntityUtil.orderBy(features, UtilMisc.toList("description"));
@@ -511,18 +511,18 @@
                 GenericDelegator delegator = product.getDelegator();
                 Map<String,String> fields = UtilMisc.toMap("productId", product.getString("productId"), "productFeatureApplTypeId", "SELECTABLE_FEATURE");
                 List<String> order = UtilMisc.toList("productFeatureTypeId", "sequenceNum");
-                List features = delegator.findByAndCache("ProductFeatureAndAppl", fields, order);
-                List featuresSorted = (List) UtilMisc.sortMaps(features, order);
-                Iterator it = (Iterator) featuresSorted.iterator();
+                List<GenericValue> features = delegator.findByAndCache("ProductFeatureAndAppl", fields, order);
+                List<GenericValue> featuresSorted = EntityUtil.orderBy(features, order);
+                Iterator<GenericValue> it = featuresSorted.iterator();
                 String oldType = null;
                 List<Map<String,String>> featureList = FastList.newInstance();
                 while(it.hasNext()) {
-                    GenericValue productFeatureAppl = (GenericValue) it.next();
+                    GenericValue productFeatureAppl = it.next();
                     if (oldType == null || !oldType.equals(productFeatureAppl.getString("productFeatureTypeId"))) {
                      // use first entry for type and description
                         if (oldType != null) {
                             featureTypeFeatures.add(featureList);
-                            featureList =  FastList.newInstance();
+                            featureList = FastList.newInstance();
                             }
                         GenericValue productFeatureType = delegator.findByPrimaryKey("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId",
                          productFeatureAppl.getString("productFeatureTypeId")));
@@ -531,13 +531,13 @@
                         oldType = productFeatureAppl.getString("productFeatureTypeId");
                     }
                     // fill other entries with featureId, description and default price and currency
-                    Map <String,String> featureData = UtilMisc.toMap("productFeatureId", productFeatureAppl.getString("productFeatureId"));
+                    Map<String,String> featureData = UtilMisc.toMap("productFeatureId", productFeatureAppl.getString("productFeatureId"));
                     if (UtilValidate.isNotEmpty(productFeatureAppl.get("description"))) {
                  featureData.put("description", productFeatureAppl.getString("description"));
                     } else {
                      featureData.put("description", productFeatureAppl.getString("productFeatureId"));
                     }
-                    List <GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice",
+                    List<GenericValue> productFeaturePrices = EntityUtil.filterByDate(delegator.findByAnd("ProductFeaturePrice",
                      UtilMisc.toMap("productFeatureId", productFeatureAppl.getString("productFeatureId"), "productPriceTypeId", "DEFAULT_PRICE")));
                     if (UtilValidate.isNotEmpty(productFeaturePrices)) {
                      GenericValue productFeaturePrice = productFeaturePrices.get(0);
@@ -559,10 +559,10 @@
         return featureTypeFeatures;
     }
 
-    public static Map getOptionalProductFeatures(GenericDelegator delegator, String productId) {
-        Map featureMap = new LinkedHashMap();
+    public static Map<String, List<GenericValue>> getOptionalProductFeatures(GenericDelegator delegator, String productId) {
+        Map<String, List<GenericValue>> featureMap = new LinkedHashMap<String, List<GenericValue>>();
 
-        List productFeatureAppls = null;
+        List<GenericValue> productFeatureAppls = null;
         try {
             productFeatureAppls = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "OPTIONAL_FEATURE"), UtilMisc.toList("productFeatureTypeId", "sequenceNum"));
         } catch (GenericEntityException e) {
@@ -570,11 +570,11 @@
         }
 
         if (productFeatureAppls != null) {
-            Iterator i = productFeatureAppls.iterator();
+            Iterator<GenericValue> i = productFeatureAppls.iterator();
             while (i.hasNext()) {
-                GenericValue appl = (GenericValue) i.next();
+                GenericValue appl = i.next();
                 String featureType = appl.getString("productFeatureTypeId");
-                List features = (List) featureMap.get(featureType);
+                List<GenericValue> features = featureMap.get(featureType);
                 if (features == null) {
                     features = FastList.newInstance();
                 }
@@ -588,15 +588,15 @@
 
     // product calc methods
     
-    public static double calcOrderAdjustments(List orderHeaderAdjustments, double subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) {
+    public static double calcOrderAdjustments(List<GenericValue> orderHeaderAdjustments, double subTotal, boolean includeOther, boolean includeTax, boolean includeShipping) {
         double adjTotal = 0.0;
 
         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 += calcOrderAdjustment(orderAdjustment, subTotal);
             }
@@ -616,14 +616,14 @@
         return adjustment;
     }    
     
-    public static List filterOrderAdjustments(List adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) {
-        List newOrderAdjustmentsList = FastList.newInstance();
+    public static List<GenericValue> filterOrderAdjustments(List<GenericValue> adjustments, boolean includeOther, boolean includeTax, boolean includeShipping, boolean forTax, boolean forShipping) {
+        List<GenericValue> newOrderAdjustmentsList = FastList.newInstance();
 
         if (UtilValidate.isNotEmpty(adjustments)) {
-            Iterator adjIt = adjustments.iterator();
+            Iterator<GenericValue> adjIt = adjustments.iterator();
 
             while (adjIt.hasNext()) {
-                GenericValue orderAdjustment = (GenericValue) adjIt.next();
+                GenericValue orderAdjustment = adjIt.next();
 
                 boolean includeAdjustment = false;
 
@@ -671,7 +671,7 @@
         return getAverageProductRating(product, null, productStoreId);
     }
 
-    public static double getAverageProductRating(GenericValue product, List reviews, String productStoreId) {
+    public static double getAverageProductRating(GenericValue product, List<GenericValue> reviews, String productStoreId) {
         if (product == null) {
             Debug.logWarning("Invalid product entity passed; unable to obtain valid product rating", module);
             return 0.00;
@@ -686,14 +686,14 @@
             productEntityRating = Double.valueOf(0);
         }
         if (entityFieldType == null) {
-            entityFieldType = new String();
+            entityFieldType = "";
         }
 
         if ("PRDR_FLAT".equals(entityFieldType)) {
             productRating = productEntityRating.doubleValue();
         } else {
             // get the product rating from the ProductReview entity; limit by product store if ID is passed
-            Map reviewByAnd = UtilMisc.toMap("statusId", "PRR_APPROVED");
+            Map<String, String> reviewByAnd = UtilMisc.toMap("statusId", "PRR_APPROVED");
             if (productStoreId != null) {
                 reviewByAnd.put("productStoreId", productStoreId);
             }
@@ -711,9 +711,9 @@
             double ratingTally = 0;
             double numRatings = 0;
             if (reviews != null) {
-                Iterator i = reviews.iterator();
+                Iterator<GenericValue> i = reviews.iterator();
                 while (i.hasNext()) {
-                    GenericValue productReview = (GenericValue) i.next();
+                    GenericValue productReview = i.next();
                     Double rating = productReview.getDouble("productRating");
                     if (rating != null) {
                         ratingTally += rating.doubleValue();
@@ -741,7 +741,7 @@
         return productRating;
     }
 
-    public static List getCurrentProductCategories(GenericDelegator delegator, String productId) {
+    public static List<GenericValue> getCurrentProductCategories(GenericDelegator delegator, String productId) {
         GenericValue product = null;
         try {
             product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
@@ -751,13 +751,13 @@
         return getCurrentProductCategories(delegator, product);
     }
 
-    public static List getCurrentProductCategories(GenericDelegator delegator, GenericValue product) {
+    public static List<GenericValue> getCurrentProductCategories(GenericDelegator delegator, GenericValue product) {
         if (product == null) {
             return null;
         }
-        List categories = FastList.newInstance();
+        List<GenericValue> categories = FastList.newInstance();
         try {
-            List categoryMembers = product.getRelated("ProductCategoryMember");
+            List<GenericValue> categoryMembers = product.getRelated("ProductCategoryMember");
             categoryMembers = EntityUtil.filterByDate(categoryMembers);
             categories = EntityUtil.getRelated("ProductCategory", categoryMembers);
         } catch (GenericEntityException e) {
@@ -774,7 +774,7 @@
         }
 
         try {
-            List virtualProductAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"));
+            List<GenericValue> virtualProductAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate"));
             virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs);
             if (UtilValidate.isEmpty(virtualProductAssocs)) {
                 //okay, not a variant, try a UNIQUE_ITEM
@@ -956,7 +956,7 @@
         return products;
     }
 
-    public static List findProducts(GenericDelegator delegator, String idToFind) throws GenericEntityException {
+    public static List<GenericValue> findProducts(GenericDelegator delegator, String idToFind) throws GenericEntityException {
         return findProducts(delegator, idToFind, null);
     }
 
@@ -989,31 +989,31 @@
         return false;
     }
     
-    public static Set getRefurbishedProductIdSet(String productId, GenericDelegator delegator) throws GenericEntityException {
-        Set productIdSet = FastSet.newInstance();
+    public static Set<String> getRefurbishedProductIdSet(String productId, GenericDelegator delegator) throws GenericEntityException {
+        Set<String> productIdSet = FastSet.newInstance();
 
         // find associated refurb items, we want serial number for main item or any refurb items too
-        List refubProductAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc",
+        List<GenericValue> refubProductAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc",
                 UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_REFURB")));
-        Iterator refubProductAssocIter = refubProductAssocs.iterator();
+        Iterator<GenericValue> refubProductAssocIter = refubProductAssocs.iterator();
         while (refubProductAssocIter.hasNext()) {
-            GenericValue refubProductAssoc = (GenericValue) refubProductAssocIter.next();
-            productIdSet.add(refubProductAssoc.get("productIdTo"));
+            GenericValue refubProductAssoc = refubProductAssocIter.next();
+            productIdSet.add(refubProductAssoc.getString("productIdTo"));
         }
         
         // see if this is a refurb productId to, and find product(s) it is a refurb of
-        List refubProductToAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc",
+        List<GenericValue> refubProductToAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc",
                 UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB")));
-        Iterator refubProductToAssocIter = refubProductToAssocs.iterator();
+        Iterator<GenericValue> refubProductToAssocIter = refubProductToAssocs.iterator();
         while (refubProductToAssocIter.hasNext()) {
-            GenericValue refubProductToAssoc = (GenericValue) refubProductToAssocIter.next();
-            productIdSet.add(refubProductToAssoc.get("productId"));
+            GenericValue refubProductToAssoc = refubProductToAssocIter.next();
+            productIdSet.add(refubProductToAssoc.getString("productId"));
         }
         
         return productIdSet;
     }
     
-    public static String getVariantFromFeatureTree(String productId, List selectedFeatures, GenericDelegator delegator) {
+    public static String getVariantFromFeatureTree(String productId, List<String> selectedFeatures, GenericDelegator delegator) {
         
         //  all method code moved here from ShoppingCartEvents.addToCart event
         String variantProductId = null;
@@ -1078,15 +1078,15 @@
             }
             // find variant
             // Debug.log("=====try to find variant for product: " + productId + " and features: " + selectedFeatures);
-            List  <GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId","PRODUCT_VARIANT")));
+            List<GenericValue> productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId","PRODUCT_VARIANT")));
             Iterator <GenericValue> assocIter = productAssocs.iterator();
             boolean productFound = false;
 nextProd:       while(assocIter.hasNext()) {
-                GenericValue productAssoc = (GenericValue) assocIter.next();
+                GenericValue productAssoc = assocIter.next();
                 Iterator <String> fIter = selectedFeatures.iterator();
                 while (fIter.hasNext()) {
-                    String featureId = (String) fIter.next();
-                    List <GenericValue> pAppls = delegator.findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE"));
+                    String featureId = fIter.next();
+                    List<GenericValue> pAppls = delegator.findByAndCache("ProductFeatureAppl", UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), "productFeatureId", featureId, "productFeatureApplTypeId","STANDARD_FEATURE"));
                     if (UtilValidate.isEmpty(pAppls)) {
                         continue nextProd;
                     }
@@ -1121,7 +1121,7 @@
                     productFeatureAppl.create();
                 }
                 //add standard features too
-                List <GenericValue> stdFeaturesAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")));
+                List<GenericValue> stdFeaturesAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")));
                 Iterator <GenericValue> stdFeatureIter = stdFeaturesAppls.iterator();              
                 while (stdFeatureIter.hasNext()) {
                     GenericValue stdFeaturesAppl = stdFeatureIter.next();
@@ -1132,7 +1132,7 @@
                  *  take the default price from the vitual product, go to the productfeature table and retrieve all the prices for the difFerent features
                  *  add these to the price of the virtual product, store the result as the default price on the variant you created.
                  */
-                List <GenericValue> productPrices = EntityUtil.filterByDate(delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId)));
+                List<GenericValue> productPrices = EntityUtil.filterByDate(delegator.findByAnd("ProductPrice", UtilMisc.toMap("productId", productId)));
                 Iterator <GenericValue> ppIter = productPrices.iterator();
                 while (ppIter.hasNext()) {
                     GenericValue productPrice = ppIter.next();
@@ -1160,7 +1160,7 @@
                 Debug.log("set the productId to: " + product.getString("productId"));
                 
                 // copy the supplier
-                List <GenericValue> supplierProducts = delegator.findByAndCache("SupplierProduct", UtilMisc.toMap("productId", productId));
+                List<GenericValue> supplierProducts = delegator.findByAndCache("SupplierProduct", UtilMisc.toMap("productId", productId));
                 Iterator <GenericValue> SPite = supplierProducts.iterator();
                 while (SPite.hasNext()) {
                     GenericValue supplierProduct = SPite.next();
@@ -1169,7 +1169,7 @@
                 }
                 
                 // copy the content
-                List <GenericValue> productContents = delegator.findByAndCache("ProductContent", UtilMisc.toMap("productId", productId));
+                List<GenericValue> productContents = delegator.findByAndCache("ProductContent", UtilMisc.toMap("productId", productId));
                 Iterator <GenericValue> productContentsTte = productContents.iterator();
                 while (productContentsTte.hasNext()) {
                     GenericValue productContent = productContentsTte.next();

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java?rev=712916&r1=712915&r2=712916&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/VariantEvents.java Mon Nov 10 18:16:46 2008
@@ -73,7 +73,7 @@
         try {
             featureTypeSize = Integer.parseInt(featureTypeSizeStr);
         } catch (NumberFormatException e) {
-            Map messageMap = UtilMisc.toMap("featureTypeSizeStr", featureTypeSizeStr);
+            Map<String, String> messageMap = UtilMisc.toMap("featureTypeSizeStr", featureTypeSizeStr);
             errMsg = UtilProperties.getMessage(resource,"variantevents.featureTypeSize_not_number", messageMap, UtilHttp.getLocale(request));
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
@@ -86,7 +86,7 @@
                 // read the product, duplicate it with the given id
                 GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId));
                 if (product == null) {
-                    Map messageMap = UtilMisc.toMap("productId", productId);
+                    Map<String, String> messageMap = UtilMisc.toMap("productId", productId);
                     errMsg = UtilProperties.getMessage(resource,"variantevents.product_not_found_with_ID", messageMap, UtilHttp.getLocale(request));
                     TransactionUtil.rollback(beganTransacton, errMsg, null);
                     request.setAttribute("_ERROR_MESSAGE_", errMsg);
@@ -123,7 +123,7 @@
                 for (int i = 0; i < featureTypeSize; i++) {
                     String productFeatureId = request.getParameter("feature_" + i);
                     if (productFeatureId == null) {
-                        Map messageMap = UtilMisc.toMap("i", Integer.toString(i));
+                        Map<String, String> messageMap = UtilMisc.toMap("i", Integer.toString(i));
                         errMsg = UtilProperties.getMessage(resource,"variantevents.productFeatureId_for_feature_type_number_not_found", messageMap, UtilHttp.getLocale(request));
                         TransactionUtil.rollback(beganTransacton, errMsg, null);
                         request.setAttribute("_ERROR_MESSAGE_", errMsg);
@@ -146,7 +146,7 @@
 
                 TransactionUtil.commit(beganTransacton);
             } catch (GenericEntityException e) {
-                Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+                Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
                 errMsg = UtilProperties.getMessage(resource,"variantevents.entity_error_quick_add_variant_data", messageMap, UtilHttp.getLocale(request));
                 TransactionUtil.rollback(beganTransacton, errMsg, null);
                 Debug.logError(e, "Entity error creating quick add variant data", module);
@@ -155,13 +155,13 @@
             }
         } catch (GenericTransactionException e) {
             Debug.logError(e, "Transaction error creating quick add variant data", module);
-            Map messageMap = UtilMisc.toMap("errMessage", e.toString());
+            Map<String, String> messageMap = UtilMisc.toMap("errMessage", e.toString());
             errMsg = UtilProperties.getMessage(resource,"variantevents.transaction_error_quick_add_variant_data", messageMap, UtilHttp.getLocale(request));
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
 
-        Map messageMap = UtilMisc.toMap("variantProductId", variantProductId);
+        Map<String, String> messageMap = UtilMisc.toMap("variantProductId", variantProductId);
         String sucMsg = UtilProperties.getMessage(resource,"variantevents.successfully_created_variant_product_with_id", messageMap, UtilHttp.getLocale(request));
         request.setAttribute("_EVENT_MESSAGE_", sucMsg);
         return "success";