svn commit: r496617 - in /ofbiz/trunk/applications/product: config/ data/ entitydef/ src/org/ofbiz/product/product/ webapp/catalog/store/

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

svn commit: r496617 - in /ofbiz/trunk/applications/product: config/ data/ entitydef/ src/org/ofbiz/product/product/ webapp/catalog/store/

jonesde
Author: jonesde
Date: Tue Jan 16 00:22:08 2007
New Revision: 496617

URL: http://svn.apache.org/viewvc?view=rev&rev=496617
Log:
Added ExcludeVariants constraint for the ProductSearch stuff, plus an indicator on the ProductStore to turn it on an off; also made small change in the way the auto-add of the view allow constraint works; did a few brief tests and all seems to be working fine

Modified:
    ofbiz/trunk/applications/product/config/ProductUiLabels.properties
    ofbiz/trunk/applications/product/data/ProductTypeData.xml
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java
    ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml

Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=496617&r1=496616&r2=496617
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Tue Jan 16 00:22:08 2007
@@ -1,7 +1,4 @@
 #####################################################################
-#
-# Copyright 2001-2006 The Apache Software Foundation
-#
 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
 # use this file except in compliance with the License. You may obtain a copy of
 # the License at
@@ -516,6 +513,7 @@
 ProductEstimatedStartArrive=Estimated (Start-Arrive)
 ProductExcludeGeoMessage=Displays only if ship-to is not in this geo
 ProductExcludeGeo=Exclude Geo
+ProductExcludeVariants=Exclude Variants
 ProductExcGeo=Exc Geo
 ProductExcludeFeatureMessage=Displays only if all items have no features in this group
 ProductExcludeFeature=Exclude Feature Group

Modified: ofbiz/trunk/applications/product/data/ProductTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/data/ProductTypeData.xml?view=diff&rev=496617&r1=496616&r2=496617
==============================================================================
--- ofbiz/trunk/applications/product/data/ProductTypeData.xml (original)
+++ ofbiz/trunk/applications/product/data/ProductTypeData.xml Tue Jan 16 00:22:08 2007
@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-Copyright 2001-2006 The Apache Software Foundation
-
 Licensed under the Apache License, Version 2.0 (the "License"); you may not
 use this file except in compliance with the License. You may obtain a copy of
 the License at

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?view=diff&rev=496617&r1=496616&r2=496617
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Tue Jan 16 00:22:08 2007
@@ -3081,6 +3081,7 @@
       <field name="vatTaxAuthPartyId" type="id"></field>
       <field name="enableAutoSuggestionList" type="indicator"><description>The auto-suggestion list is a special ShoppingList that the addSuggestionsToShoppingList service will maintain for cross-sells of ordered items.</description></field>
       <field name="enableDigProdUpload" type="indicator"></field>
+      <field name="prodSearchExcludeVariants" type="indicator"><description>default Y; if set to Y an additional constraint will of isVariant!=Y will be added to all product searches for the store</description></field>
       <field name="digProdUploadCategoryId" type="id"></field>
       <field name="autoOrderCcTryExp" type="indicator"><description>For auto-orders try other Credit Card expiration dates (if date is wrong or general failure where type not known)?</description></field>
       <field name="autoOrderCcTryOtherCards" type="indicator"><description>For auto-orders try other Credit Cards for the customer?</description></field>

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=496617&r1=496616&r2=496617
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Tue Jan 16 00:22:08 2007
@@ -1086,6 +1086,34 @@
         }
     }
 
