You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jo...@apache.org on 2007/02/28 01:51:05 UTC
svn commit: r512532 - in /ofbiz/trunk/applications: ecommerce/config/
product/config/ product/src/org/ofbiz/product/product/
Author: jonesde
Date: Tue Feb 27 16:51:04 2007
New Revision: 512532
URL: http://svn.apache.org/viewvc?view=rev&rev=512532
Log:
Implemented the rest of the ListPriceRangeConstraint ProductSearch constraint
Modified:
ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties
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/ecommerce/config/EcommerceUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties?view=diff&rev=512532&r1=512531&r2=512532
==============================================================================
--- ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties (original)
+++ ofbiz/trunk/applications/ecommerce/config/EcommerceUiLabels.properties Tue Feb 27 16:51:04 2007
@@ -82,7 +82,9 @@
AccountingVisaMastercardAmexDiscover=Credit Card: Visa/Mastercard/Amex/Discover
CommonDigitalProductUpload=Digital Product Upload
CommonGotoPage=Go to Page
+CommonLessThan=less than
CommonMessages=Messages
+CommonMoreThan=more than
CommonNewListSubscription=New List Subscription
CommonSubscribe=Subscribe
CommonUnsubscribe=Unsubscribe
@@ -332,6 +334,7 @@
EcommerceYourPrice=Your Price
EcommerceYourShoppingCartEmpty=Your shopping cart is empty
Factoids=Factoids
+ListPriceRange=List Price Range
OrderAdjustments=Adjustments
OrderAdvancePayment=Advance Payment
OrderAllowSplit=Allow Split
Modified: ofbiz/trunk/applications/product/config/ProductUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/config/ProductUiLabels.properties?view=diff&rev=512532&r1=512531&r2=512532
==============================================================================
--- ofbiz/trunk/applications/product/config/ProductUiLabels.properties (original)
+++ ofbiz/trunk/applications/product/config/ProductUiLabels.properties Tue Feb 27 16:51:04 2007
@@ -42,6 +42,8 @@
CatalogCompanyName=OFBiz: Catalog Manager
Categories=Categories
CategoryUploadImage=Upload Category Image
+CommonLessThan=less than
+CommonMoreThan=more than
CommonSurveys=Surveys
CommonVolume=Volume
ContentHtmlBody=Html Body
@@ -51,6 +53,7 @@
FacilityCompanyName=OFBiz: Facility Manager
FeatureTypes=Feature Types
Find=Find
+ListPriceRange=List Price Range
NoProductSpecifiedForUomConversion=Product-based UoM conversion requires a valid productId
OrderConfirm=Confirm
OrderFromOrder=from Order
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=512532&r1=512531&r2=512532
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearch.java Tue Feb 27 16:51:04 2007
@@ -1004,20 +1004,74 @@
public static final String constraintName = "ListPriceRange";
protected Double lowPrice;
protected Double highPrice;
+ protected String currencyUomId;
- public ListPriceRangeConstraint(Double lowPrice, Double highPrice) {
+ public ListPriceRangeConstraint(Double lowPrice, Double highPrice, String currencyUomId) {
this.lowPrice = lowPrice;
this.highPrice = highPrice;
+ this.currencyUomId = UtilValidate.isNotEmpty(currencyUomId) ? currencyUomId : "USD";
}
public void addConstraint(ProductSearchContext productSearchContext) {
- // TODO: implement ListPriceRangeConstraint makeEntityCondition
+ // make index based values and increment
+ String entityAlias = "PP" + productSearchContext.index;
+ String prefix = "pp" + productSearchContext.index;
+ productSearchContext.index++;
+
+ productSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "ProductPrice");
+
+ productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductPriceTypeId", "productPriceTypeId", null, null, null, null);
+ productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductPricePurposeId", "productPricePurposeId", null, null, null, null);
+ productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "CurrencyUomId", "currencyUomId", null, null, null, null);
+ productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "ProductStoreGroupId", "productStoreGroupId", 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.addAlias(entityAlias, prefix + "Price", "price", null, null, null, null);
+
+ productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));
+
+ productSearchContext.entityConditionList.add(new EntityExpr(prefix + "ProductPriceTypeId", EntityOperator.EQUALS, "LIST_PRICE"));
+ productSearchContext.entityConditionList.add(new EntityExpr(prefix + "ProductPricePurposeId", EntityOperator.EQUALS, "PURCHASE"));
+ productSearchContext.entityConditionList.add(new EntityExpr(prefix + "CurrencyUomId", EntityOperator.EQUALS, currencyUomId));
+ productSearchContext.entityConditionList.add(new EntityExpr(prefix + "ProductStoreGroupId", EntityOperator.EQUALS, "_NA_"));
+ 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));
+ if (this.lowPrice != null) {
+ productSearchContext.entityConditionList.add(new EntityExpr(prefix + "Price", EntityOperator.GREATER_THAN_EQUAL_TO, this.lowPrice));
+ }
+ if (this.highPrice != null) {
+ productSearchContext.entityConditionList.add(new EntityExpr(prefix + "Price", EntityOperator.LESS_THAN_EQUAL_TO, this.highPrice));
+ }
+
+ // 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", "low [" + this.lowPrice + "] high [" + this.highPrice + "] currency [" + this.currencyUomId + "]")));
}
- /** pretty print for log messages and even UI stuff */
public String prettyPrintConstraint(GenericDelegator delegator, boolean detailed, Locale locale) {
- // TODO: implement the pretty print for log messages and even UI stuff
- return null;
+ if (this.lowPrice == null && this.highPrice == null) {
+ // dummy constraint, no values
+ return null;
+ }
+ StringBuffer msgBuf = new StringBuffer();
+ msgBuf.append(UtilProperties.getMessage(resource, "ListPriceRange", locale));
+ msgBuf.append(": ");
+
+ // NOTE: at this point we know that only one or none are null
+ if (this.lowPrice == null) {
+ msgBuf.append(UtilProperties.getMessage(resource, "CommonLessThan", locale));
+ msgBuf.append(" ");
+ msgBuf.append(this.highPrice);
+ } else if (this.highPrice == null) {
+ msgBuf.append(UtilProperties.getMessage(resource, "CommonMoreThan", locale));
+ msgBuf.append(" ");
+ msgBuf.append(this.lowPrice);
+ } else {
+ msgBuf.append(this.lowPrice);
+ msgBuf.append(" - ");
+ msgBuf.append(this.highPrice);
+ }
+ return msgBuf.toString();
}
public boolean equals(Object obj) {
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=512532&r1=512531&r2=512532
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchSession.java Tue Feb 27 16:51:04 2007
@@ -401,6 +401,7 @@
}
HttpSession session = request.getSession();
boolean constraintsChanged = false;
+ GenericValue productStore = ProductStoreWorker.getProductStore(request);
// clear search? by default yes, but if the clearSearch parameter is N then don't
String clearSearchString = (String) parameters.get("clearSearch");
@@ -488,8 +489,30 @@
constraintsChanged = true;
}
+ // add a list price range to the search
+ if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_LOW")) || UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_HIGH"))) {
+ Double listPriceLow = null;
+ Double listPriceHigh = null;
+ String listPriceCurrency = UtilHttp.getCurrencyUom(request);
+ if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_LOW"))) {
+ try {
+ listPriceLow = Double.valueOf((String) parameters.get("LIST_PRICE_LOW"));
+ } catch (NumberFormatException e) {
+ Debug.logError("Error parsing LIST_PRICE_LOW parameter [" + (String) parameters.get("LIST_PRICE_LOW") + "]: " + e.toString(), module);
+ }
+ }
+ if (UtilValidate.isNotEmpty((String) parameters.get("LIST_PRICE_HIGH"))) {
+ try {
+ listPriceHigh = Double.valueOf((String) parameters.get("LIST_PRICE_HIGH"));
+ } catch (NumberFormatException e) {
+ Debug.logError("Error parsing LIST_PRICE_HIGH parameter [" + (String) parameters.get("LIST_PRICE_HIGH") + "]: " + e.toString(), module);
+ }
+ }
+ searchAddConstraint(new ProductSearch.ListPriceRangeConstraint(listPriceLow, listPriceHigh, listPriceCurrency), 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;