svn commit: r509164 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml src/org/ofbiz/product/product/ProductSearchSession.java webapp/catalog/find/keywordsearch.ftl webapp/catalog/find/keywordsearchbox.ftl

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

svn commit: r509164 - in /ofbiz/trunk/applications/product: entitydef/entitymodel.xml src/org/ofbiz/product/product/ProductSearchSession.java webapp/catalog/find/keywordsearch.ftl webapp/catalog/find/keywordsearchbox.ftl

jonesde
Author: jonesde
Date: Mon Feb 19 03:36:08 2007
New Revision: 509164

URL: http://svn.apache.org/viewvc?view=rev&rev=509164
Log:
A few misc cleanups for layout, etc; made ProductSearchSession URL parameters more flexible and added a method to turn search constraints and sort order into a parameter string, which is now used in the catalog manager search results page to make it easy to reproduce the search constraints

Modified:
    ofbiz/trunk/applications/product/entitydef/entitymodel.xml
    ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java
    ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl
    ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearchbox.ftl

Modified: ofbiz/trunk/applications/product/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/entitydef/entitymodel.xml?view=diff&rev=509164&r1=509163&r2=509164
==============================================================================
--- ofbiz/trunk/applications/product/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/product/entitydef/entitymodel.xml Mon Feb 19 03:36:08 2007
@@ -322,7 +322,7 @@
         <field name="sequenceNum" type="numeric"><description>This field is used to sort the links. The linkSeqId field is not used because it is part of the primary key and cannot be changed.</description></field>
         <field name="titleText" type="description"></field>
         <field name="detailText" type="very-long"></field>
-        <field name="imageUrl" type="description"></field>
+        <field name="imageUrl" type="url"></field>
         <field name="linkTypeEnumId" type="id"></field>
         <field name="linkInfo" type="long-varchar"></field>
         <field name="detailSubScreen" type="long-varchar"><description>This is optional. If not specified a default should be used by the category detail template.</description></field>

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=509164&r1=509163&r2=509164
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Mon Feb 19 03:36:08 2007
@@ -24,7 +24,6 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -77,7 +76,8 @@
 
         /** Basic copy constructor */
         public ProductSearchOptions(ProductSearchOptions productSearchOptions) {
-            this.constraintList = new LinkedList(productSearchOptions.constraintList);
+            this.constraintList = FastList.newInstance();
+            this.constraintList.addAll(productSearchOptions.constraintList);
             this.resultSortOrder = productSearchOptions.resultSortOrder;
             this.viewIndex = productSearchOptions.viewIndex;
             this.viewSize = productSearchOptions.viewSize;
@@ -196,7 +196,7 @@
     public static List getSearchOptionsHistoryList(HttpSession session) {
         List optionsHistoryList = (List) session.getAttribute("_PRODUCT_SEARCH_OPTIONS_HISTORY_");
         if (optionsHistoryList == null) {
-            optionsHistoryList = new LinkedList();
+            optionsHistoryList = FastList.newInstance();
             session.setAttribute("_PRODUCT_SEARCH_OPTIONS_HISTORY_", optionsHistoryList);
         }
         return optionsHistoryList;
@@ -426,25 +426,18 @@
             searchAddConstraint(new ProductSearch.CategoryConstraint(searchCategoryId, !"N".equals(searchSubCategories)), session);
             constraintsChanged = true;
         }
-        if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_CATEGORY_ID2"))) {
-            String searchCategoryId = (String) parameters.get("SEARCH_CATEGORY_ID2");
-            String searchSubCategories = (String) parameters.get("SEARCH_SUB_CATEGORIES2");
-            searchAddConstraint(new ProductSearch.CategoryConstraint(searchCategoryId, !"N".equals(searchSubCategories)), session);
-            constraintsChanged = true;
-        }
-        if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_CATEGORY_ID3"))) {
-            String searchCategoryId = (String) parameters.get("SEARCH_CATEGORY_ID3");
-            String searchSubCategories = (String) parameters.get("SEARCH_SUB_CATEGORIES3");
-            searchAddConstraint(new ProductSearch.CategoryConstraint(searchCategoryId, !"N".equals(searchSubCategories)), session);
-            constraintsChanged = true;
+        
+        for (int catNum = 1; catNum < 10; catNum++) {
+            if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_CATEGORY_ID" + catNum))) {
+                String searchCategoryId = (String) parameters.get("SEARCH_CATEGORY_ID" + catNum);
+                String searchSubCategories = (String) parameters.get("SEARCH_SUB_CATEGORIES" + catNum);
+                searchAddConstraint(new ProductSearch.CategoryConstraint(searchCategoryId, !"N".equals(searchSubCategories)), session);
+                constraintsChanged = true;
+            }
         }
 
