Author: doogie
Date: Mon Nov 10 18:18:07 2008 New Revision: 712917 URL: http://svn.apache.org/viewvc?rev=712917&view=rev Log: The rest of the generics markup, just in product/. Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ParametricSearch.java ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/promo/PromoServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductHelper.java ofbiz/trunk/applications/product/src/org/ofbiz/product/spreadsheetimport/ImportProductServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/store/ProductStoreWorker.java ofbiz/trunk/applications/product/src/org/ofbiz/product/subscription/SubscriptionServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/supplier/SupplierProductServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/test/InventoryItemTransferTest.java ofbiz/trunk/applications/product/src/org/ofbiz/product/test/StockMovesTest.java Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/catalog/CatalogWorker.java Mon Nov 10 18:18:07 2008 @@ -57,9 +57,9 @@ return WebSiteWorker.getWebSite(request); } - public static List getAllCatalogIds(ServletRequest request) { - List catalogIds = FastList.newInstance(); - List catalogs = null; + public static List<String> getAllCatalogIds(ServletRequest request) { + List<String> catalogIds = FastList.newInstance(); + List<GenericValue> catalogs = null; GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); try { catalogs = delegator.findList("ProdCatalog", null, null, UtilMisc.toList("catalogName"), null, false); @@ -67,22 +67,22 @@ Debug.logError(e, "Error looking up all catalogs", module); } if (catalogs != null) { - Iterator i = catalogs.iterator(); + Iterator<GenericValue> i = catalogs.iterator(); while (i.hasNext()) { - GenericValue c = (GenericValue) i.next(); + GenericValue c = i.next(); catalogIds.add(c.getString("prodCatalogId")); } } return catalogIds; } - public static List getStoreCatalogs(ServletRequest request) { + public static List<GenericValue> getStoreCatalogs(ServletRequest request) { String productStoreId = ProductStoreWorker.getProductStoreId(request); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); return getStoreCatalogs(delegator, productStoreId); } - public static List getStoreCatalogs(GenericDelegator delegator, String productStoreId) { + public static List<GenericValue> getStoreCatalogs(GenericDelegator delegator, String productStoreId) { try { return EntityUtil.filterByDate(delegator.findByAndCache("ProductStoreCatalog", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNum", "prodCatalogId")), true); } catch (GenericEntityException e) { @@ -91,7 +91,7 @@ return null; } - public static List getPartyCatalogs(ServletRequest request) { + public static List<GenericValue> getPartyCatalogs(ServletRequest request) { HttpSession session = ((HttpServletRequest) request).getSession(); GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); if (userLogin == null) userLogin = (GenericValue) session.getAttribute("autoUserLogin"); @@ -102,7 +102,7 @@ return getPartyCatalogs(delegator, partyId); } - public static List getPartyCatalogs(GenericDelegator delegator, String partyId) { + public static List<GenericValue> getPartyCatalogs(GenericDelegator delegator, String partyId) { if (delegator == null || partyId == null) { return null; } @@ -115,14 +115,14 @@ return null; } - public static List getProdCatalogCategories(ServletRequest request, String prodCatalogId, String prodCatalogCategoryTypeId) { + public static List<GenericValue> getProdCatalogCategories(ServletRequest request, String prodCatalogId, String prodCatalogCategoryTypeId) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); return getProdCatalogCategories(delegator, prodCatalogId, prodCatalogCategoryTypeId); } - public static List getProdCatalogCategories(GenericDelegator delegator, String prodCatalogId, String prodCatalogCategoryTypeId) { + public static List<GenericValue> getProdCatalogCategories(GenericDelegator delegator, String prodCatalogId, String prodCatalogCategoryTypeId) { try { - List prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAndCache("ProdCatalogCategory", + List<GenericValue> prodCatalogCategories = EntityUtil.filterByDate(delegator.findByAndCache("ProdCatalogCategory", UtilMisc.toMap("prodCatalogId", prodCatalogId), UtilMisc.toList("sequenceNum", "productCategoryId")), true); @@ -145,7 +145,7 @@ */ public static String getCurrentCatalogId(ServletRequest request) { HttpSession session = ((HttpServletRequest) request).getSession(); - Map requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request); + Map<String, Object> requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request); String prodCatalogId = null; boolean fromSession = false; @@ -158,40 +158,40 @@ } // get it from the database if (prodCatalogId == null) { - List catalogIds = getCatalogIdsAvailable(request); - if (catalogIds != null && catalogIds.size() > 0) prodCatalogId = (String) catalogIds.get(0); + List<String> catalogIds = getCatalogIdsAvailable(request); + if (catalogIds != null && catalogIds.size() > 0) prodCatalogId = catalogIds.get(0); } if (!fromSession) { if (Debug.verboseOn()) Debug.logVerbose("[CatalogWorker.getCurrentCatalogId] Setting new catalog name: " + prodCatalogId, module); session.setAttribute("CURRENT_CATALOG_ID", prodCatalogId); - CategoryWorker.setTrail(request, FastList.newInstance()); + CategoryWorker.setTrail(request, FastList.<String>newInstance()); } return prodCatalogId; } - public static List getCatalogIdsAvailable(ServletRequest request) { - List partyCatalogs = getPartyCatalogs(request); - List storeCatalogs = getStoreCatalogs(request); + public static List<String> getCatalogIdsAvailable(ServletRequest request) { + List<GenericValue> partyCatalogs = getPartyCatalogs(request); + List<GenericValue> storeCatalogs = getStoreCatalogs(request); return getCatalogIdsAvailable(partyCatalogs, storeCatalogs); } - public static List getCatalogIdsAvailable(GenericDelegator delegator, String productStoreId, String partyId) { - List storeCatalogs = getStoreCatalogs(delegator, productStoreId); - List partyCatalogs = getPartyCatalogs(delegator, partyId); + public static List<String> getCatalogIdsAvailable(GenericDelegator delegator, String productStoreId, String partyId) { + List<GenericValue> storeCatalogs = getStoreCatalogs(delegator, productStoreId); + List<GenericValue> partyCatalogs = getPartyCatalogs(delegator, partyId); return getCatalogIdsAvailable(partyCatalogs, storeCatalogs); } - public static List getCatalogIdsAvailable(List partyCatalogs, List storeCatalogs) { - List categoryIds = FastList.newInstance(); - List allCatalogLinks = FastList.newInstance(); + public static List<String> getCatalogIdsAvailable(List<GenericValue> partyCatalogs, List<GenericValue> storeCatalogs) { + List<String> categoryIds = FastList.newInstance(); + List<GenericValue> allCatalogLinks = FastList.newInstance(); if (partyCatalogs != null) allCatalogLinks.addAll(partyCatalogs); if (storeCatalogs != null) allCatalogLinks.addAll(storeCatalogs); if (allCatalogLinks.size() > 0) { - Iterator aclIter = allCatalogLinks.iterator(); + Iterator<GenericValue> aclIter = allCatalogLinks.iterator(); while (aclIter.hasNext()) { - GenericValue catalogLink = (GenericValue) aclIter.next(); + GenericValue catalogLink = aclIter.next(); categoryIds.add(catalogLink.getString("prodCatalogId")); } } @@ -260,7 +260,7 @@ public static String getCatalogTopCategoryId(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_BROWSE_ROOT"); + List<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_BROWSE_ROOT"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); @@ -281,7 +281,7 @@ public static String getCatalogSearchCategoryId(GenericDelegator delegator, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_SEARCH"); + List<GenericValue> prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_SEARCH"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); @@ -293,7 +293,7 @@ public static String getCatalogViewAllowCategoryId(GenericDelegator delegator, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_VIEW_ALLW"); + List<GenericValue> prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_VIEW_ALLW"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); @@ -305,7 +305,7 @@ public static String getCatalogPurchaseAllowCategoryId(GenericDelegator delegator, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - List prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_PURCH_ALLW"); + List<GenericValue> prodCatalogCategories = getProdCatalogCategories(delegator, prodCatalogId, "PCCT_PURCH_ALLW"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); return prodCatalogCategory.getString("productCategoryId"); @@ -321,7 +321,7 @@ public static String getCatalogPromotionsCategoryId(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_PROMOTIONS"); + List<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_PROMOTIONS"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); @@ -359,7 +359,7 @@ public static String getCatalogQuickaddCategoryPrimary(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - List prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD"); + List<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { GenericValue prodCatalogCategory = EntityUtil.getFirst(prodCatalogCategories); @@ -370,22 +370,22 @@ } } - public static Collection getCatalogQuickaddCategories(ServletRequest request) { + public static Collection<String> getCatalogQuickaddCategories(ServletRequest request) { return getCatalogQuickaddCategories(request, getCurrentCatalogId(request)); } - public static Collection getCatalogQuickaddCategories(ServletRequest request, String prodCatalogId) { + public static Collection<String> getCatalogQuickaddCategories(ServletRequest request, String prodCatalogId) { if (prodCatalogId == null || prodCatalogId.length() <= 0) return null; - Collection categoryIds = FastList.newInstance(); + Collection<String> categoryIds = FastList.newInstance(); - Collection prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD"); + Collection<GenericValue> prodCatalogCategories = getProdCatalogCategories(request, prodCatalogId, "PCCT_QUICK_ADD"); if (UtilValidate.isNotEmpty(prodCatalogCategories)) { - Iterator pccIter = prodCatalogCategories.iterator(); + Iterator<GenericValue> pccIter = prodCatalogCategories.iterator(); while (pccIter.hasNext()) { - GenericValue prodCatalogCategory = (GenericValue) pccIter.next(); + GenericValue prodCatalogCategory = pccIter.next(); categoryIds.add(prodCatalogCategory.getString("productCategoryId")); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryContentWrapper.java Mon Nov 10 18:18:07 2008 @@ -139,12 +139,12 @@ } } - List categoryContentList = delegator.findByAndCache("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate")); + List<GenericValue> categoryContentList = delegator.findByAndCache("ProductCategoryContent", UtilMisc.toMap("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId), UtilMisc.toList("-fromDate")); categoryContentList = EntityUtil.filterByDate(categoryContentList); GenericValue categoryContent = EntityUtil.getFirst(categoryContentList); if (categoryContent != null) { // when rendering the category content, always include the Product Category and ProductCategoryContent records that this comes from - Map inContext = FastMap.newInstance(); + Map<String, Object> inContext = FastMap.newInstance(); inContext.put("productCategory", productCategory); inContext.put("categoryContent", categoryContent); ContentWorker.renderContentAsText(dispatcher, delegator, categoryContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryServices.java Mon Nov 10 18:18:07 2008 @@ -28,6 +28,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; @@ -52,11 +53,11 @@ public static final String module = CategoryServices.class.getName(); - public static Map getCategoryMembers(DispatchContext dctx, Map context) { + public static Map<String, Object> getCategoryMembers(DispatchContext dctx, Map<String, ? extends Object> context) { GenericDelegator delegator = dctx.getDelegator(); String categoryId = (String) context.get("categoryId"); GenericValue productCategory = null; - List members = null; + List<GenericValue> members = null; try { productCategory = delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId)); @@ -67,13 +68,13 @@ Debug.logError(e, errMsg, module); return ServiceUtil.returnError(errMsg); } - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("category", productCategory); result.put("categoryMembers", members); return result; } - public static Map getPreviousNextProducts(DispatchContext dctx, Map context) { + public static Map<String, Object> getPreviousNextProducts(DispatchContext dctx, Map<String, ? extends Object> context) { GenericDelegator delegator = dctx.getDelegator(); String categoryId = (String) context.get("categoryId"); String productId = (String) context.get("productId"); @@ -84,12 +85,12 @@ return ServiceUtil.returnError("Both Index and ProductID cannot be null."); } - List orderByFields = (List) context.get("orderByFields"); + List<String> orderByFields = UtilGenerics.checkList(context.get("orderByFields")); if (orderByFields == null) orderByFields = FastList.newInstance(); String entityName = getCategoryFindEntityName(delegator, orderByFields); GenericValue productCategory; - List productCategoryMembers; + List<GenericValue> productCategoryMembers; try { productCategory = delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", categoryId)); productCategoryMembers = delegator.findByAndCache(entityName, UtilMisc.toMap("productCategoryId", categoryId), orderByFields); @@ -104,9 +105,9 @@ if (productId != null && index == null) { - Iterator i = productCategoryMembers.iterator(); + Iterator<GenericValue> i = productCategoryMembers.iterator(); while (i.hasNext()) { - GenericValue v = (GenericValue) i.next(); + GenericValue v = i.next(); if (v.getString("productId").equals(productId)) { index = Integer.valueOf(productCategoryMembers.indexOf(v)); } @@ -118,31 +119,31 @@ return ServiceUtil.returnSuccess("Product not found in the current category."); } - Map result = ServiceUtil.returnSuccess(); + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("category", productCategory); String previous = null; String next = null; if (index.intValue() - 1 >= 0 && index.intValue() - 1 < productCategoryMembers.size()) { - previous = ((GenericValue) productCategoryMembers.get(index.intValue() - 1)).getString("productId"); + previous = productCategoryMembers.get(index.intValue() - 1).getString("productId"); result.put("previousProductId", previous); } else { - previous = ((GenericValue) productCategoryMembers.get(productCategoryMembers.size() - 1)).getString("productId"); + previous = productCategoryMembers.get(productCategoryMembers.size() - 1).getString("productId"); result.put("previousProductId", previous); } if (index.intValue() + 1 < productCategoryMembers.size()) { - next = ((GenericValue) productCategoryMembers.get(index.intValue() + 1)).getString("productId"); + next = productCategoryMembers.get(index.intValue() + 1).getString("productId"); result.put("nextProductId", next); } else { - next = ((GenericValue) productCategoryMembers.get(0)).getString("productId"); + next = productCategoryMembers.get(0).getString("productId"); result.put("nextProductId", next); } return result; } - private static String getCategoryFindEntityName(GenericDelegator delegator, List orderByFields) { + private static String getCategoryFindEntityName(GenericDelegator delegator, List<String> orderByFields) { // allow orderByFields to contain fields from the Product entity, if there are such fields String entityName = "ProductCategoryMember"; if (orderByFields == null) { @@ -155,10 +156,9 @@ ModelEntity productModel = delegator.getModelEntity("Product"); ModelEntity productCategoryMemberModel = delegator.getModelEntity("ProductCategoryMember"); - Iterator orderByFieldIter = orderByFields.iterator(); + Iterator<String> orderByFieldIter = orderByFields.iterator(); while (orderByFieldIter.hasNext()) { - String orderByField = (String) orderByFieldIter.next(); - + String orderByField = orderByFieldIter.next(); // Get the real field name from the order by field removing ascending/descending order if (UtilValidate.isNotEmpty(orderByField)) { int startPos = 0, endPos = orderByField.length(); @@ -191,13 +191,13 @@ return entityName; } - public static Map getProductCategoryAndLimitedMembers(DispatchContext dctx, Map context) { + public static Map<String, Object> getProductCategoryAndLimitedMembers(DispatchContext dctx, Map<String, ? extends Object> context) { GenericDelegator delegator = dctx.getDelegator(); String productCategoryId = (String) context.get("productCategoryId"); boolean limitView = ((Boolean) context.get("limitView")).booleanValue(); int defaultViewSize = ((Integer) context.get("defaultViewSize")).intValue(); - List orderByFields = (List) context.get("orderByFields"); + List<String> orderByFields = UtilGenerics.checkList(context.get("orderByFields")); if (orderByFields == null) orderByFields = FastList.newInstance(); String entityName = getCategoryFindEntityName(delegator, orderByFields); @@ -252,7 +252,7 @@ highIndex = 0; } - List productCategoryMembers = null; + List<GenericValue> productCategoryMembers = null; if (productCategory != null) { try { if (useCacheForMembers) { @@ -281,7 +281,8 @@ highIndex = listSize; } } else { - List mainCondList = UtilMisc.toList(EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, productCategory.getString("productCategoryId"))); + List<EntityCondition> mainCondList = FastList.newInstance(); + mainCondList.add(EntityCondition.makeCondition("productCategoryId", EntityOperator.EQUALS, productCategory.getString("productCategoryId"))); if (activeOnly) { mainCondList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, nowTimestamp)); mainCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, nowTimestamp))); @@ -302,7 +303,7 @@ int chunkSize = 0; listSize = 0; - while ((nextValue = (GenericValue) pli.next()) != null) { + while ((nextValue = pli.next()) != null) { String productId = nextValue.getString("productId"); if (CategoryWorker.isProductInCategory(delegator, productId, viewProductCategoryId)) { if (listSize + 1 >= lowIndex && chunkSize < viewSize) { @@ -348,7 +349,7 @@ } } - Map result = FastMap.newInstance(); + Map<String, Object> result = FastMap.newInstance(); result.put("viewIndex", Integer.valueOf(viewIndex)); result.put("viewSize", Integer.valueOf(viewSize)); result.put("lowIndex", Integer.valueOf(lowIndex)); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/category/CategoryWorker.java Mon Nov 10 18:18:07 2008 @@ -33,6 +33,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilFormatOut; +import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; @@ -90,18 +91,18 @@ public static void getCategoriesWithNoParent(ServletRequest request, String attributeName) { GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); - Collection results = FastList.newInstance(); + Collection<GenericValue> results = FastList.newInstance(); try { - Collection allCategories = delegator.findList("ProductCategory", null, null, null, null, false); + Collection<GenericValue> allCategories = delegator.findList("ProductCategory", null, null, null, null, false); if (allCategories == null) return; - Iterator aciter = allCategories.iterator(); + Iterator<GenericValue> aciter = allCategories.iterator(); while (aciter.hasNext()) { - GenericValue curCat = (GenericValue) aciter.next(); - Collection parentCats = curCat.getRelatedCache("CurrentProductCategoryRollup"); + GenericValue curCat = aciter.next(); + Collection<GenericValue> parentCats = curCat.getRelatedCache("CurrentProductCategoryRollup"); if (parentCats == null || parentCats.size() <= 0) results.add(curCat); @@ -118,7 +119,7 @@ } public static void getRelatedCategories(ServletRequest request, String attributeName, boolean limitView) { - Map requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request); + Map<String, Object> requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request); String requestId = null; requestId = UtilFormatOut.checkNull((String)requestParameters.get("catalog_id"), (String)requestParameters.get("CATALOG_ID"), @@ -140,32 +141,32 @@ } public static void getRelatedCategories(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) { - List categories = getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty); + List<GenericValue> categories = getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty); if (categories.size() > 0) request.setAttribute(attributeName, categories); } /** @deprecated */ - public static List getRelatedCategoriesRet(PageContext pageContext, String attributeName, String parentId, boolean limitView) { + public static List<GenericValue> getRelatedCategoriesRet(PageContext pageContext, String attributeName, String parentId, boolean limitView) { return getRelatedCategoriesRet(pageContext.getRequest(), attributeName, parentId, limitView); } - public static List getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView) { + public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView) { return getRelatedCategoriesRet(request, attributeName, parentId, limitView, false); } - public static List getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) { + public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty) { return getRelatedCategoriesRet(request, attributeName, parentId, limitView, excludeEmpty, false); } - public static List getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) { - List categories = FastList.newInstance(); + public static List<GenericValue> getRelatedCategoriesRet(ServletRequest request, String attributeName, String parentId, boolean limitView, boolean excludeEmpty, boolean recursive) { + List<GenericValue> categories = FastList.newInstance(); if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.getRelatedCategories] ParentID: " + parentId, module); GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); - List rollups = null; + List<GenericValue> rollups = null; try { rollups = delegator.findByAndCache("ProductCategoryRollup", @@ -180,10 +181,10 @@ } if (UtilValidate.isNotEmpty(rollups)) { // Debug.log("Rollup size: " + rollups.size(), module); - Iterator ri = rollups.iterator(); + Iterator<GenericValue> ri = rollups.iterator(); while (ri.hasNext()) { - GenericValue parent = (GenericValue) ri.next(); + GenericValue parent = ri.next(); // Debug.log("Adding child of: " + parent.getString("parentProductCategoryId"), module); GenericValue cv = null; @@ -258,12 +259,12 @@ } private static EntityCondition buildCountCondition(String fieldName, String fieldValue) { - List orCondList = FastList.newInstance(); + List<EntityCondition> orCondList = FastList.newInstance(); orCondList.add(EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, UtilDateTime.nowTimestamp())); orCondList.add(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null)); EntityCondition orCond = EntityCondition.makeCondition(orCondList, EntityOperator.OR); - List andCondList = FastList.newInstance(); + List<EntityCondition> andCondList = FastList.newInstance(); andCondList.add(EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN, UtilDateTime.nowTimestamp())); andCondList.add(EntityCondition.makeCondition(fieldName, EntityOperator.EQUALS, fieldValue)); andCondList.add(orCond); @@ -278,7 +279,7 @@ } public static void setTrail(ServletRequest request, String currentCategory) { - Map requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request); + Map<String, Object> requestParameters = UtilHttp.getParameterMap((HttpServletRequest) request); String previousCategory = (String) requestParameters.get("pcategory"); if (Debug.verboseOn()) Debug.logVerbose("[CategoryWorker.setTrail] Start: previousCategory=" + previousCategory + @@ -289,7 +290,7 @@ return; // always get the last crumb list - List crumb = getTrail(request); + List<String> crumb = getTrail(request); if (crumb == null) { crumb = FastList.newInstance(); @@ -303,7 +304,7 @@ if (cindex < (crumb.size() - 1)) { for (int i = crumb.size() - 1; i > cindex; i--) { - String deadCat = (String) crumb.remove(i); + String deadCat = crumb.remove(i); if (Debug.infoOn()) Debug.logInfo("[CategoryWorker.setTrail] Removed after current category index: " + i + " catname: " + deadCat, module); @@ -336,7 +337,7 @@ if (index < (crumb.size() - 1)) { for (int i = crumb.size() - 1; i > index; i--) { - String deadCat = (String) crumb.remove(i); + String deadCat = crumb.remove(i); if (Debug.infoOn()) Debug.logInfo("[CategoryWorker.setTrail] Removed after previous category index: " + i + " catname: " + deadCat, module); @@ -351,22 +352,22 @@ } /** @deprecated */ - public static List getTrail(PageContext pageContext) { + public static List<String> getTrail(PageContext pageContext) { return getTrail(pageContext.getRequest()); } - public static List getTrail(ServletRequest request) { + public static List<String> getTrail(ServletRequest request) { HttpSession session = ((HttpServletRequest) request).getSession(); - List crumb = (List) session.getAttribute("_BREAD_CRUMB_TRAIL_"); + List<String> crumb = UtilGenerics.checkList(session.getAttribute("_BREAD_CRUMB_TRAIL_")); return crumb; } /** @deprecated */ - public static List setTrail(PageContext pageContext, List crumb) { + public static List<String> setTrail(PageContext pageContext, List<String> crumb) { return setTrail(pageContext.getRequest(), crumb); } - public static List setTrail(ServletRequest request, List crumb) { + public static List<String> setTrail(ServletRequest request, List<String> crumb) { HttpSession session = ((HttpServletRequest) request).getSession(); session.setAttribute("_BREAD_CRUMB_TRAIL_", crumb); return crumb; @@ -378,7 +379,7 @@ } public static boolean checkTrailItem(ServletRequest request, String category) { - List crumb = getTrail(request); + List<String> crumb = getTrail(request); if (crumb != null && crumb.contains(category)) return true; @@ -392,10 +393,10 @@ } public static String lastTrailItem(ServletRequest request) { - List crumb = getTrail(request); + List<String> crumb = getTrail(request); if (UtilValidate.isNotEmpty(crumb)) { - return (String) crumb.get(crumb.size() - 1); + return crumb.get(crumb.size() - 1); } else { return null; } @@ -405,17 +406,17 @@ if (productCategoryId == null) return false; if (productId == null || productId.length() == 0) return false; - List productCategoryMembers = EntityUtil.filterByDate(delegator.findByAndCache("ProductCategoryMember", + List<GenericValue> productCategoryMembers = EntityUtil.filterByDate(delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productCategoryId", productCategoryId, "productId", productId)), true); if (productCategoryMembers == null || productCategoryMembers.size() == 0) { //before giving up see if this is a variant product, and if so look up the virtual product and check it... GenericValue product = delegator.findByPrimaryKeyCache("Product", UtilMisc.toMap("productId", productId)); - List productAssocs = ProductWorker.getVariantVirtualAssocs(product); + List<GenericValue> productAssocs = ProductWorker.getVariantVirtualAssocs(product); //this does take into account that a product could be a variant of multiple products, but this shouldn't ever really happen... if (UtilValidate.isNotEmpty(productAssocs)) { - Iterator pasIter = productAssocs.iterator(); + Iterator<GenericValue> pasIter = productAssocs.iterator(); while (pasIter.hasNext()) { - GenericValue productAssoc = (GenericValue) pasIter.next(); + GenericValue productAssoc = pasIter.next(); if (isProductInCategory(delegator, productAssoc.getString("productId"), productCategoryId)) { return true; } @@ -428,19 +429,19 @@ } } - public static List filterProductsInCategory(GenericDelegator delegator, List valueObjects, String productCategoryId) throws GenericEntityException { + public static List<GenericValue> filterProductsInCategory(GenericDelegator delegator, List<GenericValue> valueObjects, String productCategoryId) throws GenericEntityException { return filterProductsInCategory(delegator, valueObjects, productCategoryId, "productId"); } - public static List filterProductsInCategory(GenericDelegator delegator, List valueObjects, String productCategoryId, String productIdFieldName) throws GenericEntityException { - List newList = FastList.newInstance(); + public static List<GenericValue> filterProductsInCategory(GenericDelegator delegator, List<GenericValue> valueObjects, String productCategoryId, String productIdFieldName) throws GenericEntityException { + List<GenericValue> newList = FastList.newInstance(); if (productCategoryId == null) return newList; if (valueObjects == null) return null; - Iterator valIter = valueObjects.iterator(); + Iterator<GenericValue> valIter = valueObjects.iterator(); while (valIter.hasNext()) { - GenericValue curValue = (GenericValue) valIter.next(); + GenericValue curValue = valIter.next(); String productId = curValue.getString(productIdFieldName); if (isProductInCategory(delegator, productId, productCategoryId)) { newList.add(curValue); @@ -449,13 +450,13 @@ return newList; } - public static void getCategoryContentWrappers(Map catContentWrappers, List categoryList, HttpServletRequest request) throws GenericEntityException { + public static void getCategoryContentWrappers(Map<String, CategoryContentWrapper> catContentWrappers, List<GenericValue> categoryList, HttpServletRequest request) throws GenericEntityException { if (catContentWrappers == null || categoryList == null) { return; } - Iterator catIterator = categoryList.iterator(); - while(catIterator.hasNext()) { - GenericValue cat = (GenericValue) catIterator.next(); + Iterator<GenericValue> catIterator = categoryList.iterator(); + while (catIterator.hasNext()) { + GenericValue cat = catIterator.next(); String productCategoryId = (String) cat.get("productCategoryId"); if (catContentWrappers.containsKey(productCategoryId)) { @@ -465,8 +466,7 @@ CategoryContentWrapper catContentWrapper = new CategoryContentWrapper(cat, request); catContentWrappers.put(productCategoryId, catContentWrapper); - List subCat = FastList.newInstance(); - subCat = getRelatedCategoriesRet(request, "subCatList", productCategoryId, true); + List<GenericValue> subCat = getRelatedCategoriesRet(request, "subCatList", productCategoryId, true); if(subCat != null) { getCategoryContentWrappers(catContentWrappers, subCat, request ); } Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigItemContentWrapper.java Mon Nov 10 18:18:07 2008 @@ -134,12 +134,12 @@ } } - List productConfigItemContentList = delegator.findByAndCache("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate")); + List<GenericValue> productConfigItemContentList = delegator.findByAndCache("ProdConfItemContent", UtilMisc.toMap("configItemId", configItemId, "confItemContentTypeId", confItemContentTypeId), UtilMisc.toList("-fromDate")); productConfigItemContentList = EntityUtil.filterByDate(productConfigItemContentList); GenericValue productConfigItemContent = EntityUtil.getFirst(productConfigItemContentList); if (productConfigItemContent != null) { // when rendering the product config item content, always include the ProductConfigItem and ProdConfItemContent records that this comes from - Map inContext = FastMap.newInstance(); + Map<String, Object> inContext = FastMap.newInstance(); inContext.put("productConfigItem", productConfigItem); inContext.put("productConfigItemContent", productConfigItemContent); ContentWorker.renderContentAsText(dispatcher, delegator, productConfigItemContent.getString("contentId"), outWriter, inContext, locale, mimeTypeId, false); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWorker.java Mon Nov 10 18:18:07 2008 @@ -51,7 +51,7 @@ public static final String resource = "ProductUiLabels"; public static final String SEPARATOR = "::"; // cache key separator - public static UtilCache productConfigCache = new UtilCache("product.config", true); // use soft reference to free up memory if needed + public static UtilCache<String, ProductConfigWrapper> productConfigCache = new UtilCache<String, ProductConfigWrapper>("product.config", true); // use soft reference to free up memory if needed public static ProductConfigWrapper getProductConfigWrapper(String productId, String currencyUomId, HttpServletRequest request) { ProductConfigWrapper configWrapper = null; @@ -72,7 +72,7 @@ autoUserLogin); productConfigCache.put(cacheKey, new ProductConfigWrapper(configWrapper)); } else { - configWrapper = new ProductConfigWrapper((ProductConfigWrapper)productConfigCache.get(cacheKey)); + configWrapper = new ProductConfigWrapper(productConfigCache.get(cacheKey)); } } catch(ProductConfigWrapperException we) { configWrapper = null; @@ -85,11 +85,11 @@ public static void fillProductConfigWrapper(ProductConfigWrapper configWrapper, HttpServletRequest request) { int numOfQuestions = configWrapper.getQuestions().size(); for (int k = 0; k < numOfQuestions; k++) { - String[] opts = request.getParameterValues("" + k); + String[] opts = request.getParameterValues(Integer.toString(k)); if (opts == null) { // check for standard item comments - ProductConfigWrapper.ConfigItem question = (ProductConfigWrapper.ConfigItem) configWrapper.getQuestions().get(k); + ProductConfigWrapper.ConfigItem question = configWrapper.getQuestions().get(k); if (question.isStandard()) { int i = 0; while (i <= (question.getOptions().size() -1)) { @@ -123,10 +123,10 @@ // set selected variant products if (UtilValidate.isNotEmpty(option) && (option.hasVirtualComponent())) { - List components = option.getComponents(); + List<GenericValue> components = option.getComponents(); int variantIndex = 0; for (int i = 0; i < components.size(); i++) { - GenericValue component = (GenericValue)components.get(i); + GenericValue component = components.get(i); if (option.isVirtualComponent(component)) { String productParamName = "add_product_id" + k + "_" + cnt + "_" + variantIndex; String selectedProdcutId = request.getParameter(productParamName); @@ -138,7 +138,7 @@ if (ProductWorker.isVirtual((GenericDelegator)request.getAttribute("delegator"), selectedProdcutId)) { if ("VV_FEATURETREE".equals(ProductWorker.getProductvirtualVariantMethod((GenericDelegator)request.getAttribute("delegator"), selectedProdcutId))) { // get the selected features - List <String> selectedFeatures = FastList.newInstance(); + List<String> selectedFeatures = FastList.newInstance(); Enumeration paramNames = request.getParameterNames(); while(paramNames.hasMoreElements()) { String paramName = (String)paramNames.nextElement(); @@ -183,21 +183,21 @@ public static void storeProductConfigWrapper(ProductConfigWrapper configWrapper, GenericDelegator delegator) { if (configWrapper == null || (!configWrapper.isCompleted())) return; String configId = null; - List questions = configWrapper.getQuestions(); - List configsToCheck = FastList.newInstance(); + List<ConfigItem> questions = configWrapper.getQuestions(); + List<GenericValue> configsToCheck = FastList.newInstance(); int selectedOptionSize = 0; for (int i = 0; i < questions.size(); i++) { String configItemId = null; Long sequenceNum = null; - List <ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); - ConfigItem ci = (ConfigItem)questions.get(i); - List options = ci.getOptions(); + List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); + ConfigItem ci = questions.get(i); + List<ConfigOption> options = ci.getOptions(); if (ci.isStandard()) { selectedOptions.addAll(options); } else { - Iterator availOptions = options.iterator(); + Iterator<ConfigOption> availOptions = options.iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { selectedOptions.add(oneOption); } @@ -209,13 +209,13 @@ configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); try { - List <GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum)); - Iterator <GenericValue> configIt = configs.iterator(); + List<GenericValue> configs = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configItemId",configItemId,"sequenceNum", sequenceNum)); + Iterator<GenericValue> configIt = configs.iterator(); while (configIt.hasNext()) { GenericValue productConfigConfig = configIt.next(); - Iterator selOpIt = selectedOptions.iterator(); + Iterator<ConfigOption> selOpIt = selectedOptions.iterator(); while (selOpIt.hasNext()) { - ConfigOption oneOption = (ConfigOption)selOpIt.next(); + ConfigOption oneOption = selOpIt.next(); String configOptionId = oneOption.configOption.getString("configOptionId"); if (productConfigConfig.getString("configOptionId").equals(configOptionId)) { String comments = oneOption.getComments() != null ? oneOption.getComments() : ""; @@ -233,12 +233,12 @@ } } if (UtilValidate.isNotEmpty(configsToCheck)) { - Iterator <GenericValue> ctci = configsToCheck.iterator(); + Iterator<GenericValue> ctci = configsToCheck.iterator(); while (ctci.hasNext()) { GenericValue productConfigConfig = ctci.next(); String tempConfigId = productConfigConfig.getString("configId"); try { - List tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId)); + List<GenericValue> tempResult = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId",tempConfigId)); if (tempResult.size() == selectedOptionSize && configsToCheck.containsAll(tempResult)) { List<GenericValue> configOptionProductOptions = delegator.findByAnd("ConfigOptionProductOption", UtilMisc.toMap("configId",tempConfigId)); if (UtilValidate.isNotEmpty(configOptionProductOptions)) { @@ -247,15 +247,15 @@ for (int i = 0; i < questions.size(); i++) { String configItemId = null; Long sequenceNum = null; - List <ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); - ConfigItem ci = (ConfigItem)questions.get(i); - List options = ci.getOptions(); + List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); + ConfigItem ci = questions.get(i); + List<ConfigOption> options = ci.getOptions(); if (ci.isStandard()) { selectedOptions.addAll(options); } else { - Iterator availOptions = options.iterator(); + Iterator<ConfigOption> availOptions = options.iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { selectedOptions.add(oneOption); } @@ -268,9 +268,9 @@ List<GenericValue> components = anOption.getComponents(); for (GenericValue aComponent : components) { if (anOption.isVirtualComponent(aComponent)) { - Map componentOptions = anOption.getComponentOptions(); + Map<String, String> componentOptions = anOption.getComponentOptions(); String optionProductId = aComponent.getString("productId"); - String optionProductOptionId = (String)componentOptions.get(optionProductId); + String optionProductOptionId = componentOptions.get(optionProductId); String configOptionId = anOption.configOption.getString("configOptionId"); configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); @@ -316,15 +316,15 @@ for (int i = 0; i < questions.size(); i++) { String configItemId = null; Long sequenceNum = null; - List <ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); - ConfigItem ci = (ConfigItem)questions.get(i); - List options = ci.getOptions(); + List<ProductConfigWrapper.ConfigOption> selectedOptions = FastList.newInstance(); + ConfigItem ci = questions.get(i); + List<ConfigOption> options = ci.getOptions(); if (ci.isStandard()) { selectedOptions.addAll(options); } else { - Iterator availOptions = options.iterator(); + Iterator<ConfigOption> availOptions = options.iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { selectedOptions.add(oneOption); } @@ -339,10 +339,10 @@ } configItemId = ci.getConfigItemAssoc().getString("configItemId"); sequenceNum = ci.getConfigItemAssoc().getLong("sequenceNum"); - Iterator selOpIt = selectedOptions.iterator(); + Iterator<ConfigOption> selOpIt = selectedOptions.iterator(); while (selOpIt.hasNext()) { - List toBeStored = FastList.newInstance(); - ConfigOption oneOption = (ConfigOption)selOpIt.next(); + List<GenericValue> toBeStored = FastList.newInstance(); + ConfigOption oneOption = selOpIt.next(); String configOptionId = oneOption.configOption.getString("configOptionId"); String description = oneOption.getComments(); GenericValue productConfigConfig = delegator.makeValue("ProductConfigConfig"); @@ -354,9 +354,9 @@ toBeStored.add(productConfigConfig); if (oneOption.hasVirtualComponent()) { - List components = oneOption.getComponents(); + List<GenericValue> components = oneOption.getComponents(); for (int j = 0; j < components.size(); j++) { - GenericValue component = (GenericValue)components.get(j); + GenericValue component = (GenericValue)components.get(j); if (oneOption.isVirtualComponent(component)) { String componentOption = (String)oneOption.componentOptions.get(component.getString("productId")); GenericValue configOptionProductOption = delegator.makeValue("ConfigOptionProductOption"); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java?rev=712917&r1=712916&r2=712917&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/config/ProductConfigWrapper.java Mon Nov 10 18:18:07 2008 @@ -60,7 +60,7 @@ protected double basePrice = 0.0; protected double defaultPrice = 0.0; protected String configId = null; // Id of persisted ProductConfigWrapper - protected List questions = null; // ProductConfigs + protected List<ConfigItem> questions = null; // ProductConfigs /** Creates a new instance of ProductConfigWrapper */ public ProductConfigWrapper() { @@ -83,7 +83,7 @@ delegator = pcw.delegator; autoUserLogin = pcw.autoUserLogin; for (int i = 0; i < pcw.questions.size(); i++) { - questions.add(new ConfigItem((ConfigItem)pcw.questions.get(i))); + questions.add(new ConfigItem(pcw.questions.get(i))); } } @@ -101,22 +101,21 @@ this.autoUserLogin = autoUserLogin; // get the base price - Map priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId, + Map<String, Object> priceContext = UtilMisc.toMap("product", product, "prodCatalogId", catalogId, "webSiteId", webSiteId, "productStoreId", productStoreId, "currencyUomId", currencyUomId, "autoUserLogin", autoUserLogin); - Map priceMap = dispatcher.runSync("calculateProductPrice", priceContext); + Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", priceContext); Double price = (Double)priceMap.get("price"); if (price != null) { basePrice = price.doubleValue(); } questions = FastList.newInstance(); - List questionsValues = FastList.newInstance(); if (product.getString("productTypeId") != null && product.getString("productTypeId").equals("AGGREGATED")) { - questionsValues = delegator.findByAnd("ProductConfig", UtilMisc.toMap("productId", productId), UtilMisc.toList("sequenceNum")); + List<GenericValue> questionsValues = delegator.findByAnd("ProductConfig", UtilMisc.toMap("productId", productId), UtilMisc.toList("sequenceNum")); questionsValues = EntityUtil.filterByDate(questionsValues); - Iterator questionsValuesIt = questionsValues.iterator(); - Set itemIds = FastSet.newInstance(); + Set<String> itemIds = FastSet.newInstance(); + Iterator<GenericValue> questionsValuesIt = questionsValues.iterator(); while (questionsValuesIt.hasNext()) { - ConfigItem oneQuestion = new ConfigItem((GenericValue)questionsValuesIt.next()); + ConfigItem oneQuestion = new ConfigItem(questionsValuesIt.next()); oneQuestion.setContent(locale, "text/html"); // TODO: mime-type shouldn't be hardcoded if (itemIds.contains(oneQuestion.getConfigItem().getString("configItemId"))) { oneQuestion.setFirst(false); @@ -124,10 +123,10 @@ itemIds.add(oneQuestion.getConfigItem().getString("configItemId")); } questions.add(oneQuestion); - List configOptions = delegator.findByAnd("ProductConfigOption", UtilMisc.toMap("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")), UtilMisc.toList("sequenceNum")); - Iterator configOptionsIt = configOptions.iterator(); + List<GenericValue> configOptions = delegator.findByAnd("ProductConfigOption", UtilMisc.toMap("configItemId", oneQuestion.getConfigItemAssoc().getString("configItemId")), UtilMisc.toList("sequenceNum")); + Iterator<GenericValue> configOptionsIt = configOptions.iterator(); while (configOptionsIt.hasNext()) { - ConfigOption option = new ConfigOption(delegator, dispatcher, (GenericValue)configOptionsIt.next(), oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin); + ConfigOption option = new ConfigOption(delegator, dispatcher, configOptionsIt.next(), oneQuestion, catalogId, webSiteId, currencyUomId, autoUserLogin); oneQuestion.addOption(option); } } @@ -139,11 +138,11 @@ //configure ProductConfigWrapper according to ProductConfigConfig entity if (UtilValidate.isNotEmpty(configId)) { this.configId = configId; - List productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId)); + List<GenericValue> productConfigConfig = delegator.findByAnd("ProductConfigConfig", UtilMisc.toMap("configId", configId)); if (UtilValidate.isNotEmpty(productConfigConfig)) { - Iterator pccIt = productConfigConfig.iterator(); + Iterator<GenericValue> pccIt = productConfigConfig.iterator(); while (pccIt.hasNext()) { - GenericValue pcc =(GenericValue) pccIt.next(); + GenericValue pcc = pccIt.next(); String configItemId = pcc.getString("configItemId"); String configOptionId = pcc.getString("configOptionId"); Long sequenceNum = pcc.getLong("sequenceNum"); @@ -156,11 +155,11 @@ public void setSelected(String configItemId, Long sequenceNum, String configOptionId, String comments) throws Exception { for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); if (ci.configItemAssoc.getString("configItemId").equals(configItemId) && ci.configItemAssoc.getLong("sequenceNum").equals(sequenceNum)) { - List avalOptions = ci.getOptions(); + List<ConfigOption> avalOptions = ci.getOptions(); for (int j = 0; j < avalOptions.size(); j++) { - ConfigOption oneOption = (ConfigOption)avalOptions.get(j); + ConfigOption oneOption = avalOptions.get(j); if (oneOption.configOption.getString("configOptionId").equals(configOptionId)) { setSelected(i, j, comments); break; @@ -172,11 +171,11 @@ public void resetConfig() { for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); if (!ci.isStandard()) { - List options = ci.getOptions(); + List<ConfigOption> options = ci.getOptions(); for (int j = 0; j < options.size(); j++) { - ConfigOption co = (ConfigOption)options.get(j); + ConfigOption co = options.get(j); co.setSelected(false); co.setComments(null); } @@ -187,13 +186,13 @@ public void setDefaultConfig() { resetConfig(); for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); if (ci.isMandatory()) { ConfigOption co = ci.getDefault(); if(co != null){ co.setSelected(true); }else if (ci.getOptions().size() > 0) { - co = (ConfigOption)ci.getOptions().get(0); + co = ci.getOptions().get(0); co.setSelected(true); } } @@ -205,19 +204,19 @@ } public boolean equals(Object obj) { - if (obj == null || !(obj instanceof ProductConfigWrapper)) { + if (!(obj instanceof ProductConfigWrapper)) { return false; } ProductConfigWrapper cw = (ProductConfigWrapper)obj; if (!product.getString("productId").equals(cw.getProduct().getString("productId"))) { return false; } - List cwq = cw.getQuestions(); + List<ConfigItem> cwq = cw.getQuestions(); if (questions.size() != cwq.size()) { return false; } for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); if (!ci.equals(cwq.get(i))) { return false; } @@ -226,10 +225,10 @@ } public String toString() { - return "" + questions; + return questions.toString(); } - public List getQuestions() { + public List<ConfigItem> getQuestions() { return questions; } @@ -238,8 +237,8 @@ } public void setSelected(int question, int option, String comments) throws Exception { - ConfigItem ci = (ConfigItem)questions.get(question); - List avalOptions = ci.getOptions(); + ConfigItem ci = questions.get(question); + List<ConfigOption> avalOptions = ci.getOptions(); if (ci.isSingleChoice()) { for (int j = 0; j < avalOptions.size(); j++) { ConfigOption oneOption = (ConfigOption)avalOptions.get(j); @@ -249,7 +248,7 @@ } ConfigOption theOption = null; if (option >= 0 && option < avalOptions.size()) { - theOption = (ConfigOption)avalOptions.get(option); + theOption = avalOptions.get(option); } if (theOption != null) { theOption.setSelected(true); @@ -260,8 +259,8 @@ public void setSelected(int question, int option, int component, String componentOption) throws Exception { // set variant products ConfigOption theOption = getItemOtion(question, option); - List components = theOption.getComponents(); - GenericValue oneComponent = (GenericValue)components.get(component); + List<GenericValue> components = theOption.getComponents(); + GenericValue oneComponent = components.get(component); if (theOption.isVirtualComponent(oneComponent)) { if (theOption.componentOptions == null) { theOption.componentOptions = FastMap.newInstance(); @@ -274,16 +273,16 @@ } } - public List getSelectedOptions() { - List selectedOptions = FastList.newInstance(); + public List<ConfigOption> getSelectedOptions() { + List<ConfigOption> selectedOptions = FastList.newInstance(); for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); if (ci.isStandard()) { selectedOptions.addAll(ci.getOptions()); } else { - Iterator availOptions = ci.getOptions().iterator(); + Iterator<ConfigOption> availOptions = ci.getOptions().iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { selectedOptions.add(oneOption); } @@ -293,10 +292,10 @@ return selectedOptions; } - public List getDefaultOptions() { - List defaultOptions = FastList.newInstance(); + public List<ConfigOption> getDefaultOptions() { + List<ConfigOption> defaultOptions = FastList.newInstance(); for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); ConfigOption co = ci.getDefault(); if (co != null){ defaultOptions.add(co); @@ -307,9 +306,9 @@ public double getTotalPrice() { double totalPrice = basePrice; - List options = getSelectedOptions(); + List<ConfigOption> options = getSelectedOptions(); for (int i = 0; i < options.size(); i++) { - ConfigOption oneOption = (ConfigOption)options.get(i); + ConfigOption oneOption = options.get(i); totalPrice += oneOption.getPrice(); } return totalPrice; @@ -317,9 +316,9 @@ private void setDefaultPrice() { double totalPrice = basePrice; - List options = getDefaultOptions(); + List<ConfigOption> options = getDefaultOptions(); for (int i = 0; i < options.size(); i++) { - ConfigOption oneOption = (ConfigOption)options.get(i); + ConfigOption oneOption = options.get(i); totalPrice += oneOption.getPrice(); } defaultPrice = totalPrice; @@ -332,11 +331,11 @@ public boolean isCompleted() { boolean completed = true; for (int i = 0; i < questions.size(); i++) { - ConfigItem ci = (ConfigItem)questions.get(i); + ConfigItem ci = questions.get(i); if (!ci.isStandard() && ci.isMandatory()) { - Iterator availOptions = ci.getOptions().iterator(); + Iterator<ConfigOption> availOptions = ci.getOptions().iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { completed = true; break; @@ -354,10 +353,10 @@ public ConfigOption getItemOtion(int itemIndex, int optionIndex) { if (questions.size() > itemIndex) { - ConfigItem ci = (ConfigItem)questions.get(itemIndex); - List options = ci.getOptions(); + ConfigItem ci = questions.get(itemIndex); + List<ConfigOption> options = ci.getOptions(); if (options.size() > optionIndex) { - ConfigOption co = (ConfigOption)options.get(optionIndex); + ConfigOption co = options.get(optionIndex); return co; } } @@ -369,7 +368,7 @@ GenericValue configItem = null; GenericValue configItemAssoc = null; ProductConfigItemContentWrapper content = null; - List options = null; + List<ConfigOption> options = null; boolean first = true; public ConfigItem(GenericValue questionAssoc) throws Exception { @@ -383,7 +382,7 @@ configItemAssoc = GenericValue.create(ci.configItemAssoc); options = FastList.newInstance(); for (int i = 0; i < ci.options.size(); i++) { - options.add(new ConfigOption((ConfigOption)ci.options.get(i))); + options.add(new ConfigOption(ci.options.get(i))); } first = ci.first; content = ci.content; // FIXME: this should be cloned @@ -429,7 +428,7 @@ options.add(option); } - public List getOptions() { + public List<ConfigOption> getOptions() { return options; } @@ -463,9 +462,9 @@ public boolean isSelected() { if (isStandard()) return true; - Iterator availOptions = getOptions().iterator(); + Iterator<ConfigOption> availOptions = getOptions().iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { return true; } @@ -474,9 +473,9 @@ } public ConfigOption getSelected() { - Iterator availOptions = getOptions().iterator(); + Iterator<ConfigOption> availOptions = getOptions().iterator(); while (availOptions.hasNext()) { - ConfigOption oneOption = (ConfigOption)availOptions.next(); + ConfigOption oneOption = availOptions.next(); if (oneOption.isSelected()) { return oneOption; } @@ -487,7 +486,7 @@ public ConfigOption getDefault(){ String defaultConfigOptionId = configItemAssoc.getString("defaultConfigOptionId"); if(UtilValidate.isNotEmpty(defaultConfigOptionId)){ - for(ConfigOption oneOption : (List<ConfigOption>)getOptions()) { + for(ConfigOption oneOption : getOptions()) { String currentConfigOptionId = oneOption.getId(); if (defaultConfigOptionId.compareToIgnoreCase(currentConfigOptionId) == 0 ){ return oneOption; @@ -505,12 +504,12 @@ if (!configItem.getString("configItemId").equals(ci.getConfigItem().getString("configItemId"))) { return false; } - List opts = ci.getOptions(); + List<ConfigOption> opts = ci.getOptions(); if (options.size() != opts.size()) { return false; } for (int i = 0; i < options.size(); i++) { - ConfigOption co = (ConfigOption)options.get(i); + ConfigOption co = options.get(i); if (!co.equals(opts.get(i))) { return false; } @@ -526,8 +525,8 @@ public class ConfigOption implements java.io.Serializable { double optionPrice = 0; Date availabilityDate = null; - List componentList = null; // lists of ProductConfigProduct - Map componentOptions = null; + List<GenericValue> componentList = null; // lists of ProductConfigProduct + Map<String, String> componentOptions = null; GenericValue configOption = null; boolean selected = false; boolean available = true; @@ -538,14 +537,14 @@ configOption = option; parentConfigItem = configItem; componentList = option.getRelated("ConfigOptionProductConfigProduct"); - Iterator componentsIt = componentList.iterator(); + Iterator<GenericValue> componentsIt = componentList.iterator(); while (componentsIt.hasNext()) { double price = 0; - GenericValue oneComponent = (GenericValue)componentsIt.next(); + GenericValue oneComponent = componentsIt.next(); // Get the component's price - Map fieldMap = UtilMisc.toMap("product", oneComponent.getRelatedOne("ProductProduct"), "prodCatalogId", catalogId, "webSiteId", webSiteId, + Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponent.getRelatedOne("ProductProduct"), "prodCatalogId", catalogId, "webSiteId", webSiteId, "currencyUomId", currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", autoUserLogin); - Map priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); + Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); Double componentPrice = (Double) priceMap.get("price"); Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); double mult = 1; @@ -559,7 +558,7 @@ price = componentPrice.doubleValue(); } else { fieldMap.put("productPricePurposeId", "PURCHASE"); - Map purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); + Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); Double purchasePrice = (Double) purchasePriceResultMap.get("price"); if (purchasePrice != null) { price = purchasePrice.doubleValue(); @@ -574,7 +573,7 @@ configOption = GenericValue.create(co.configOption); componentList = FastList.newInstance(); for (int i = 0; i < co.componentList.size(); i++) { - componentList.add(GenericValue.create((GenericValue)co.componentList.get(i))); + componentList.add(GenericValue.create(co.componentList.get(i))); } optionPrice = co.optionPrice; available = co.available; @@ -584,21 +583,21 @@ public void recalculateOptionPrice(ProductConfigWrapper pcw) throws Exception { optionPrice = 0; - Iterator componentsIt = componentList.iterator(); + Iterator<GenericValue> componentsIt = componentList.iterator(); while (componentsIt.hasNext()) { double price = 0; - GenericValue oneComponent = (GenericValue)componentsIt.next(); + GenericValue oneComponent = componentsIt.next(); GenericValue oneComponentProduct = oneComponent.getRelatedOne("ProductProduct"); - String variantProductId = (String)componentOptions.get(oneComponent.getString("productId")); + String variantProductId = componentOptions.get(oneComponent.getString("productId")); if (UtilValidate.isNotEmpty(variantProductId)) { oneComponentProduct = pcw.delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", variantProductId)); } // Get the component's price - Map fieldMap = UtilMisc.toMap("product", oneComponentProduct, "prodCatalogId", pcw.catalogId, "webSiteId", pcw.webSiteId, + Map<String, Object> fieldMap = UtilMisc.toMap("product", oneComponentProduct, "prodCatalogId", pcw.catalogId, "webSiteId", pcw.webSiteId, "currencyUomId", pcw.currencyUomId, "productPricePurposeId", "COMPONENT_PRICE", "autoUserLogin", pcw.autoUserLogin); - Map priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); + Map<String, Object> priceMap = dispatcher.runSync("calculateProductPrice", fieldMap); Double componentPrice = (Double) priceMap.get("price"); Boolean validPriceFound = (Boolean)priceMap.get("validPriceFound"); double mult = 1; @@ -612,7 +611,7 @@ price = componentPrice.doubleValue(); } else { fieldMap.put("productPricePurposeId", "PURCHASE"); - Map purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); + Map<String, Object> purchasePriceResultMap = dispatcher.runSync("calculateProductPrice", fieldMap); Double purchasePrice = (Double) purchasePriceResultMap.get("price"); if (purchasePrice != null) { price = purchasePrice.doubleValue(); @@ -701,11 +700,11 @@ available = newValue; } - public List getComponents() { + public List<GenericValue> getComponents() { return componentList; } - public Map getComponentOptions() { + public Map<String, String> getComponentOptions() { return componentOptions; } |
Free forum by Nabble | Edit this page |