Author: sichen
Date: Fri Mar 2 11:51:35 2007 New Revision: 513916 URL: http://svn.apache.org/viewvc?view=rev&rev=513916 Log: Added the capability to filter product searches by Product.introductionDate and Product.salesDiscontinuationDate. Adding the AVAILABILITY_FILTER="true" form parameter results in the addition of an AvailabilityDateConstraint object to the ProductSearchSession. Not currently used in any forms. Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=513916&r1=513915&r2=513916 ============================================================================== --- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original) +++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Fri Mar 2 11:51:35 2007 @@ -585,6 +585,7 @@ ProductFeatureType=Feature Type ProductFeatures=Features ProductFile=File +ProductFilterByAvailabilityDates=Filtered by Introduction and Sales Discontinuation Dates ProductFindLocation=Find Location ProductFindLocationsFor=Find Locations for ProductFindOrdersToPick=Find Orders to pick Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java?view=diff&rev=513916&r1=513915&r2=513916 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Fri Mar 2 11:51:35 2007 @@ -1178,6 +1178,34 @@ } } + public static class AvailabilityDateConstraint extends ProductSearchConstraint { + public static final String constraintName = "AvailabilityDate"; + + public AvailabilityDateConstraint() { + } + + public void addConstraint(ProductSearchContext productSearchContext) { + productSearchContext.dynamicViewEntity.addAlias("PROD", "prodIntroductionDate", "introductionDate", null, null, null, null); + productSearchContext.entityConditionList.add(new EntityExpr(new EntityExpr("prodIntroductionDate", EntityOperator.EQUALS, null), EntityOperator.OR, new EntityExpr("prodIntroductionDate", EntityOperator.LESS_THAN_EQUAL_TO, productSearchContext.nowTimestamp))); + productSearchContext.dynamicViewEntity.addAlias("PROD", "prodSalesDiscontinuationDate", "salesDiscontinuationDate", null, null, null, null); + productSearchContext.entityConditionList.add(new EntityExpr(new EntityExpr("prodSalesDiscontinuationDate", EntityOperator.EQUALS, null), EntityOperator.OR, new EntityExpr("prodSalesDiscontinuationDate", EntityOperator.GREATER_THAN, productSearchContext.nowTimestamp))); + productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", ""))); + } + + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { + return UtilProperties.getMessage(resource, "ProductFilterByAvailabilityDates", locale); + } + + public boolean equals(Object obj) { + ProductSearchConstraint psc = (ProductSearchConstraint) obj; + if (psc instanceof AvailabilityDateConstraint) { + return true; + } else { + return false; + } + } + } + // ====================================================================== // Result Sort Classes // ====================================================================== Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?view=diff&rev=513916&r1=513915&r2=513916 ============================================================================== --- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original) +++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Fri Mar 2 11:51:35 2007 @@ -543,6 +543,11 @@ // not consider this a change for now, shouldn't change often: constraintsChanged = true; } + if ("true".equalsIgnoreCase((String) parameters.get("AVAILABILITY_FILTER"))) { + searchAddConstraint(new ProductSearch.AvailabilityDateConstraint(), session); + constraintsChanged = true; + } + String prodCatalogId = CatalogWorker.getCurrentCatalogId(request); String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, prodCatalogId); if (UtilValidate.isNotEmpty(viewProductCategoryId)) { |
Free forum by Nabble | Edit this page |