-
         // if there is any category selected try to use catalog and add a constraint for it
-        if (UtilValidate.isEmpty((String) parameters.get("SEARCH_CATEGORY_ID"))  &&
-            UtilValidate.isEmpty((String) parameters.get("SEARCH_CATEGORY_ID2")) &&
-            UtilValidate.isEmpty((String) parameters.get("SEARCH_CATEGORY_ID3"))) {    
-            
+        if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_CATALOG_ID"))) {    
             String searchCatalogId = (String) parameters.get("SEARCH_CATALOG_ID");
             if (searchCatalogId != null && !searchCatalogId.equalsIgnoreCase("")) {
                 List categories = CategoryWorker.getRelatedCategoriesRet(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, searchCatalogId), true);
@@ -462,21 +455,16 @@
             searchAddConstraint(new ProductSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session);
             constraintsChanged = true;
         }
-        if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_STRING2"))) {
-            String keywordString = (String) parameters.get("SEARCH_STRING2");
-            String searchOperator = (String) parameters.get("SEARCH_OPERATOR2");
-            // defaults to true/Y, ie anything but N is true/Y
-            boolean anyPrefixSuffix = !"N".equals((String) parameters.get("SEARCH_ANYPRESUF2"));
-            searchAddConstraint(new ProductSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session);
-            constraintsChanged = true;
-        }
-        if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_STRING3"))) {
-            String keywordString = (String) parameters.get("SEARCH_STRING3");
-            String searchOperator = (String) parameters.get("SEARCH_OPERATOR3");
-            // defaults to true/Y, ie anything but N is true/Y
-            boolean anyPrefixSuffix = !"N".equals((String) parameters.get("SEARCH_ANYPRESUF3"));
-            searchAddConstraint(new ProductSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session);
-            constraintsChanged = true;
+
+        for (int kwNum = 1; kwNum < 10; kwNum++) {
+            if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_STRING" + kwNum))) {
+                String keywordString = (String) parameters.get("SEARCH_STRING" + kwNum);
+                String searchOperator = (String) parameters.get("SEARCH_OPERATOR" + kwNum);
+                // defaults to true/Y, ie anything but N is true/Y
+                boolean anyPrefixSuffix = !"N".equals((String) parameters.get("SEARCH_ANYPRESUF" + kwNum));
+                searchAddConstraint(new ProductSearch.KeywordConstraint(keywordString, anyPrefixSuffix, anyPrefixSuffix, null, "AND".equals(searchOperator)), session);
+                constraintsChanged = true;
+            }
         }
 
         // if features were specified by ID add a constraint for each
@@ -629,5 +617,100 @@
         result.put("searchSortOrderString", searchSortOrderString);
 
         return result;
