Author: jonesde Date: Fri Nov 10 22:25:52 2006 New Revision: 473652 URL: http://svn.apache.org/viewvc?view=rev&rev=473652 Log: Applied patch from Marco Risaliti with another pass at the internationalization of the ProductSearch stuff, and the search by catalog stuff; Jira #OFBIZ-179
Modified: incubator/ofbiz/trunk/applications/content/widget/cms/advancedsearchprep.bsh incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/content/advancedsearchprep.bsh incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/advancedsearch.ftl incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/minilastproductsearches.ftl incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/advancedsearchoptions.bsh incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/keywordsearch.bsh incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/advancedsearch.ftl incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/advancedsearchoptions.bsh incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/keywordsearch.bsh incubator/ofbiz/trunk/applications/product/webapp/catalog/find/advancedsearch.ftl incubator/ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml Modified: incubator/ofbiz/trunk/applications/content/widget/cms/advancedsearchprep.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/content/widget/cms/advancedsearchprep.bsh?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/content/widget/cms/advancedsearchprep.bsh (original) +++ incubator/ofbiz/trunk/applications/content/widget/cms/advancedsearchprep.bsh Fri Nov 10 22:25:52 2006 @@ -30,7 +30,7 @@ } searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, session); +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); context.put("productFeaturesByTypeMap", productFeaturesByTypeMap); context.put("productFeatureTypeIdsOrdered", productFeatureTypeIdsOrdered); Modified: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/content/advancedsearchprep.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/content/advancedsearchprep.bsh?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/content/advancedsearchprep.bsh (original) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/WEB-INF/actions/content/advancedsearchprep.bsh Fri Nov 10 22:25:52 2006 @@ -31,7 +31,7 @@ } searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, session); +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); context.put("productFeaturesByTypeMap", productFeaturesByTypeMap); context.put("productFeatureTypeIdsOrdered", productFeatureTypeIdsOrdered); Modified: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/advancedsearch.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/advancedsearch.ftl?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/advancedsearch.ftl (original) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/advancedsearch.ftl Fri Nov 10 22:25:52 2006 @@ -15,12 +15,13 @@ under the License. --> <#assign searchOptionsHistoryList = Static["org.ofbiz.product.product.ProductSearchSession"].getSearchOptionsHistoryList(session)> - +<#assign currentCatalogId = Static["org.ofbiz.product.catalog.CatalogWorker"].getCurrentCatalogId(request)> <div class="head1">${uiLabelMap.ProductAdvancedSearchinCategory}</div> <br/> <form name="advtokeywordsearchform" method="post" action="<@ofbizUrl>keywordsearch</@ofbizUrl>" style="margin: 0;"> <input type="hidden" name="VIEW_SIZE" value="10"/> <table border="0" wdith="100%"> + <input type="hidden" name="SEARCH_CATALOG_ID" value="${currentCatalogId}"> <#if searchCategory?has_content> <input type="hidden" name="SEARCH_CATEGORY_ID" value="${searchCategoryId?if_exists}"/> <tr> @@ -70,7 +71,7 @@ </#list> <tr> <td align="right" valign="middle"> - <div class="tabletext">${uiLabelMap.ProductSortOrder}:</div> + <div class="tabletext">${uiLabelMap.ProductSortedBy}:</div> </td> <td valign="middle"> <div class="tabletext"> @@ -130,7 +131,7 @@ <a href="<@ofbizUrl>setCurrentSearchFromHistoryAndSearch?searchHistoryIndex=${searchOptions_index}&clearSearch=N</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonSearch}</a> <a href="<@ofbizUrl>setCurrentSearchFromHistory?searchHistoryIndex=${searchOptions_index}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonRefine}</a> </div> - <#assign constraintStrings = searchOptions.searchGetConstraintStrings(false, delegator)> + <#assign constraintStrings = searchOptions.searchGetConstraintStrings(false, delegator, locale)> <#list constraintStrings as constraintString> <div class="tabletext"> - ${constraintString}</div> </#list> Modified: incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/minilastproductsearches.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/minilastproductsearches.ftl?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/minilastproductsearches.ftl (original) +++ incubator/ofbiz/trunk/applications/ecommerce/webapp/ecommerce/catalog/minilastproductsearches.ftl Fri Nov 10 22:25:52 2006 @@ -39,7 +39,7 @@ <a href="<@ofbizUrl>setCurrentSearchFromHistoryAndSearch?searchHistoryIndex=${searchOptions_index}&clearSearch=N</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonSearch}]</a> <a href="<@ofbizUrl>setCurrentSearchFromHistory?searchHistoryIndex=${searchOptions_index}</@ofbizUrl>" class="buttontext">[${uiLabelMap.CommonRefine}]</a> </div> - <#assign constraintStrings = searchOptions.searchGetConstraintStrings(false, delegator)> + <#assign constraintStrings = searchOptions.searchGetConstraintStrings(false, delegator, locale)> <#list constraintStrings as constraintString> <div class="tabletext"> - ${constraintString}</div> </#list> Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/advancedsearchoptions.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/advancedsearchoptions.bsh?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/advancedsearchoptions.bsh (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/advancedsearchoptions.bsh Fri Nov 10 22:25:52 2006 @@ -41,7 +41,7 @@ } searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, session); +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); context.put("searchCategoryId", searchCategoryId); context.put("searchCategory", searchCategory); Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/keywordsearch.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/keywordsearch.bsh?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/keywordsearch.bsh (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/WEB-INF/actions/entry/catalog/keywordsearch.bsh Fri Nov 10 22:25:52 2006 @@ -30,7 +30,7 @@ // note: this can be run multiple times in the same request without causing problems, will check to see on its own if it has run again ProductSearchSession.processSearchParameters(parameters, request); prodCatalogId = CatalogWorker.getCurrentCatalogId(request); -Map result = ProductSearchSession.getProductSearchResult(session, delegator, prodCatalogId); +Map result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId); context.put("productIds", result.get("productIds")); context.put("viewIndex", result.get("viewIndex")); Modified: incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/advancedsearch.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/advancedsearch.ftl?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/advancedsearch.ftl (original) +++ incubator/ofbiz/trunk/applications/order/webapp/ordermgr/entry/catalog/advancedsearch.ftl Fri Nov 10 22:25:52 2006 @@ -15,12 +15,13 @@ under the License. --> <#assign searchOptionsHistoryList = Static["org.ofbiz.product.product.ProductSearchSession"].getSearchOptionsHistoryList(session)> - +<#assign currentCatalogId = Static["org.ofbiz.product.catalog.CatalogWorker"].getCurrentCatalogId(request)> <div class="head1">${uiLabelMap.ProductAdvancedSearchinCategory}</div> <br/> <form name="advtokeywordsearchform" method="post" action="<@ofbizUrl>keywordsearch</@ofbizUrl>" style="margin: 0;"> <input type="hidden" name="VIEW_SIZE" value="10"> <table border="0" wdith="100%"> + <input type="hidden" name="SEARCH_CATALOG_ID" value="${currentCatalogId}"> <#if searchCategory?has_content> <input type="hidden" name="SEARCH_CATEGORY_ID" value="${searchCategoryId?if_exists}"> <tr> @@ -85,7 +86,7 @@ </tr> <tr> <td align="right" valign="middle"> - <div class="tabletext">${uiLabelMap.ProductSortOrder}:</div> + <div class="tabletext">${uiLabelMap.CommonSortedBy}:</div> </td> <td valign="middle"> <div class="tabletext"> @@ -100,8 +101,8 @@ <option value="SortProductPrice:DEFAULT_PRICE">${uiLabelMap.ProductDefaultPrice}</option> <option value="SortProductPrice:AVERAGE_COST">${uiLabelMap.ProductAverageCost}</option> </select> - ${uiLabelMap.EcommerceLowToHigh}<input type="radio" name="sortAscending" value="Y" checked> - ${uiLabelMap.EcommerceHighToLow}<input type="radio" name="sortAscending" value="N"> + ${uiLabelMap.ProductLowToHigh}<input type="radio" name="sortAscending" value="Y" checked> + ${uiLabelMap.ProductHighToLow}<input type="radio" name="sortAscending" value="N"> </div> </td> </tr> @@ -114,7 +115,7 @@ <#list searchConstraintStrings as searchConstraintString> <div class="tabletext"> - ${searchConstraintString}</div> </#list> - <div class="tabletext">${uiLabelMap.ProductSortedBy}: ${searchSortOrderString}</div> + <div class="tabletext">${uiLabelMap.CommonSortedBy}: ${searchSortOrderString}</div> <div class="tabletext"> ${uiLabelMap.ProductNewSearch}<input type="radio" name="clearSearch" value="Y" checked> ${uiLabelMap.ProductRefineSearch}<input type="radio" name="clearSearch" value="N"> @@ -147,7 +148,7 @@ <a href="<@ofbizUrl>setCurrentSearchFromHistoryAndSearch?searchHistoryIndex=${searchOptions_index}&clearSearch=N</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonSearch}</a> <a href="<@ofbizUrl>setCurrentSearchFromHistory?searchHistoryIndex=${searchOptions_index}</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonRefine}</a> </div> - <#assign constraintStrings = searchOptions.searchGetConstraintStrings(false, delegator)> + <#assign constraintStrings = searchOptions.searchGetConstraintStrings(false, delegator, locale)> <#list constraintStrings as constraintString> <div class="tabletext"> - ${constraintString}</div> </#list> Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Fri Nov 10 22:25:52 2006 @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TreeSet; @@ -499,9 +500,81 @@ public abstract void addConstraint(ProductSearchContext productSearchContext); /** pretty print for log messages and even UI stuff */ - public abstract String prettyPrintConstraint(GenericDelegator delegator, boolean detailed); + public abstract String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale); } + + public static class CatalogConstraint extends ProductSearchConstraint { + public static final String constraintName = "Catalog"; + protected String prodCatalogId; + protected ArrayList productCategories; + + public CatalogConstraint(String prodCatalogId, ArrayList productCategories) { + this.prodCatalogId = prodCatalogId; + this.productCategories = productCategories; + } + + public void addConstraint(ProductSearchContext productSearchContext) { + ArrayList productCategoryIds = new ArrayList(); + Iterator itCat = productCategories.iterator(); + while (itCat.hasNext()) { + GenericValue category = (GenericValue)itCat.next(); + productCategoryIds.add(category.getString("productCategoryId")); + } + + // make index based values and increment + String entityAlias = "PCM" + productSearchContext.index; + String prefix = "pcm" + productSearchContext.index; + productSearchContext.index++; + + productSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "ProductCategoryMember"); + productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductCategoryId", "productCategoryId", null, null, null, null); + productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "FromDate", "fromDate", null, null, null, null); + productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ThruDate", "thruDate", null, null, null, null); + productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId")); productSearchContext.entityConditionList.add(new EntityExpr(prefix + "ProductCategoryId", EntityOperator.IN, productCategoryIds)); + productSearchContext.entityConditionList.add(new EntityExpr(new EntityExpr(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, new EntityExpr(prefix + "ThruDate", EntityOperator.GREATER_THAN, productSearchContext.nowTimestamp))); + productSearchContext.entityConditionList.add(new EntityExpr(prefix + "FromDate", EntityOperator.LESS_THAN, productSearchContext.nowTimestamp)); + + // 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", this.prodCatalogId))); + } + + /** pretty print for log messages and even UI stuff */ + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { + GenericValue prodCatalog = null; + try { + prodCatalog = delegator.findByPrimaryKeyCache("ProdCatalog", UtilMisc.toMap("prodCatalogId", prodCatalogId)); + } catch (GenericEntityException e) { + Debug.logError(e, "Error finding ProdCatalog information for constraint pretty print", module); + } + StringBuffer ppBuf = new StringBuffer(); + ppBuf.append(UtilProperties.getMessage(resource, "ProductCatalog", locale)+": "); + if (prodCatalog != null) { + ppBuf.append(prodCatalog.getString("catalogName")); + } + return ppBuf.toString(); + } + + public boolean equals(Object obj) { + ProductSearchConstraint psc = (ProductSearchConstraint) obj; + if (psc instanceof CatalogConstraint) { + CatalogConstraint that = (CatalogConstraint) psc; + if (this.prodCatalogId == null) { + if (that.prodCatalogId != null) { + return false; + } + } else { + if (!this.prodCatalogId.equals(that.prodCatalogId)) { + return false; + } + } + return true; + } else { + return false; + } + } + } + public static class CategoryConstraint extends ProductSearchConstraint { public static final String constraintName = "Category"; protected String productCategoryId; @@ -542,15 +615,15 @@ } /** pretty print for log messages and even UI stuff */ - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { GenericValue productCategory = null; try { productCategory = delegator.findByPrimaryKeyCache("ProductCategory", UtilMisc.toMap("productCategoryId", productCategoryId)); } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductCategory information for constraint pretty print", module); } - StringBuffer ppBuf = new StringBuffer(); - ppBuf.append("Category: "); + StringBuffer ppBuf = new StringBuffer(); + ppBuf.append(UtilProperties.getMessage(resource, "ProductCategory", locale)+": "); if (productCategory != null) { ppBuf.append(productCategory.getString("description")); } @@ -560,7 +633,7 @@ ppBuf.append("]"); } if (includeSubCategories) { - ppBuf.append(" (and all sub-categories)"); + ppBuf.append(" ("+UtilProperties.getMessage(resource, "ProductIncludeAllSubCategories", locale)+")"); } return ppBuf.toString(); } @@ -615,7 +688,7 @@ productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.productFeatureId))); } - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { GenericValue productFeature = null; GenericValue productFeatureType = null; try { @@ -624,7 +697,16 @@ } catch (GenericEntityException e) { Debug.logError(e, "Error finding ProductFeature and Type information for constraint pretty print", module); } - return (productFeatureType == null ? "Feature: " : productFeatureType.getString("description") + ": ") + (productFeature == null ? "[" + this.productFeatureId + "]" : productFeature.getString("description")); + StringBuffer ppBuf = new StringBuffer(); + if (productFeatureType == null) { + ppBuf.append(UtilProperties.getMessage(resource, "ProductFeature", locale)+": "); + ppBuf.append("[" + this.productFeatureId + "]"); + } else { + // TODO getString to be localized like get("description", locale) + ppBuf.append(productFeatureType.getString("description") + ": "); + ppBuf.append(productFeature.getString("description")); + } + return (ppBuf.toString()); } public boolean equals(Object obj) { @@ -684,7 +766,7 @@ productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", featureIdInfo.toString()))); } - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { StringBuffer infoOut = new StringBuffer(); try { Iterator featureIdIter = this.productFeatureIdSet.iterator(); @@ -693,7 +775,7 @@ GenericValue productFeature = delegator.findByPrimaryKeyCache("ProductFeature", UtilMisc.toMap("productFeatureId", featureId)); GenericValue productFeatureType = productFeature == null ? null : productFeature.getRelatedOneCache("ProductFeatureType"); if (productFeatureType == null) { - infoOut.append("Feature: "); + infoOut.append(UtilProperties.getMessage(resource, "ProductFeature", locale)+": "); } else { infoOut.append(productFeatureType.getString("description")); infoOut.append(": "); @@ -818,8 +900,12 @@ } /** pretty print for log messages and even UI stuff */ - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { - return "Keyword(s): \"" + this.keywordsString + "\", where " + (isAnd ? "all words match" : "any word matches"); + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { + StringBuffer ppBuf = new StringBuffer(); + ppBuf.append(UtilProperties.getMessage(resource, "ProductKeywords", locale) + ": \""); + ppBuf.append(this.keywordsString + "\", " + UtilProperties.getMessage(resource, "ProductKeywordWhere", locale) + " "); + ppBuf.append(isAnd ? UtilProperties.getMessage(resource, "ProductKeywordAllWordsMatch", locale) : UtilProperties.getMessage(resource, "ProductKeywordAnyWordMatches", locale)); + return ppBuf.toString(); } public boolean equals(Object obj) { @@ -869,7 +955,7 @@ } /** pretty print for log messages and even UI stuff */ - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { // TODO: implement the pretty print for log messages and even UI stuff return null; } @@ -918,7 +1004,7 @@ } /** pretty print for log messages and even UI stuff */ - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { // TODO: implement the pretty print for log messages and even UI stuff return null; } @@ -975,8 +1061,8 @@ productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", this.supplierPartyId))); } - public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed) { - return "Supplier: " + PartyHelper.getPartyName(delegator, supplierPartyId, false); + public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) { + return UtilProperties.getMessage(resource, "ProductSupplier", locale)+": " + PartyHelper.getPartyName(delegator, supplierPartyId, false); } public boolean equals(Object obj) { @@ -1009,7 +1095,7 @@ public abstract void setSortOrder(ProductSearchContext productSearchContext); public abstract String getOrderName(); - public abstract String prettyPrintSortOrder(boolean detailed); + public abstract String prettyPrintSortOrder(boolean detailed, Locale locale); public abstract boolean isAscending(); } @@ -1029,8 +1115,8 @@ return "KeywordRelevancy"; } - public String prettyPrintSortOrder(boolean detailed) { - return "Keyword Relevancy"; + public String prettyPrintSortOrder(boolean detailed, Locale locale) { + return UtilProperties.getMessage(resource, "ProductKeywordRelevency", locale); } public boolean isAscending() { @@ -1072,15 +1158,15 @@ return "ProductField:" + this.fieldName; } - public String prettyPrintSortOrder(boolean detailed) { + public String prettyPrintSortOrder(boolean detailed, Locale locale) { if ("productName".equals(this.fieldName)) { - return "Product Name"; + return UtilProperties.getMessage(resource, "ProductProductName", locale); } else if ("totalQuantityOrdered".equals(this.fieldName)) { - return "Popularity by Orders"; + return UtilProperties.getMessage(resource, "ProductPopularityByOrders", locale); } else if ("totalTimesViewed".equals(this.fieldName)) { - return "Popularity by Views"; + return UtilProperties.getMessage(resource, "ProductPopularityByViews", locale); } else if ("averageCustomerRating".equals(this.fieldName)) { - return "Customer Rating"; + return UtilProperties.getMessage(resource, "ProductCustomerRating", locale); } return this.fieldName; } @@ -1146,16 +1232,25 @@ return "ProductPrice:" + productPriceTypeId; } - public String prettyPrintSortOrder(boolean detailed) { + public String prettyPrintSortOrder(boolean detailed, Locale locale) { String priceTypeName = null; if ("LIST_PRICE".equals(this.productPriceTypeId)) { - priceTypeName = "List Price"; + priceTypeName = UtilProperties.getMessage(resource, "ProductListPrice", locale); } else if ("DEFAULT_PRICE".equals(this.productPriceTypeId)) { - priceTypeName = "Default Price"; + priceTypeName = UtilProperties.getMessage(resource, "ProductDefaultPrice", locale); } else if ("AVERAGE_COST".equals(this.productPriceTypeId)) { - priceTypeName = "Average Cost"; + priceTypeName = UtilProperties.getMessage(resource, "ProductAverageCost", locale); + } + if (priceTypeName == null) { + priceTypeName = UtilProperties.getMessage(resource, "ProductPrice", locale) + " ("; + if (this.ascending) { + priceTypeName += UtilProperties.getMessage(resource, "ProductLowToHigh", locale)+")"; + } else { + priceTypeName += UtilProperties.getMessage(resource, "ProductHighToLow", locale)+")"; + } } - return (priceTypeName == null ? "Price" : priceTypeName) + " (" + (this.ascending ? "Low to High)" : "High to Low)"); + + return priceTypeName; } public boolean isAscending() { Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Fri Nov 10 22:25:52 2006 @@ -387,7 +387,7 @@ List productSearchConstraintList = ProductSearchSession.ProductSearchOptions.getConstraintList(session); // if no constraints, don't do a search... if (productSearchConstraintList != null && productSearchConstraintList.size() > 0) { - ResultSortOrder resultSortOrder = ProductSearchSession.ProductSearchOptions.getResultSortOrder(session); + ResultSortOrder resultSortOrder = ProductSearchSession.ProductSearchOptions.getResultSortOrder(request); ProductSearchSession.checkSaveSearchOptionsHistory(session); ProductSearchContext productSearchContext = new ProductSearchContext(delegator, visitId); Modified: incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original) +++ incubator/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Fri Nov 10 22:25:52 2006 @@ -24,6 +24,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; @@ -43,6 +44,7 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.product.catalog.CatalogWorker; +import org.ofbiz.product.category.CategoryWorker; import org.ofbiz.product.feature.ParametricSearch; import org.ofbiz.product.product.ProductSearch.CategoryConstraint; import org.ofbiz.product.product.ProductSearch.FeatureConstraint; @@ -102,8 +104,8 @@ } return this.resultSortOrder; } - public static ResultSortOrder getResultSortOrder(HttpSession session) { - ProductSearchOptions productSearchOptions = getProductSearchOptions(session); + public static ResultSortOrder getResultSortOrder(HttpServletRequest request) { + ProductSearchOptions productSearchOptions = getProductSearchOptions(request.getSession()); return productSearchOptions.getResultSortOrder(); } public static void setResultSortOrder(ResultSortOrder resultSortOrder, HttpSession session) { @@ -148,7 +150,7 @@ this.viewSize = viewSize; } - public List searchGetConstraintStrings(boolean detailed, GenericDelegator delegator) { + public List searchGetConstraintStrings(boolean detailed, GenericDelegator delegator, Locale locale) { List productSearchConstraintList = this.getConstraintList(); List constraintStrings = new ArrayList(); if (productSearchConstraintList == null) { @@ -158,7 +160,7 @@ while (productSearchConstraintIter.hasNext()) { ProductSearchConstraint productSearchConstraint = (ProductSearchConstraint) productSearchConstraintIter.next(); if (productSearchConstraint == null) continue; - String constraintString = productSearchConstraint.prettyPrintConstraint(delegator, detailed); + String constraintString = productSearchConstraint.prettyPrintConstraint(delegator, detailed, locale); if (UtilValidate.isNotEmpty(constraintString)) { constraintStrings.add(constraintString); } else { @@ -357,21 +359,24 @@ } public static List searchGetConstraintStrings(boolean detailed, HttpSession session, GenericDelegator delegator) { + Locale locale = UtilHttp.getLocale(session); ProductSearchOptions productSearchOptions = getProductSearchOptions(session); - return productSearchOptions.searchGetConstraintStrings(detailed, delegator); + return productSearchOptions.searchGetConstraintStrings(detailed, delegator, locale); } - public static String searchGetSortOrderString(boolean detailed, HttpSession session) { - ResultSortOrder resultSortOrder = ProductSearchOptions.getResultSortOrder(session); + public static String searchGetSortOrderString(boolean detailed, HttpServletRequest request) { + Locale locale = UtilHttp.getLocale(request); + ResultSortOrder resultSortOrder = ProductSearchOptions.getResultSortOrder(request); if (resultSortOrder == null) return ""; - return resultSortOrder.prettyPrintSortOrder(detailed); + return resultSortOrder.prettyPrintSortOrder(detailed, locale); } public static void searchSetSortOrder(ResultSortOrder resultSortOrder, HttpSession session) { ProductSearchOptions.setResultSortOrder(resultSortOrder, session); } - public static void searchAddFeatureIdConstraints(Collection featureIds, HttpSession session) { + public static void searchAddFeatureIdConstraints(Collection featureIds, HttpServletRequest request) { + HttpSession session = request.getSession(); if (featureIds == null || featureIds.size() == 0) { return; } @@ -444,6 +449,20 @@ 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"))) { + + String searchCatalogId = (String) parameters.get("SEARCH_CATALOG_ID"); + if (searchCatalogId != null && !searchCatalogId.equalsIgnoreCase("")) { + ArrayList categories = CategoryWorker.getRelatedCategoriesRet(request, "topLevelList", CatalogWorker.getCatalogTopCategoryId(request, searchCatalogId), true); + searchAddConstraint(new ProductSearch.CatalogConstraint(searchCatalogId, categories), session); + constraintsChanged = true; + } + } + // if keywords were specified, add a constraint for them if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_STRING"))) { String keywordString = (String) parameters.get("SEARCH_STRING"); @@ -474,14 +493,14 @@ List featureIdList = ParametricSearch.makeFeatureIdListFromPrefixed(parameters); if (featureIdList.size() > 0) { constraintsChanged = true; - searchAddFeatureIdConstraints(featureIdList, session); + searchAddFeatureIdConstraints(featureIdList, request); } // if features were selected add a constraint for each Map featureIdByType = ParametricSearch.makeFeatureIdByTypeMap(parameters); if (featureIdByType.size() > 0) { constraintsChanged = true; - searchAddFeatureIdConstraints(featureIdByType.values(), session); + searchAddFeatureIdConstraints(featureIdByType.values(), request); } // add a supplier to the search @@ -535,7 +554,7 @@ } } - public static Map getProductSearchResult(HttpSession session, GenericDelegator delegator, String prodCatalogId) { + public static Map getProductSearchResult(HttpServletRequest request, GenericDelegator delegator, String prodCatalogId) { // ========== Create View Indexes int viewIndex = 0; @@ -544,6 +563,7 @@ int lowIndex = 0; int listSize = 0; + HttpSession session = request.getSession(); ProductSearchOptions productSearchOptions = getProductSearchOptions(session); Integer viewIndexInteger = productSearchOptions.getViewIndex(); @@ -568,7 +588,7 @@ checkSaveSearchOptionsHistory(session); productSearchConstraintList = ensureViewAllowConstraint(productSearchConstraintList, prodCatalogId, delegator); - ResultSortOrder resultSortOrder = ProductSearchOptions.getResultSortOrder(session); + ResultSortOrder resultSortOrder = ProductSearchOptions.getResultSortOrder(request); ProductSearchContext productSearchContext = new ProductSearchContext(delegator, visitId); productSearchContext.addProductSearchConstraints(productSearchConstraintList); @@ -590,7 +610,7 @@ // ========== Setup other display info List searchConstraintStrings = searchGetConstraintStrings(false, session, delegator); - String searchSortOrderString = searchGetSortOrderString(false, session); + String searchSortOrderString = searchGetSortOrderString(false, request); // ========== populate the result Map Map result = new HashMap(); Modified: incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/advancedsearchoptions.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/advancedsearchoptions.bsh?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/advancedsearchoptions.bsh (original) +++ incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/advancedsearchoptions.bsh Fri Nov 10 22:25:52 2006 @@ -40,7 +40,7 @@ } searchConstraintStrings = ProductSearchSession.searchGetConstraintStrings(false, session, delegator); -searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, session); +searchSortOrderString = ProductSearchSession.searchGetSortOrderString(false, request); // get suppliers in system supplerPartyRoleAndPartyDetails = delegator.findByAnd("PartyRoleAndPartyDetail", UtilMisc.toMap("roleTypeId", "SUPPLIER"), UtilMisc.toList("groupName", "firstName")); Modified: incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/keywordsearch.bsh URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/keywordsearch.bsh?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/keywordsearch.bsh (original) +++ incubator/ofbiz/trunk/applications/product/webapp/catalog/WEB-INF/actions/find/keywordsearch.bsh Fri Nov 10 22:25:52 2006 @@ -27,7 +27,7 @@ // note: this can be run multiple times in the same request without causing problems, will check to see on its own if it has run again ProductSearchSession.processSearchParameters(parameters, request); prodCatalogId = CatalogWorker.getCurrentCatalogId(request); -Map result = ProductSearchSession.getProductSearchResult(session, delegator, prodCatalogId); +Map result = ProductSearchSession.getProductSearchResult(request, delegator, prodCatalogId); applicationTypes = delegator.findAll("ProductFeatureApplType", UtilMisc.toList("description")); Modified: incubator/ofbiz/trunk/applications/product/webapp/catalog/find/advancedsearch.ftl URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/webapp/catalog/find/advancedsearch.ftl?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/webapp/catalog/find/advancedsearch.ftl (original) +++ incubator/ofbiz/trunk/applications/product/webapp/catalog/find/advancedsearch.ftl Fri Nov 10 22:25:52 2006 @@ -35,6 +35,25 @@ </tr> <#else> <tr> + <td align="right" valign="middle"> + <div class="tabletext">${uiLabelMap.ProductCatalog}:</div> + </td> + <td valign="middle"> + <div class="tabletext"> + <select class="selectBox" name="SEARCH_CATALOG_ID"> + <option value="">- ${uiLabelMap.ProductAnyCatalog} -</option> + <#list prodCatalogs as prodCatalog> + <#assign displayDesc = prodCatalog.catalogName?default("${uiLabelMap.ProductNoDescription}")> + <#if 18 < displayDesc?length> + <#assign displayDesc = displayDesc[0..15] + "..."> + </#if> + <option value="${prodCatalog.prodCatalogId}">${displayDesc} [${prodCatalog.prodCatalogId}]</option> + </#list> + </select> + </div> + </td> + </tr> + <tr> <td align="right" valign="middle"> <div class="tabletext">${uiLabelMap.ProductCategory}:</div> </td> @@ -118,7 +137,7 @@ </tr> <tr> <td align="right" valign="middle"> - <div class="tabletext">${uiLabelMap.CommonSortOrder}:</div> + <div class="tabletext">${uiLabelMap.CommonSortedBy}:</div> </td> <td valign="middle"> <div class="tabletext"> @@ -151,8 +170,8 @@ </#list> <div class="tabletext">${uiLabelMap.CommonSortedBy}: ${searchSortOrderString}</div> <div class="tabletext"> - New Search<input type="radio" name="clearSearch" value="Y" checked/> - Refine Search<input type="radio" name="clearSearch" value="N"/> + ${uiLabelMap.ProductNewSearch}<input type="radio" name="clearSearch" value="Y" checked/> + ${uiLabelMap.ProductRefineSearch}<input type="radio" name="clearSearch" value="N"/> </div> </td> </tr> Modified: incubator/ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml URL: http://svn.apache.org/viewvc/incubator/ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml?view=diff&rev=473652&r1=473651&r2=473652 ============================================================================== --- incubator/ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml (original) +++ incubator/ofbiz/trunk/applications/product/widget/catalog/FindScreens.xml Fri Nov 10 22:25:52 2006 @@ -55,6 +55,9 @@ <condition-expr field-name="showInSelect" operator="not-equals" value="N"/> <order-by field-name="description"/> </entity-condition> + <entity-condition entity-name="ProdCatalog" list-name="prodCatalogs"> + <order-by field-name="catalogName"/> + </entity-condition> <script location="component://product/webapp/catalog/WEB-INF/actions/find/advancedsearchoptions.bsh"/> </actions> <widgets>