Author: lektran
Date: Sat Dec 22 20:06:56 2007 New Revision: 606532 URL: http://svn.apache.org/viewvc?rev=606532&view=rev Log: Had a look through all the code using ProductAssoc and made sure it was honouring thru dates, plus a few tidy ups along the way Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/editShoppingList.bsh ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomSimpleMethods.xml ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/EditProductBom.bsh ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.bsh ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductUtilServices.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductWorker.java ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.bsh Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java (original) +++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/agreement/AgreementServices.java Sat Dec 22 20:06:56 2007 @@ -102,6 +102,7 @@ List productAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap( "productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT")); + productAssocs = EntityUtil.filterByDate(productAssocs); if (productAssocs.size() > 0) { GenericEntity productAssoc = EntityUtil.getFirst(productAssocs); agreementItems = delegator.findByAndCache("AgreementItemAndProductAppl", UtilMisc.toMap( Modified: ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/editShoppingList.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/editShoppingList.bsh?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/editShoppingList.bsh (original) +++ ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/shoppinglist/editShoppingList.bsh Sat Dec 22 20:06:56 2007 @@ -140,6 +140,7 @@ productVariantAssocs = null; if ("Y".equals(product.getString("isVirtual"))) { productVariantAssocs = product.getRelatedCache("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("sequenceNum")); + productVariantAssocs = EntityUtil.filterByDate(productVariantAssocs); } shoppingListItemData.put("shoppingListItem", shoppingListItem); shoppingListItemData.put("product", product); Modified: ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomSimpleMethods.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomSimpleMethods.xml?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomSimpleMethods.xml (original) +++ ofbiz/trunk/applications/manufacturing/script/org/ofbiz/manufacturing/bom/BomSimpleMethods.xml Sat Dec 22 20:06:56 2007 @@ -51,6 +51,7 @@ <make-value value-name="lookupMap" entity-name="ProductAssoc"/> <set-pk-fields map-name="parameters" value-name="lookupMap"/> <find-by-and entity-name="ProductAssoc" map-name="lookupMap" list-name="assocs"/> + <filter-list-by-date list-name="assocs"/> <iterate entry-name="assoc" list-name="assocs"> <set-service-fields service-name="createBOMAssoc" map-name="assoc" to-map-name="context"/> <set field="context.productId" from-field="parameters.copyToProductId"/> Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMServices.java Sat Dec 22 20:06:56 2007 @@ -35,6 +35,7 @@ import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.order.order.OrderReadHelper; import org.ofbiz.service.DispatchContext; import org.ofbiz.service.GenericServiceException; @@ -140,26 +141,25 @@ // If the product is a variant of a virtual, then the billOfMaterialLevel cannot be // lower than the billOfMaterialLevel of the virtual product. List virtualProducts = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT")); - if (virtualProducts != null) { - int virtualMaxDepth = 0; - Iterator virtualProductsIt = virtualProducts.iterator(); - while (virtualProductsIt.hasNext()) { - int virtualDepth = 0; - GenericValue oneVirtualProductAssoc = (GenericValue)virtualProductsIt.next(); - GenericValue virtualProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", oneVirtualProductAssoc.getString("productId"))); - if (virtualProduct.get("billOfMaterialLevel") != null) { - virtualDepth = virtualProduct.getLong("billOfMaterialLevel").intValue(); - } else { - virtualDepth = 0; - } - if (virtualDepth > virtualMaxDepth) { - virtualMaxDepth = virtualDepth; - } + virtualProducts = EntityUtil.filterByDate(virtualProducts); + int virtualMaxDepth = 0; + Iterator virtualProductsIt = virtualProducts.iterator(); + while (virtualProductsIt.hasNext()) { + int virtualDepth = 0; + GenericValue oneVirtualProductAssoc = (GenericValue)virtualProductsIt.next(); + GenericValue virtualProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", oneVirtualProductAssoc.getString("productId"))); + if (virtualProduct.get("billOfMaterialLevel") != null) { + virtualDepth = virtualProduct.getLong("billOfMaterialLevel").intValue(); + } else { + virtualDepth = 0; } - if (virtualMaxDepth > llc.intValue()) { - llc = new Long(virtualMaxDepth); + if (virtualDepth > virtualMaxDepth) { + virtualMaxDepth = virtualDepth; } } + if (virtualMaxDepth > llc.intValue()) { + llc = new Long(virtualMaxDepth); + } product.set("billOfMaterialLevel", llc); product.store(); if (alsoComponents.booleanValue()) { @@ -182,14 +182,13 @@ } if (alsoVariants.booleanValue()) { List variantProducts = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")); - if (variantProducts != null) { - Iterator variantProductsIt = variantProducts.iterator(); - while (variantProductsIt.hasNext()) { - GenericValue oneVariantProductAssoc = (GenericValue)variantProductsIt.next(); - GenericValue variantProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", oneVariantProductAssoc.getString("productId"))); - variantProduct.set("billOfMaterialLevel", llc); - variantProduct.store(); - } + variantProducts = EntityUtil.filterByDate(variantProducts, true); + Iterator variantProductsIt = variantProducts.iterator(); + while (variantProductsIt.hasNext()) { + GenericValue oneVariantProductAssoc = (GenericValue)variantProductsIt.next(); + GenericValue variantProduct = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", oneVariantProductAssoc.getString("productId"))); + variantProduct.set("billOfMaterialLevel", llc); + variantProduct.store(); } } } catch (Exception e) { Modified: ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java (original) +++ ofbiz/trunk/applications/manufacturing/src/org/ofbiz/manufacturing/bom/BOMTree.java Sat Dec 22 20:06:56 2007 @@ -129,18 +129,16 @@ // product is variant). if (!hasBom(product, inDate)) { List virtualProducts = product.getRelatedByAnd("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")); - if (virtualProducts != null && virtualProducts.size() > 0) { - virtualProducts = EntityUtil.filterByDate(virtualProducts, inDate); - if (virtualProducts != null && virtualProducts.size() > 0) { - GenericValue virtualProduct = (GenericValue)virtualProducts.get(0); - // If the virtual product is manufactured as a different product, - // load the new product - productIdForRules = virtualProduct.getString("productId"); - manufacturedAsProduct = manufacturedAsProduct(virtualProduct.getString("productId"), inDate); - product = delegator.findByPrimaryKey("Product", - UtilMisc.toMap("productId", - (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): virtualProduct.get("productId")))); - } + virtualProducts = EntityUtil.filterByDate(virtualProducts, inDate); + GenericValue virtualProduct = EntityUtil.getFirst(virtualProducts); + if (virtualProduct != null) { + // If the virtual product is manufactured as a different product, + // load the new product + productIdForRules = virtualProduct.getString("productId"); + manufacturedAsProduct = manufacturedAsProduct(virtualProduct.getString("productId"), inDate); + product = delegator.findByPrimaryKey("Product", + UtilMisc.toMap("productId", + (manufacturedAsProduct != null? manufacturedAsProduct.getString("productIdTo"): virtualProduct.get("productId")))); } } if (product == null) return; @@ -173,8 +171,8 @@ "productAssocTypeId", "PRODUCT_MANUFACTURED")); manufacturedAsProducts = EntityUtil.filterByDate(manufacturedAsProducts, inDate); GenericValue manufacturedAsProduct = null; - if (manufacturedAsProducts != null && manufacturedAsProducts.size() > 0) { - manufacturedAsProduct = (GenericValue)manufacturedAsProducts.get(0); + if (UtilValidate.isNotEmpty(manufacturedAsProducts)) { + manufacturedAsProduct = EntityUtil.getFirst(manufacturedAsProducts); } return manufacturedAsProduct; } @@ -182,7 +180,7 @@ private boolean hasBom(GenericValue product, Date inDate) throws GenericEntityException { List children = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", bomTypeId)); children = EntityUtil.filterByDate(children, inDate); - return (children != null && children.size() > 0); + return UtilValidate.isNotEmpty(children); } /** It tells if the current (in-memory) tree representing Modified: ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/EditProductBom.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/EditProductBom.bsh?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/EditProductBom.bsh (original) +++ ofbiz/trunk/applications/manufacturing/webapp/manufacturing/WEB-INF/actions/bom/EditProductBom.bsh Sat Dec 22 20:06:56 2007 @@ -50,7 +50,7 @@ String fromDateStr = request.getParameter("fromDate"); Timestamp fromDate = null; -if (fromDateStr != null && fromDateStr.length() > 0) fromDate = Timestamp.valueOf(fromDateStr); +if (UtilValidate.isNotEmpty(fromDateStr)) fromDate = Timestamp.valueOf(fromDateStr); if (fromDate == null) fromDate = (Timestamp)request.getAttribute("ProductAssocCreateFromDate"); if (fromDate != null) context.put("fromDate", fromDate); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderReadHelper.java Sat Dec 22 20:06:56 2007 @@ -1181,9 +1181,7 @@ GenericValue virtual = null; try { List virtuals = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productIdTo", product.getString("productId"), "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate")); - if (virtuals != null) { - virtuals = EntityUtil.filterByDate(virtuals); - } + virtuals = EntityUtil.filterByDate(virtuals); virtual = EntityUtil.getFirst(virtuals); } catch (GenericEntityException e) { Debug.logError(e, "Problem getting virtual product"); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java Sat Dec 22 20:06:56 2007 @@ -414,29 +414,28 @@ new EntityExpr(new EntityExpr("productId", EntityOperator.EQUALS, productId), EntityOperator.OR, new EntityExpr("productIdTo", EntityOperator.EQUALS, productId)), new EntityExpr("productAssocTypeId", EntityOperator.EQUALS, "PRODUCT_INCOMPATABLE")), EntityOperator.AND); productAssocs = delegator.findByCondition("ProductAssoc", cond, null, null); + productAssocs = EntityUtil.filterByDate(productAssocs); List productList = FastList.newInstance(); - if (productAssocs != null) { - Iterator iter = productAssocs.iterator(); - while (iter.hasNext()) { - GenericValue productAssoc = (GenericValue) iter.next(); - if (productId.equals(productAssoc.getString("productId"))) { - productList.add(productAssoc.getString("productIdTo")); - continue; - } - if (productId.equals(productAssoc.getString("productIdTo"))) { - productList.add(productAssoc.getString("productId")); - continue; - } - } - Iterator sciIter = cart.iterator(); - while (sciIter.hasNext()) { - ShoppingCartItem sci = (ShoppingCartItem) sciIter.next(); - if (productList.contains(sci.getProductId())) { - try { - cart.removeCartItem(sci, dispatcher); - } catch (CartItemModifyException e) { - Debug.logError(e.getMessage(), module); - } + Iterator iter = productAssocs.iterator(); + while (iter.hasNext()) { + GenericValue productAssoc = (GenericValue) iter.next(); + if (productId.equals(productAssoc.getString("productId"))) { + productList.add(productAssoc.getString("productIdTo")); + continue; + } + if (productId.equals(productAssoc.getString("productIdTo"))) { + productList.add(productAssoc.getString("productId")); + continue; + } + } + Iterator sciIter = cart.iterator(); + while (sciIter.hasNext()) { + ShoppingCartItem sci = (ShoppingCartItem) sciIter.next(); + if (productList.contains(sci.getProductId())) { + try { + cart.removeCartItem(sci, dispatcher); + } catch (CartItemModifyException e) { + Debug.logError(e.getMessage(), module); } } } Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductDisplayWorker.java Sat Dec 22 20:06:56 2007 @@ -70,7 +70,7 @@ // Collection upgradeProducts = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productId", item.getProductId(), "productAssocTypeId", "PRODUCT_UPGRADE"), null); List complementProducts = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productId", item.getProductId(), "productAssocTypeId", "PRODUCT_COMPLEMENT"), null); // since ProductAssoc records have a fromDate and thruDate, we can filter by now so that only assocs in the date range are included - complementProducts = EntityUtil.filterByDate(complementProducts, true); + complementProducts = EntityUtil.filterByDate(complementProducts); List productsCategories = delegator.findByAndCache("ProductCategoryMember", UtilMisc.toMap("productId", item.getProductId()), null); productsCategories = EntityUtil.filterByDate(productsCategories, true); Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java (original) +++ ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/product/ProductPromoWorker.java Sat Dec 22 20:06:56 2007 @@ -1104,7 +1104,7 @@ } if ("Y".equals(product.getString("isVirtual"))) { List productAssocs = EntityUtil.filterByDate(product.getRelatedCache("MainProductAssoc", - UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("sequenceNum")), true); + UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("sequenceNum"))); Iterator productAssocIter = productAssocs.iterator(); while (productAssocIter.hasNext()) { GenericValue productAssoc = (GenericValue) productAssocIter.next(); Modified: ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh (original) +++ ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/order/shipGroups.bsh Sat Dec 22 20:06:56 2007 @@ -39,7 +39,7 @@ FastList expandProductGroup(product, quantityInGroup, quantityShipped, quantityOpen, assocType) { sublines = FastList.newInstance(); associations = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", assocType)); - associations = EntityUtil.filterByDate( associations ); + associations = EntityUtil.filterByDate(associations); for (iter = associations.iterator(); iter.hasNext(); ) { association = iter.next(); line = FastMap.newInstance(); Modified: ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.bsh?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.bsh (original) +++ ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/editShoppingList.bsh Sat Dec 22 20:06:56 2007 @@ -99,6 +99,7 @@ productVariantAssocs = null; if ("Y".equals(product.getString("isVirtual"))) { productVariantAssocs = product.getRelatedCache("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("sequenceNum")); + productVariantAssocs = EntityUtil.filterByDate(productVariantAssocs); } shoppingListItemData.put("shoppingListItem", shoppingListItem); Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/catalog/CatalogServices.xml Sat Dec 22 20:06:56 2007 @@ -311,58 +311,58 @@ <!-- get related assoc product --> <get-related-one relation-name="Product" value-name="productCategoryMember" to-value-name="product"/> <if-compare operator="equals" field-name="isVirtual" value="Y" map-name="product"> - <!-- log level="info" message = "Virtual product =====${productCategoryMember.productId}"/ --> - <set field="virtualProductContext.productId" from-field="product.productId"/> - <set field="virtualProductContext.productAssocTypeId" value="PRODUCT_VARIANT"/> - <find-by-and entity-name="ProductAssoc" map-name="virtualProductContext" list-name="variantProducts"/> - - <if-not-empty field-name="variantProducts"> - <iterate entry-name="variantProduct" list-name="variantProducts"> - <!-- log level="info" message = "Variant product =====${variantProduct.productIdTo}"/ --> - <set field="variantProductContext.productId" from-field="variantProduct.productIdTo"/> - <call-service service-name="checkImageUrlForProduct" in-map-name="variantProductContext"> - <result-to-field result-name="filesImageMap" field-name="filesImageMap"/> - </call-service> - <if-not-empty field-name="filesImageMap"> - <if-not-empty field-name="smallImageUrl" map-name="filesImageMap.smallImageUrlMap"> - <if-compare value="Y" field-name="filesImageMap.smallImageUrlMap.isExists" operator="equals"> - <field-to-list list-name="fileExists" field-name="smallImageUrl" map-name="filesImageMap.smallImageUrlMap"/> - <else> - <field-to-list list-name="fileNotExists" field-name="smallImageUrl" map-name="filesImageMap.smallImageUrlMap"/> - </else> - </if-compare> - </if-not-empty> + <!-- log level="info" message = "Virtual product =====${productCategoryMember.productId}"/ --> + <set field="virtualProductContext.productId" from-field="product.productId"/> + <set field="virtualProductContext.productAssocTypeId" value="PRODUCT_VARIANT"/> + <find-by-and entity-name="ProductAssoc" map-name="virtualProductContext" list-name="variantProducts"/> + <filter-list-by-date list-name="variantProducts"/> + <if-not-empty field-name="variantProducts"> + <iterate entry-name="variantProduct" list-name="variantProducts"> + <!-- log level="info" message = "Variant product =====${variantProduct.productIdTo}"/ --> + <set field="variantProductContext.productId" from-field="variantProduct.productIdTo"/> + <call-service service-name="checkImageUrlForProduct" in-map-name="variantProductContext"> + <result-to-field result-name="filesImageMap" field-name="filesImageMap"/> + </call-service> + <if-not-empty field-name="filesImageMap"> + <if-not-empty field-name="smallImageUrl" map-name="filesImageMap.smallImageUrlMap"> + <if-compare value="Y" field-name="filesImageMap.smallImageUrlMap.isExists" operator="equals"> + <field-to-list list-name="fileExists" field-name="smallImageUrl" map-name="filesImageMap.smallImageUrlMap"/> + <else> + <field-to-list list-name="fileNotExists" field-name="smallImageUrl" map-name="filesImageMap.smallImageUrlMap"/> + </else> + </if-compare> + </if-not-empty> - <if-not-empty field-name="mediumImageUrl" map-name="filesImageMap.mediumImageUrlMap"> - <if-compare value="Y" field-name="filesImageMap.mediumImageUrlMap.isExists" operator="equals"> - <field-to-list list-name="fileExists" field-name="mediumImageUrl" map-name="filesImageMap.mediumImageUrlMap"/> - <else> - <field-to-list list-name="fileNotExists" field-name="mediumImageUrl" map-name="filesImageMap.mediumImageUrlMap"/> - </else> - </if-compare> - </if-not-empty> + <if-not-empty field-name="mediumImageUrl" map-name="filesImageMap.mediumImageUrlMap"> + <if-compare value="Y" field-name="filesImageMap.mediumImageUrlMap.isExists" operator="equals"> + <field-to-list list-name="fileExists" field-name="mediumImageUrl" map-name="filesImageMap.mediumImageUrlMap"/> + <else> + <field-to-list list-name="fileNotExists" field-name="mediumImageUrl" map-name="filesImageMap.mediumImageUrlMap"/> + </else> + </if-compare> + </if-not-empty> - <if-not-empty field-name="largeImageUrl" map-name="filesImageMap.largeImageUrlMap"> - <if-compare value="Y" field-name="filesImageMap.largeImageUrlMap.isExists" operator="equals"> - <field-to-list list-name="fileExists" field-name="largeImageUrl" map-name="filesImageMap.largeImageUrlMap"/> - <else> - <field-to-list list-name="fileNotExists" field-name="largeImageUrl" map-name="filesImageMap.largeImageUrlMap"/> - </else> - </if-compare> - </if-not-empty> + <if-not-empty field-name="largeImageUrl" map-name="filesImageMap.largeImageUrlMap"> + <if-compare value="Y" field-name="filesImageMap.largeImageUrlMap.isExists" operator="equals"> + <field-to-list list-name="fileExists" field-name="largeImageUrl" map-name="filesImageMap.largeImageUrlMap"/> + <else> + <field-to-list list-name="fileNotExists" field-name="largeImageUrl" map-name="filesImageMap.largeImageUrlMap"/> + </else> + </if-compare> + </if-not-empty> - <if-not-empty field-name="detailImageUrl" map-name="filesImageMap.detailImageUrlMap"> - <if-compare value="Y" field-name="filesImageMap.detailImageUrl.isExists" operator="equals"> - <field-to-list list-name="fileExists" field-name="detailImageUrl" map-name="filesImageMap.detailImageUrl"/> - <else> - <field-to-list list-name="fileNotExists" field-name="detailImageUrl" map-name="filesImageMap.detailImageUrl"/> - </else> - </if-compare> - </if-not-empty> + <if-not-empty field-name="detailImageUrl" map-name="filesImageMap.detailImageUrlMap"> + <if-compare value="Y" field-name="filesImageMap.detailImageUrl.isExists" operator="equals"> + <field-to-list list-name="fileExists" field-name="detailImageUrl" map-name="filesImageMap.detailImageUrl"/> + <else> + <field-to-list list-name="fileNotExists" field-name="detailImageUrl" map-name="filesImageMap.detailImageUrl"/> + </else> + </if-compare> + </if-not-empty> - </if-not-empty> - </iterate> - </if-not-empty> + </if-not-empty> + </iterate> + </if-not-empty> </if-compare> </iterate> <field-to-result field-name="fileExists" result-name="fileExists"/> Modified: ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml (original) +++ ofbiz/trunk/applications/product/script/org/ofbiz/product/product/ProductServices.xml Sat Dec 22 20:06:56 2007 @@ -142,6 +142,7 @@ <!-- get all productAssocs, then get the actual product to update --> <find-by-and entity-name="ProductAssoc" map-name="variantProductAssocMap" list-name="variantProductAssocs"/> + <filter-list-by-date list-name="variantProductAssocs"/> <iterate entry-name="variantProductAssoc" list-name="variantProductAssocs"> <clear-field field-name="variantProduct"/> <entity-one entity-name="Product" value-name="variantProduct" auto-field-map="false"> @@ -593,6 +594,7 @@ <set from-field="parameters.virtualProductId" field="variantsFindContext.productId"/> <set value="PRODUCT_VARIANT" field="variantsFindContext.productAssocTypeId"/> <find-by-and entity-name="ProductAssoc" map-name="variantsFindContext" list-name="variants"/> + <filter-list-by-date list-name="variants"/> <iterate entry-name="newProduct" list-name="variants"> <set from-field="newProduct.productIdTo" field="productVariantContext.productId"/> <!-- if requested, duplicate related data --> Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/feature/ProductFeatureServices.java Sat Dec 22 20:06:56 2007 @@ -28,6 +28,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; @@ -137,37 +138,35 @@ * see if it has every single feature in the list of productFeatureAppls as a STANDARD_FEATURE. If so, then * it qualifies and add it to the list of existingVariantProductIds. */ - List productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")), true); - if (productAssocs != null && productAssocs.size() > 0) { - Iterator productAssocIter = productAssocs.iterator(); - while (productAssocIter.hasNext()) { - GenericEntity productAssoc = (GenericEntity) productAssocIter.next(); - - //for each associated product, if it has all standard features, display it's productId - boolean hasAllFeatures = true; - Iterator curProductFeatureAndApplIter = curProductFeatureAndAppls.iterator(); - while (curProductFeatureAndApplIter.hasNext()) { - String productFeatureAndAppl = (String) curProductFeatureAndApplIter.next(); - Map findByMap = UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), - "productFeatureId", productFeatureAndAppl, - "productFeatureApplTypeId", "STANDARD_FEATURE"); - - //Debug.log("Using findByMap: " + findByMap); - - List standardProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", findByMap), true); - if (standardProductFeatureAndAppls == null || standardProductFeatureAndAppls.size() == 0) { - // Debug.log("Does NOT have this standard feature"); - hasAllFeatures = false; - break; - } else { - // Debug.log("DOES have this standard feature"); - } + List productAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"))); + Iterator productAssocIter = productAssocs.iterator(); + while (productAssocIter.hasNext()) { + GenericEntity productAssoc = (GenericEntity) productAssocIter.next(); + + //for each associated product, if it has all standard features, display it's productId + boolean hasAllFeatures = true; + Iterator curProductFeatureAndApplIter = curProductFeatureAndAppls.iterator(); + while (curProductFeatureAndApplIter.hasNext()) { + String productFeatureAndAppl = (String) curProductFeatureAndApplIter.next(); + Map findByMap = UtilMisc.toMap("productId", productAssoc.getString("productIdTo"), + "productFeatureId", productFeatureAndAppl, + "productFeatureApplTypeId", "STANDARD_FEATURE"); + + //Debug.log("Using findByMap: " + findByMap); + + List standardProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", findByMap)); + if (UtilValidate.isEmpty(standardProductFeatureAndAppls)) { + // Debug.log("Does NOT have this standard feature"); + hasAllFeatures = false; + break; + } else { + // Debug.log("DOES have this standard feature"); } + } - if (hasAllFeatures) { - // add to list of existing variants: productId=productAssoc.productIdTo - existingVariantProductIds.add(productAssoc.get("productIdTo")); - } + if (hasAllFeatures) { + // add to list of existing variants: productId=productAssoc.productIdTo + existingVariantProductIds.add(productAssoc.get("productIdTo")); } } results = ServiceUtil.returnSuccess(); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java Sat Dec 22 20:06:56 2007 @@ -150,9 +150,11 @@ // Variant Product IDs if ("Y".equals(product.getString("isVirtual"))) { if (!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.Variant.Product.productId", "0"))) { - Iterator variantProductAssocs = UtilMisc.toIterator(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"))); - while (variantProductAssocs != null && variantProductAssocs.hasNext()) { - GenericValue variantProductAssoc = (GenericValue) variantProductAssocs.next(); + List variantProductAssocs = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")); + variantProductAssocs = EntityUtil.filterByDate(variantProductAssocs); + Iterator variantProductAssocsIt = variantProductAssocs.iterator(); + while (variantProductAssocsIt.hasNext()) { + GenericValue variantProductAssoc = (GenericValue) variantProductAssocsIt.next(); int weight = 1; try { weight = Integer.parseInt(UtilProperties.getPropertyValue("prodsearch", "index.weight.Variant.Product.productId", "0")); Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java Sat Dec 22 20:06:56 2007 @@ -685,6 +685,7 @@ boolean foundFeatureOnVariant = false; // get/check all the variants List variantAssocs = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")); + variantAssocs = EntityUtil.filterByDate(variantAssocs); List variants = EntityUtil.getRelated("AssocProduct", variantAssocs); Iterator variantIter = variants.iterator(); while (!foundFeatureOnVariant && variantIter.hasNext()) { @@ -771,6 +772,7 @@ GenericValue product = delegator.findByPrimaryKey("Product", UtilMisc.toMap("productId", productId)); // get all the variants List variantAssocs = product.getRelatedByAnd("MainProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")); + variantAssocs = EntityUtil.filterByDate(variantAssocs); List variants = EntityUtil.getRelated("AssocProduct", variantAssocs); Iterator variantIter = variants.iterator(); while (variantIter.hasNext()) { Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductServices.java Sat Dec 22 20:06:56 2007 @@ -381,18 +381,15 @@ if (product.get("isVariant") != null && product.getString("isVariant").equalsIgnoreCase("Y")) { List c = product.getRelatedByAndCache("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")); - - if (c != null) { - //if (Debug.infoOn()) Debug.logInfo("Found related: " + c, module); - c = EntityUtil.filterByDate(c, true); - //if (Debug.infoOn()) Debug.logInfo("Found Filtered related: " + c, module); - if (c.size() > 0) { - GenericValue asV = (GenericValue) c.iterator().next(); - - //if (Debug.infoOn()) Debug.logInfo("ASV: " + asV, module); - mainProduct = asV.getRelatedOneCache("MainProduct"); - //if (Debug.infoOn()) Debug.logInfo("Main product = " + mainProduct, module); - } + //if (Debug.infoOn()) Debug.logInfo("Found related: " + c, module); + c = EntityUtil.filterByDate(c); + //if (Debug.infoOn()) Debug.logInfo("Found Filtered related: " + c, module); + if (c.size() > 0) { + GenericValue asV = (GenericValue) c.iterator().next(); + + //if (Debug.infoOn()) Debug.logInfo("ASV: " + asV, module); + mainProduct = asV.getRelatedOneCache("MainProduct"); + //if (Debug.infoOn()) Debug.logInfo("Main product = " + mainProduct, module); } } result.put("product", mainProduct); @@ -469,7 +466,7 @@ productAssocs = product.getRelatedCache("AssocProductAssoc", UtilMisc.toMap("productAssocTypeId", type), UtilMisc.toList("sequenceNum")); } // filter the list by date - productAssocs = EntityUtil.filterByDate(productAssocs, true); + productAssocs = EntityUtil.filterByDate(productAssocs); // first check to see if there is a view allow category and if these producta are in it... if (checkViewAllow && prodCatalogId != null && productAssocs != null && productAssocs.size() > 0) { String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, prodCatalogId); 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=606532&r1=606531&r2=606532&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 Sat Dec 22 20:06:56 2007 @@ -60,7 +60,7 @@ public static final String module = ProductUtilServices.class.getName(); public static final String resource = "ProductUiLabels"; - /** First expirt all ProductAssocs for all disc variants, then disc all virtuals that have all expired variant ProductAssocs */ + /** 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) { GenericDelegator delegator = dctx.getDelegator(); Timestamp nowTimestamp = UtilDateTime.nowTimestamp(); @@ -83,7 +83,7 @@ continue; } List passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", virtualProductId, "productIdTo", productOne.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT")); - passocList = EntityUtil.filterByDate(passocList, nowTimestamp); + passocList = EntityUtil.filterByDate(passocList); if (passocList.size() > 0) { Iterator passocIter = passocList.iterator(); while (passocIter.hasNext()) { @@ -110,7 +110,7 @@ int numSoFar = 0; while ((product = (GenericValue) eli.next()) != null) { List passocList = delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", product.get("productId"), "productAssocTypeId", "PRODUCT_VARIANT")); - passocList = EntityUtil.filterByDate(passocList, nowTimestamp); + passocList = EntityUtil.filterByDate(passocList); if (passocList.size() == 0) { product.set("salesDiscontinuationDate", nowTimestamp); @@ -269,6 +269,7 @@ String productId = value.getString("productId"); List 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) { Debug.logInfo("Virtual product with ID " + productId + " should have 1 assoc, has " + paList.size(), module); @@ -305,7 +306,7 @@ // has only one valid variant String productId = value.getString("productId"); - List paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT")), nowTimestamp); + List 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) { @@ -357,7 +358,7 @@ 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")), nowTimestamp); + List paList = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_VARIANT"))); if (paList.size() > 1) { Map messageMap = UtilMisc.toMap("productId", productId); errMsg = UtilProperties.getMessage(resource,"productutilservices.found_more_than_one_valid_variant_for_virtual_ID", messageMap, locale); @@ -523,7 +524,7 @@ 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")), nowTimestamp); + List 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")); 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=606532&r1=606531&r2=606532&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 Sat Dec 22 20:06:56 2007 @@ -189,7 +189,7 @@ public static List getVariantVirtualAssocs(GenericValue variantProduct) throws GenericEntityException { if (variantProduct != null && "Y".equals(variantProduct.getString("isVariant"))) { List productAssocs = EntityUtil.filterByDate(variantProduct.getRelatedByAndCache("AssocProductAssoc", - UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT")), true); + UtilMisc.toMap("productAssocTypeId", "PRODUCT_VARIANT"))); return productAssocs; } return null; @@ -278,10 +278,10 @@ 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 - upgradeProducts = EntityUtil.filterByDate(upgradeProducts, true); - complementProducts = EntityUtil.filterByDate(complementProducts, true); - obsolescenceProducts = EntityUtil.filterByDate(obsolescenceProducts, true); - obsoleteByProducts = EntityUtil.filterByDate(obsoleteByProducts, true); + upgradeProducts = EntityUtil.filterByDate(upgradeProducts); + complementProducts = EntityUtil.filterByDate(complementProducts); + obsolescenceProducts = EntityUtil.filterByDate(obsolescenceProducts); + obsoleteByProducts = EntityUtil.filterByDate(obsoleteByProducts); if (upgradeProducts != null && upgradeProducts.size() > 0) pageContext.setAttribute(assocPrefix + "upgrade", upgradeProducts); @@ -657,13 +657,13 @@ try { List virtualProductAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_VARIANT"), UtilMisc.toList("-fromDate")); - virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs, true); - if (virtualProductAssocs == null || virtualProductAssocs.size() == 0) { + virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs); + if (UtilValidate.isEmpty(virtualProductAssocs)) { //okay, not a variant, try a UNIQUE_ITEM virtualProductAssocs = delegator.findByAndCache("ProductAssoc", UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "UNIQUE_ITEM"), UtilMisc.toList("-fromDate")); - virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs, true); + virtualProductAssocs = EntityUtil.filterByDate(virtualProductAssocs); } - if (virtualProductAssocs != null && virtualProductAssocs.size() > 0) { + if (UtilValidate.isNotEmpty(virtualProductAssocs)) { //found one, set this first as the parent product GenericValue productAssoc = EntityUtil.getFirst(virtualProductAssocs); _parentProduct = productAssoc.getRelatedOneCache("MainProduct"); @@ -826,7 +826,7 @@ // find associated refurb items, we want serial number for main item or any refurb items too List refubProductAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", - UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_REFURB")), true); + UtilMisc.toMap("productId", productId, "productAssocTypeId", "PRODUCT_REFURB"))); Iterator refubProductAssocIter = refubProductAssocs.iterator(); while (refubProductAssocIter.hasNext()) { GenericValue refubProductAssoc = (GenericValue) refubProductAssocIter.next(); @@ -835,7 +835,7 @@ // see if this is a refurb productId to, and find product(s) it is a refurb of List refubProductToAssocs = EntityUtil.filterByDate(delegator.findByAnd("ProductAssoc", - UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB")), true); + UtilMisc.toMap("productIdTo", productId, "productAssocTypeId", "PRODUCT_REFURB"))); Iterator refubProductToAssocIter = refubProductToAssocs.iterator(); while (refubProductToAssocIter.hasNext()) { GenericValue refubProductToAssoc = (GenericValue) refubProductToAssocIter.next(); Modified: ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.bsh URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.bsh?rev=606532&r1=606531&r2=606532&view=diff ============================================================================== --- ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.bsh (original) +++ ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/product/EditProductAssoc.bsh Sat Dec 22 20:06:56 2007 @@ -46,7 +46,7 @@ fromDateStr = request.getParameter("FROM_DATE"); Timestamp fromDate = null; -if (fromDateStr != null && fromDateStr.length() > 0) fromDate = Timestamp.valueOf(fromDateStr); +if (UtilValidate.isNotEmpty(fromDateStr.length())) fromDate = Timestamp.valueOf(fromDateStr); if (fromDate == null) fromDate = (Timestamp)request.getAttribute("ProductAssocCreateFromDate"); if (fromDate != null) context.put("fromDate", fromDate); |
Free forum by Nabble | Edit this page |