+    }
+    
+    public static String makeSearchParametersString(HttpSession session) {
+        return makeSearchParametersString(getProductSearchOptions(session));
+    }
+    public static String makeSearchParametersString(ProductSearchOptions productSearchOptions) {
+        StringBuffer searchParamString = new StringBuffer();
+
+        List constraintList = productSearchOptions.getConstraintList();
+        Iterator constraintIter = constraintList.iterator();
+        int categoriesCount = 0;
+        int featuresCount = 0;
+        int keywordsCount = 0;
+        boolean isNotFirst = false;
+        while (constraintIter.hasNext()) {
+            ProductSearchConstraint psc = (ProductSearchConstraint) constraintIter.next();
+            if (psc instanceof ProductSearch.CategoryConstraint) {
+                ProductSearch.CategoryConstraint cc = (ProductSearch.CategoryConstraint) psc;
+                categoriesCount++;
+                if (isNotFirst) {
+                    searchParamString.append("&amp;");
+                } else {
+                    isNotFirst = true;
+                }
+                searchParamString.append("SEARCH_CATEGORY_ID");
+                searchParamString.append(categoriesCount);
+                searchParamString.append("=");
+                searchParamString.append(cc.productCategoryId);
+                searchParamString.append("&amp;SEARCH_SUB_CATEGORIES");
+                searchParamString.append(categoriesCount);
+                searchParamString.append("=");
+                searchParamString.append(cc.includeSubCategories ? "Y" : "N");
+            } else if (psc instanceof ProductSearch.FeatureConstraint) {
+                ProductSearch.FeatureConstraint fc = (ProductSearch.FeatureConstraint) psc;
+                featuresCount++;
+                if (isNotFirst) {
+                    searchParamString.append("&amp;");
+                } else {
+                    isNotFirst = true;
+                }
+                searchParamString.append("SEARCH_FEAT");
+                searchParamString.append(featuresCount);
+                searchParamString.append("=");
+                searchParamString.append(fc.productFeatureId);
+            /* No way to specify parameters for these right now, so table until later
+            } else if (psc instanceof ProductSearch.FeatureSetConstraint) {
+                ProductSearch.FeatureSetConstraint fsc = (ProductSearch.FeatureSetConstraint) psc;
+             */  
+            } else if (psc instanceof ProductSearch.KeywordConstraint) {
+                ProductSearch.KeywordConstraint kc = (ProductSearch.KeywordConstraint) psc;
+                keywordsCount++;
+                if (isNotFirst) {
+                    searchParamString.append("&amp;");
+                } else {
+                    isNotFirst = true;
+                }
+                searchParamString.append("SEARCH_STRING");
+                searchParamString.append(keywordsCount);
+                searchParamString.append("=");
+                searchParamString.append(UtilHttp.encodeBlanks(kc.keywordsString));
+                searchParamString.append("&amp;SEARCH_OPERATOR");
+                searchParamString.append(keywordsCount);
+                searchParamString.append("=");
+                searchParamString.append(kc.isAnd ? "AND" : "OR");
+                searchParamString.append("&amp;SEARCH_ANYPRESUF");
+                searchParamString.append(keywordsCount);
+                searchParamString.append("=");
+                searchParamString.append(kc.anyPrefix | kc.anySuffix ? "Y" : "N");
+                
+            /* No way to specify parameters for these right now, so table until later
+            } else if (psc instanceof ProductSearch.ListPriceRangeConstraint) {
+                ProductSearch.ListPriceRangeConstraint lprc = (ProductSearch.ListPriceRangeConstraint) psc;
+             */  
+            }
+        }
+        
+        ResultSortOrder resultSortOrder = productSearchOptions.getResultSortOrder();
+        if (resultSortOrder != null) {
+            if (resultSortOrder instanceof ProductSearch.SortKeywordRelevancy) {
+                //ProductSearch.SortKeywordRelevancy skr = (ProductSearch.SortKeywordRelevancy) resultSortOrder;
+                searchParamString.append("&amp;sortOrder=SortKeywordRelevancy");
+            } else if (resultSortOrder instanceof ProductSearch.SortProductField) {
+                ProductSearch.SortProductField spf = (ProductSearch.SortProductField) resultSortOrder;
+                searchParamString.append("&amp;sortOrder=SortProductField:");
+                searchParamString.append(spf.fieldName);
+            } else if (resultSortOrder instanceof ProductSearch.SortProductPrice) {
+                ProductSearch.SortProductPrice spp = (ProductSearch.SortProductPrice) resultSortOrder;
+                searchParamString.append("&amp;sortOrder=SortProductPrice:");
+                searchParamString.append(spp.productPriceTypeId);
+            }
+            searchParamString.append("&amp;sortAscending=");
+            searchParamString.append(resultSortOrder.isAscending() ? "Y" : "N");
+        }
+
+        return searchParamString.toString();
     }
 }