+    public static class ExcludeVariantsConstraint extends ProductSearchConstraint {
+        public static final String constraintName = "ExcludeVariants";
+
+        public ExcludeVariantsConstraint() {
+        }
+
+        public void addConstraint(ProductSearchContext productSearchContext) {
+            productSearchContext.dynamicViewEntity.addAlias("PROD", "prodIsVariant", "isVariant", null, null, null, null);
+            productSearchContext.entityConditionList.add(new EntityExpr("prodIsVariant", EntityOperator.NOT_EQUAL, "Y"));
+
+            // add in productSearchConstraint, don't worry about the productSearchResultId or constraintSeqId, those will be fill in later
+            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, "ProductExcludeVariants", locale);
+        }
+
+        public boolean equals(Object obj) {
+            ProductSearchConstraint psc = (ProductSearchConstraint) obj;
+            if (psc instanceof ExcludeVariantsConstraint) {
+                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=496617&r1=496616&r2=496617
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Tue Jan 16 00:22:08 2007
@@ -33,6 +33,8 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
@@ -89,7 +91,7 @@
         public static void addConstraint(ProductSearchConstraint productSearchConstraint, HttpSession session) {
             ProductSearchOptions productSearchOptions = getProductSearchOptions(session);
             if (productSearchOptions.constraintList == null) {
-                productSearchOptions.constraintList = new LinkedList();
+                productSearchOptions.constraintList = FastList.newInstance();
             }
             if (!productSearchOptions.constraintList.contains(productSearchConstraint)) {
                 productSearchOptions.constraintList.add(productSearchConstraint);
@@ -152,7 +154,7 @@
 
         public List searchGetConstraintStrings(boolean detailed, GenericDelegator delegator, Locale locale) {
             List productSearchConstraintList = this.getConstraintList();
-            List constraintStrings = new ArrayList();
+            List constraintStrings = FastList.newInstance();
             if (productSearchConstraintList == null) {
                 return constraintStrings;
             }
@@ -331,8 +333,6 @@
             return new ArrayList();
         }
 
-        // make sure the view allow category is included
-        productSearchConstraintList = ensureViewAllowConstraint(productSearchConstraintList, prodCatalogId, delegator);
         ResultSortOrder resultSortOrder = productSearchOptions.getResultSortOrder();
 
         // if the search options have changed since the last search, put at the beginning of the options history list
@@ -341,19 +341,6 @@
         return ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
     }
 
-    public static List ensureViewAllowConstraint(List productSearchConstraintList, String prodCatalogId, GenericDelegator delegator) {
-        String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, prodCatalogId);
-        if (UtilValidate.isNotEmpty(viewProductCategoryId)) {
-            ProductSearchConstraint viewAllowConstraint = new CategoryConstraint(viewProductCategoryId, true);
-            if (!productSearchConstraintList.contains(viewAllowConstraint)) {
-                // don't add to same list, will modify the one in the session, create new list
-                productSearchConstraintList = new ArrayList(productSearchConstraintList);
-                productSearchConstraintList.add(viewAllowConstraint);
-            }
-        }
-        return productSearchConstraintList;
-    }
-
     public static void searchClear(HttpSession session) {
         ProductSearchOptions.clearSearchOptions(session);
     }
@@ -403,6 +390,7 @@
     }
 
     public static void processSearchParameters(Map parameters, HttpServletRequest request) {
+        GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
         Boolean alreadyRun = (Boolean) request.getAttribute("processSearchParametersAlreadyRun");
         if (Boolean.TRUE.equals(alreadyRun)) {
             return;
@@ -509,7 +497,22 @@
             searchAddConstraint(new ProductSearch.SupplierConstraint(supplierPartyId), session);
             constraintsChanged = true;
         }
+        
+        // check the ProductStore to see if we should add the ExcludeVariantsConstraint
+        GenericValue productStore = ProductStoreWorker.getProductStore(request);
+        if (productStore != null && !"N".equals(productStore.getString("prodSearchExcludeVariants"))) {
+            searchAddConstraint(new ProductSearch.ExcludeVariantsConstraint(), session);
+            // not consider this a change for now, shouldn't change often: constraintsChanged = true;
+        }
 
+        String prodCatalogId = CatalogWorker.getCurrentCatalogId(request);
+        String viewProductCategoryId = CatalogWorker.getCatalogViewAllowCategoryId(delegator, prodCatalogId);
+        if (UtilValidate.isNotEmpty(viewProductCategoryId)) {
+            ProductSearchConstraint viewAllowConstraint = new CategoryConstraint(viewProductCategoryId, true);
+            searchAddConstraint(viewAllowConstraint, session);
+            // not consider this a change for now, shouldn't change often: constraintsChanged = true;
+        }
+        
         // set the sort order
         String sortOrder = (String) parameters.get("sortOrder");
         String sortAscending = (String) parameters.get("sortAscending");
@@ -587,7 +590,6 @@
             // if the search options have changed since the last search, put at the beginning of the options history list
             checkSaveSearchOptionsHistory(session);
 
-            productSearchConstraintList = ensureViewAllowConstraint(productSearchConstraintList, prodCatalogId, delegator);
             ResultSortOrder resultSortOrder = ProductSearchOptions.getResultSortOrder(request);
 
             ProductSearchContext productSearchContext = new ProductSearchContext(delegator, visitId);

Modified: ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml?view=diff&rev=496617&r1=496616&r2=496617
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/store/ProductStoreForms.xml Tue Jan 16 00:22:08 2007
@@ -1,8 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!--
-
-Copyright 2001-2006 The Apache Software Foundation
-
 Licensed under the Apache License, Version 2.0 (the "License"); you may not
 use this file except in compliance with the License. You may obtain a copy of
 the License at
@@ -202,6 +199,10 @@
         </field>
         <field name="vatTaxAuthGeoId"><lookup target-form-name="LookupGeo"/></field>
         <field name="vatTaxAuthPartyId"><lookup target-form-name="LookupPartyName"/></field>
+        <field name="prodSearchExcludeVariants" widget-style="selectBox">
+            <drop-down allow-empty="false" no-current-selected-key="Y"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
+        </field>
+
         <field name="enableDigProdUpload" widget-style="selectBox">
             <drop-down allow-empty="false" no-current-selected-key="N"><option key="Y" description="${uiLabelMap.CommonY}"/><option key="N" description="${uiLabelMap.CommonN}"/></drop-down>
         </field>