Modified: ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl?view=diff&rev=509164&r1=509163&r2=509164
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearch.ftl Mon Feb 19 03:36:08 2007
@@ -19,10 +19,10 @@
 
 <div class="head1">${uiLabelMap.ProductSearchProducts}, <span class="head2">${uiLabelMap.ProductSearchFor}:</span></div>
 <#list searchConstraintStrings as searchConstraintString>
-    <div class="tabletext">&nbsp;<a href="<@ofbizUrl>keywordsearch?removeConstraint=${searchConstraintString_index}&clearSearch=N</@ofbizUrl>" class="buttontext">[X]</a>&nbsp;${searchConstraintString}</div>
+    <div class="tabletext">&nbsp;<a href="<@ofbizUrl>keywordsearch?removeConstraint=${searchConstraintString_index}&clearSearch=N</@ofbizUrl>" class="buttontext">X</a>&nbsp;${searchConstraintString}</div>
 </#list>
 <div class="tabletext">${uiLabelMap.CommonSortedBy}: ${searchSortOrderString}</div>
-<div class="tabletext"><a href="<@ofbizUrl>advancedsearch?SEARCH_CATEGORY_ID=${(requestParameters.SEARCH_CATEGORY_ID)?if_exists}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonRefine} ${uiLabelMap.CommonSearch}]</a></div>
+<div class="tabletext"><a href="<@ofbizUrl>advancedsearch?SEARCH_CATEGORY_ID=${(requestParameters.SEARCH_CATEGORY_ID)?if_exists}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonRefine} ${uiLabelMap.CommonSearch}</a></div>
 
 <#if !productIds?has_content>
   <br/><div class="head2">&nbsp;${uiLabelMap.ProductNoResultsFound}.</div>
@@ -34,13 +34,13 @@
       <td align="right">
         <b>
         <#if 0 < viewIndex?int>
-          <a href="<@ofbizUrl>keywordsearch/~VIEW_INDEX=${viewIndex-1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonPrevious}]</a> |
+          <a href="<@ofbizUrl>keywordsearch/~VIEW_INDEX=${viewIndex-1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonPrevious}</a> |
         </#if>
         <#if 0 < listSize?int>
           <span class="tabletext">${lowIndex+1} - ${highIndex} ${uiLabelMap.CommonOf} ${listSize}</span>
         </#if>
         <#if highIndex?int < listSize?int>
-          | <a href="<@ofbizUrl>keywordsearch/~VIEW_INDEX=${viewIndex+1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonNext}]</a>
+          | <a href="<@ofbizUrl>keywordsearch/~VIEW_INDEX=${viewIndex+1}/~VIEW_SIZE=${viewSize}/~clearSearch=N</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonNext}</a>
         </#if>
         </b>
       </td>
@@ -175,7 +175,6 @@
 </div>
 
 <hr class="sepbar"/>
-
 <div class="tabletext">
 <form method="post" action="<@ofbizUrl>searchRemoveFeature</@ofbizUrl>" name="searchRemoveFeature">
   <b>${uiLabelMap.ProductRemoveFeatureFromResults}:</b><br/>
@@ -184,6 +183,17 @@
   <input type="submit" value="${uiLabelMap.ProductRemoveFeature}" class="smallSubmit"><br/>
 </form>
 </div>
+
+<hr class="sepbar"/>
+<div class="tabletext">
+<form method="post" action="" name="searchShowParams">
+  <#assign searchParams = Static["org.ofbiz.product.product.ProductSearchSession"].makeSearchParametersString(session)>
+  <b>Plain Search Parameters:</b><input type="text" size="60" name="searchParameters" value="${searchParams}" class="inputBox">
+  <b>HTML Search Parameters:</b><input type="text" size="60" name="searchParameters" value="${searchParams?html}" class="inputBox">
+  <input type="hidden" name="clearSearch" value="N">
+</form>
+</div>
+
 <hr class="sepbar"/>
 <div class="tabletext">
 <form method="post" action="<@ofbizUrl>searchExportProductList</@ofbizUrl>" name="searchRemoveFeature">

Modified: ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearchbox.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearchbox.ftl?view=diff&rev=509164&r1=509163&r2=509164
==============================================================================
--- ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearchbox.ftl (original)
+++ ofbiz/trunk/applications/product/webapp/catalog/find/keywordsearchbox.ftl Mon Feb 19 03:36:08 2007
@@ -49,8 +49,7 @@
               <div class="tabletext">${uiLabelMap.ProductKeywords}: <input type="text" class="inputBox" name="SEARCH_STRING" size="20" maxlength="50" value="${requestParameters.SEARCH_STRING?if_exists}"/></div>
               <div class="tabletext">
                 ${uiLabelMap.ProductCategoryId}:
-                <input type="text" class="inputBox" name="SEARCH_CATEGORY_ID" size="18" maxlength="20" value="${requestParameters.SEARCH_CATEGORY_ID?if_exists}"/>
-                <a href="javascript:call_fieldlookup2(document.keywordsearchform.SEARCH_CATEGORY_ID,'LookupProductCategory');"><img src='/images/fieldlookup.gif' width='15' height='14' border='0' alt='Click here For Field Lookup'/></a>
+                <input type="text" class="inputBox" name="SEARCH_CATEGORY_ID" size="15" maxlength="20" value="${requestParameters.SEARCH_CATEGORY_ID?if_exists}"/><a href="javascript:call_fieldlookup2(document.keywordsearchform.SEARCH_CATEGORY_ID,'LookupProductCategory');"><img src='/images/fieldlookup.gif' width='15' height='14' border='0' alt='Click here For Field Lookup'/></a>
               </div>
               <div class="tabletext">
                 ${uiLabelMap.CommonNoContains}<input type="checkbox" name="SEARCH_CONTAINS" value="N" <#if requestParameters.SEARCH_CONTAINS?if_exists == "N">checked="checked"</#if>/>
@@ -64,8 +63,7 @@
             <form name="advancedsearchform" method="post" action="<@ofbizUrl>advancedsearch</@ofbizUrl>" style="margin: 0;">
               <div class="tabletext">
                 ${uiLabelMap.ProductCategoryId}:
-                <input type="text" class="inputBox" name="SEARCH_CATEGORY_ID" size="18" maxlength="20" value="${requestParameters.SEARCH_CATEGORY_ID?if_exists}"/>
-                <a href="javascript:call_fieldlookup2(document.advancedsearchform.SEARCH_CATEGORY_ID,'LookupProductCategory');"><img src='/images/fieldlookup.gif' width='15' height='14' border='0' alt='Click here For Field Lookup'/></a>
+                <input type="text" class="inputBox" name="SEARCH_CATEGORY_ID" size="15" maxlength="20" value="${requestParameters.SEARCH_CATEGORY_ID?if_exists}"/><a href="javascript:call_fieldlookup2(document.advancedsearchform.SEARCH_CATEGORY_ID,'LookupProductCategory');"><img src='/images/fieldlookup.gif' width='15' height='14' border='0' alt='Click here For Field Lookup'/></a>
               </div>
               <div class="tabletext">
                 <a href="javascript:document.advancedsearchform.submit()" class="buttontext">${uiLabelMap.ProductAdvancedSearch}</a>