svn commit: r759254 [2/4] - in /ofbiz/trunk/applications/product/src: ./ org/ofbiz/product/catalog/ org/ofbiz/product/category/ org/ofbiz/product/config/ org/ofbiz/product/feature/ org/ofbiz/product/inventory/ org/ofbiz/product/price/ org/ofbiz/product...

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

svn commit: r759254 [2/4] - in /ofbiz/trunk/applications/product/src: ./ org/ofbiz/product/catalog/ org/ofbiz/product/category/ org/ofbiz/product/config/ org/ofbiz/product/feature/ org/ofbiz/product/inventory/ org/ofbiz/product/price/ org/ofbiz/product...

doogie-3
Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryServices.java Fri Mar 27 17:01:36 2009
@@ -53,9 +53,9 @@
  * Inventory Services
  */
 public class InventoryServices {
-
+
     public final static String module = InventoryServices.class.getName();
-
+
     public static final MathContext generalRounding = new MathContext(10);
 
     public static Map<String, Object> prepareInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) {
@@ -65,43 +65,43 @@
         GenericValue inventoryItem = null;
         GenericValue newItem = null;
         GenericValue userLogin = (GenericValue) context.get("userLogin");
-
+
         try {
             inventoryItem = delegator.findByPrimaryKey("InventoryItem", UtilMisc.toMap("inventoryItemId", inventoryItemId));
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError("Inventory item lookup problem [" + e.getMessage() + "]");
         }
-
+
         if (inventoryItem == null) {
             return ServiceUtil.returnError("Cannot locate inventory item.");
         }
 
         try {
             Map<String, Object> results = ServiceUtil.returnSuccess();
-
+
             String inventoryType = inventoryItem.getString("inventoryItemTypeId");
             if (inventoryType.equals("NON_SERIAL_INV_ITEM")) {
                 BigDecimal atp = inventoryItem.getBigDecimal("availableToPromiseTotal");
                 BigDecimal qoh = inventoryItem.getBigDecimal("quantityOnHandTotal");
-
+
                 if (atp == null) {
                     return ServiceUtil.returnError("The request transfer amount is not available, there is no available to promise on the Inventory Item with ID " + inventoryItem.getString("inventoryItemId"));
                 }
                 if (qoh == null) {
                     qoh = atp;
                 }
-
+
                 // first make sure we have enough to cover the request transfer amount
                 if (xferQty.compareTo(atp) > 0) {
                     return ServiceUtil.returnError("The request transfer amount is not available, the available to promise [" + atp + "] is not sufficient for the desired transfer quantity [" + xferQty + "] on the Inventory Item with ID " + inventoryItem.getString("inventoryItemId"));
                 }
-
+
                 /*
                  * atp < qoh - split and save the qoh - atp
                  * xferQty < atp - split and save atp - xferQty
                  * atp < qoh && xferQty < atp - split and save qoh - atp + atp - xferQty
                  */
-
+
                 // at this point we have already made sure that the xferQty is less than or equals to the atp, so if less that just create a new inventory record for the quantity to be moved
                 // NOTE: atp should always be <= qoh, so if xfer < atp, then xfer < qoh, so no need to check/handle that
                 // however, if atp < qoh && atp == xferQty, then we still need to split; oh, but no need to check atp == xferQty in the second part because if it isn't greater and isn't less, then it is equal
@@ -115,17 +115,17 @@
                     newItem = GenericValue.create(inventoryItem);
                     newItem.set("availableToPromiseTotal", BigDecimal.ZERO);
                     newItem.set("quantityOnHandTotal", BigDecimal.ZERO);
-
+
                     delegator.createSetNextSeqId(newItem);
-
+
                     results.put("inventoryItemId", newItem.get("inventoryItemId"));
-
+
                     // TODO: how do we get this here: "inventoryTransferId", inventoryTransferId
                     Map<String, Object> createNewDetailMap = UtilMisc.toMap("availableToPromiseDiff", xferQty, "quantityOnHandDiff", xferQty,
                             "inventoryItemId", newItem.get("inventoryItemId"), "userLogin", userLogin);
                     Map<String, Object> createUpdateDetailMap = UtilMisc.toMap("availableToPromiseDiff", negXferQty, "quantityOnHandDiff", negXferQty,
                             "inventoryItemId", inventoryItem.get("inventoryItemId"), "userLogin", userLogin);
-
+
                     try {
                         Map<String, Object> resultNew = dctx.getDispatcher().runSync("createInventoryItemDetail", createNewDetailMap);
                         if (ServiceUtil.isError(resultNew)) {
@@ -146,7 +146,7 @@
                     return ServiceUtil.returnError("Serialized inventory is not available for transfer.");
                 }
             }
-
+
             // setup values so that no one will grab the inventory during the move
             // if newItem is not null, it is the item to be moved, otherwise the original inventoryItem is the one to be moved
             if (inventoryType.equals("NON_SERIAL_INV_ITEM")) {
@@ -181,13 +181,13 @@
                     results.put("inventoryItemId", inventoryItem.get("inventoryItemId"));
               }
             }
-
+
             return results;
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError("Inventory store/create problem [" + e.getMessage() + "]");
         }
     }
-
+
     public static Map<String, Object> completeInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         String inventoryTransferId = (String) context.get("inventoryTransferId");
@@ -195,7 +195,7 @@
         GenericValue inventoryItem = null;
         GenericValue destinationFacility = null;
         GenericValue userLogin = (GenericValue) context.get("userLogin");
-
+
         try {
             inventoryTransfer = delegator.findByPrimaryKey("InventoryTransfer",
                     UtilMisc.toMap("inventoryTransferId", inventoryTransferId));
@@ -204,18 +204,18 @@
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError("Inventory Item/Transfer lookup problem [" + e.getMessage() + "]");
         }
-
+
         if (inventoryTransfer == null || inventoryItem == null) {
             return ServiceUtil.returnError("ERROR: Lookup of InventoryTransfer and/or InventoryItem failed!");
         }
-
+
         String inventoryType = inventoryItem.getString("inventoryItemTypeId");
-
+
         // set the fields on the transfer record
         if (inventoryTransfer.get("receiveDate") == null) {
             inventoryTransfer.set("receiveDate", UtilDateTime.nowTimestamp());
         }
-
+
         if (inventoryType.equals("NON_SERIAL_INV_ITEM")) {
             // add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP
             BigDecimal atp = inventoryItem.get("availableToPromiseTotal") == null ? BigDecimal.ZERO : inventoryItem.getBigDecimal("availableToPromiseTotal");
@@ -270,17 +270,17 @@
 
         // set the inventory transfer record to complete
         inventoryTransfer.set("statusId", "IXF_COMPLETE");
-
+
         // store the entities
         try {
             inventoryTransfer.store();
         } catch (GenericEntityException e) {
             return ServiceUtil.returnError("Inventory store problem [" + e.getMessage() + "]");
         }
-
+
         return ServiceUtil.returnSuccess();
     }
-
+
     public static Map<String, Object> cancelInventoryTransfer(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
         String inventoryTransferId = (String) context.get("inventoryTransferId");
@@ -302,9 +302,9 @@
         if (inventoryTransfer == null || inventoryItem == null) {
             return ServiceUtil.returnError("ERROR: Lookup of InventoryTransfer and/or InventoryItem failed!");
         }
-
+
         String inventoryType = inventoryItem.getString("inventoryItemTypeId");
-
+
         // re-set the fields on the item
         if (inventoryType.equals("NON_SERIAL_INV_ITEM")) {
             // add an adjusting InventoryItemDetail so set ATP back to QOH: ATP = ATP + (QOH - ATP), diff = QOH - ATP
@@ -357,10 +357,10 @@
             return ServiceUtil.returnSuccess();
         }
         */
-
+
         Map<String, Map<String, Timestamp>> ordersToUpdate = FastMap.newInstance();
         Map<String, Map<String, Timestamp>> ordersToCancel = FastMap.newInstance();
-
+
         // find all inventory items w/ a negative ATP
         List<GenericValue> inventoryItems = null;
         try {
@@ -370,14 +370,14 @@
             Debug.logError(e, "Trouble getting inventory items", module);
             return ServiceUtil.returnError("Problem getting InventoryItem records");
         }
-
+
         if (inventoryItems == null) {
             Debug.logInfo("No items out of stock; no backorders to worry about", module);
             return ServiceUtil.returnSuccess();
         }
-
+
         Debug.log("OOS Inventory Items: " + inventoryItems.size(), module);
-
+
         for (GenericValue inventoryItem: inventoryItems) {
             // get the incomming shipment information for the item
             List<GenericValue> shipmentAndItems = null;
@@ -394,7 +394,7 @@
                 Debug.logError(e, "Problem getting ShipmentAndItem records", module);
                 return ServiceUtil.returnError("Problem getting ShipmentAndItem records");
             }
-
+
             // get the reservations in order of newest first
             List<GenericValue> reservations = null;
             try {
@@ -403,17 +403,17 @@
                 Debug.logError(e, "Problem getting related reservations", module);
                 return ServiceUtil.returnError("Problem getting related reservations");
             }
-
+
             if (reservations == null) {
                 Debug.logWarning("No outstanding reservations for this inventory item, why is it negative then?", module);
                 continue;
             }
-
+
             Debug.log("Reservations for item: " + reservations.size(), module);
-
+
             // available at the time of order
             BigDecimal availableBeforeReserved = inventoryItem.getBigDecimal("availableToPromiseTotal");
-
+
             // go through all the reservations in order
             for (GenericValue reservation: reservations) {
                 String orderId = reservation.getString("orderId");
@@ -429,9 +429,9 @@
                         actualPromiseDate = reservation.getTimestamp("reservedDatetime");
                     }
                 }
-
+
                 Debug.log("Promised Date: " + actualPromiseDate, module);
-
+
                 // find the next possible ship date
                 Timestamp nextShipDate = null;
                 BigDecimal availableAtTime = BigDecimal.ZERO;
@@ -442,19 +442,19 @@
                         break;
                     }
                 }
-
+
                 Debug.log("Next Ship Date: " + nextShipDate, module);
-
+
                 // create a modified promise date (promise date - 1 day)
                 Calendar pCal = Calendar.getInstance();
                 pCal.setTimeInMillis(actualPromiseDate.getTime());
                 pCal.add(Calendar.DAY_OF_YEAR, -1);
                 Timestamp modifiedPromisedDate = new Timestamp(pCal.getTimeInMillis());
                 Timestamp now = UtilDateTime.nowTimestamp();
-
+
                 Debug.log("Promised Date + 1: " + modifiedPromisedDate, module);
                 Debug.log("Now: " + now, module);
-
+
                 // check the promised date vs the next ship date
                 if (nextShipDate == null || nextShipDate.after(actualPromiseDate)) {
                     if (nextShipDate == null && modifiedPromisedDate.after(now)) {
@@ -469,13 +469,13 @@
                         }
                         notifyItems.put(orderItemSeqId, nextShipDate);
                         ordersToUpdate.put(orderId, notifyItems);
-
+
                         // need to know if nextShipDate is more then 30 days after promised
                         Calendar sCal = Calendar.getInstance();
                         sCal.setTimeInMillis(actualPromiseDate.getTime());
                         sCal.add(Calendar.DAY_OF_YEAR, 30);
                         Timestamp farPastPromised = new Timestamp(sCal.getTimeInMillis());
-
+
                         // check to see if this is >30 days or second run, if so flag to cancel
                         boolean needToCancel = false;
                         if (nextShipDate == null || nextShipDate.after(farPastPromised)) {
@@ -486,7 +486,7 @@
                             // this is the second notification; using cancel rule
                             needToCancel = true;
                         }
-
+
                         // add the info to the cancel map if we need to schedule a cancel
                         if (needToCancel) {
                             // queue the item to be cancelled
@@ -498,7 +498,7 @@
                             cancelItems.put(orderItemSeqId, farPastPromised);
                             ordersToCancel.put(orderId, cancelItems);
                         }
-
+
                         // store the updated promiseDate as the nextShipDate
                         try {
                             reservation.set("currentPromisedDate", nextShipDate);
@@ -508,12 +508,12 @@
                         }
                     }
                 }
-
+
                 // subtract our qty from reserved to get the next value
                 availableBeforeReserved = availableBeforeReserved.subtract(reservation.getBigDecimal("quantity"));
             }
         }
-
+
         // all items to cancel will also be in the notify list so start with that
         List<String> ordersToNotify = FastList.newInstance();
         for (Map.Entry<String, Map<String, Timestamp>> entry: ordersToUpdate.entrySet()) {
@@ -522,7 +522,7 @@
             Map<String, Timestamp> cancelItems = ordersToCancel.get(orderId);
             boolean cancelAll = false;
             Timestamp cancelAllTime = null;
-
+
             List<GenericValue> orderItemShipGroups = null;
             try {
                 orderItemShipGroups= delegator.findByAnd("OrderItemShipGroup",
@@ -530,7 +530,7 @@
             } catch (GenericEntityException e) {
                 Debug.logError(e, "Cannot get OrderItemShipGroups from orderId" + orderId, module);
             }
-
+
             for (GenericValue orderItemShipGroup: orderItemShipGroups) {
                 List<GenericValue> orderItems = FastList.newInstance();
                 List<GenericValue> orderItemShipGroupAssoc = null;
@@ -541,7 +541,7 @@
                                         orderItemShipGroup.get("shipGroupSeqId"),
                                         "orderId",
                                         orderId));
-
+
                     for (GenericValue assoc: orderItemShipGroupAssoc) {
                         GenericValue orderItem = assoc.getRelatedOne("OrderItem");
                         if (orderItem != null) {
@@ -551,26 +551,26 @@
                 } catch (GenericEntityException e) {
                      Debug.logError(e, "Problem fetching OrderItemShipGroupAssoc", module);
                 }
-
-
+
+
                 /* Check the split preference. */
                 boolean maySplit = false;
                 if (orderItemShipGroup != null && orderItemShipGroup.get("maySplit") != null) {
                     maySplit = orderItemShipGroup.getBoolean("maySplit").booleanValue();
                 }
-
+
                 /* Figure out if we must cancel all items. */
                 if (!maySplit && cancelItems != null) {
                     cancelAll = true;
                     Set<String> cancelSet = cancelItems.keySet();
                     cancelAllTime = cancelItems.get(cancelSet.iterator().next());
                 }
-
+
                 // if there are none to cancel just create an empty map
                 if (cancelItems == null) {
                     cancelItems = FastMap.newInstance();
                 }
-
+
                 if (orderItems != null) {
                     List<GenericValue> toBeStored = FastList.newInstance();
                     for (GenericValue orderItem: orderItems) {
@@ -578,11 +578,11 @@
                         Timestamp shipDate = (Timestamp) backOrderedItems.get(orderItemSeqId);
                         Timestamp cancelDate = (Timestamp) cancelItems.get(orderItemSeqId);
                         Timestamp currentCancelDate = orderItem.getTimestamp("autoCancelDate");
-
+
                         Debug.logError("OI: " + orderId + " SEQID: "+ orderItemSeqId + " cancelAll: " + cancelAll + " cancelDate: " + cancelDate, module);
                         if (backOrderedItems.containsKey(orderItemSeqId)) {
                             orderItem.set("estimatedShipDate", shipDate);
-
+
                             if (currentCancelDate == null) {
                                 if (cancelAll || cancelDate != null) {
                                     if (orderItem.get("dontCancelSetUserLogin") == null && orderItem.get("dontCancelSetDate") == null) {
@@ -607,11 +607,11 @@
                         }
                     }
                 }
-
-
+
+
             }
         }
-
+
         // send off a notification for each order
         for (String orderId: ordersToNotify) {
             try {
@@ -621,10 +621,10 @@
                 continue;
             }
         }
-
+
         return ServiceUtil.returnSuccess();
     }
-
+
     /**
      * Get Inventory Available for a Product based on the list of associated products.  The final ATP and QOH will
      * be the minimum of all the associated products' inventory divided by their ProductAssoc.quantity
@@ -634,26 +634,26 @@
         List<GenericValue> productAssocList = UtilGenerics.checkList(context.get("assocProducts"));
         String facilityId = (String)context.get("facilityId");
         String statusId = (String)context.get("statusId");
-
+
         BigDecimal availableToPromiseTotal = BigDecimal.ZERO;
         BigDecimal quantityOnHandTotal = BigDecimal.ZERO;
-
+
         if (UtilValidate.isNotEmpty(productAssocList)) {
             // minimum QOH and ATP encountered
             BigDecimal minQuantityOnHandTotal = null;
             BigDecimal minAvailableToPromiseTotal = null;
-
+
            // loop through each associated product.
            for (GenericValue productAssoc: productAssocList) {
                String productIdTo = productAssoc.getString("productIdTo");
                BigDecimal assocQuantity = productAssoc.getBigDecimal("quantity");
-
+
                // if there is no quantity for the associated product in ProductAssoc entity, default it to 1.0
                if (assocQuantity == null) {
                    Debug.logWarning("ProductAssoc from [" + productAssoc.getString("productId") + "] to [" + productAssoc.getString("productIdTo") + "] has no quantity, assuming 1.0", module);
                    assocQuantity = BigDecimal.ONE;
                }
-
+
                // figure out the inventory available for this associated product
                Map<String, Object> resultOutput = null;
                try {
@@ -668,7 +668,7 @@
                   Debug.logError(e, "Problems getting inventory available by facility", module);
                   return ServiceUtil.returnError(e.getMessage());
                }
-
+
                // Figure out what the QOH and ATP inventory would be with this associated product
                BigDecimal currentQuantityOnHandTotal = (BigDecimal) resultOutput.get("quantityOnHandTotal");
                BigDecimal currentAvailableToPromiseTotal = (BigDecimal) resultOutput.get("availableToPromiseTotal");
@@ -682,7 +682,7 @@
                if (minAvailableToPromiseTotal == null || tmpAvailableToPromiseTotal.compareTo(minAvailableToPromiseTotal) < 0) {
                    minAvailableToPromiseTotal = tmpAvailableToPromiseTotal;
                }
-
+
                if (Debug.verboseOn()) {
                    Debug.logVerbose("productIdTo = " + productIdTo + " assocQuantity = " + assocQuantity + "current QOH " + currentQuantityOnHandTotal +
                         "currentATP = " + currentAvailableToPromiseTotal + " minQOH = " + minQuantityOnHandTotal + " minATP = " + minAvailableToPromiseTotal, module);
@@ -692,7 +692,7 @@
           quantityOnHandTotal = minQuantityOnHandTotal;
           availableToPromiseTotal = minAvailableToPromiseTotal;
         }
-
+
         Map<String, Object> result = ServiceUtil.returnSuccess();
         result.put("availableToPromiseTotal", availableToPromiseTotal);
         result.put("quantityOnHandTotal", quantityOnHandTotal);
@@ -787,7 +787,7 @@
         results.put("mktgPkgQOHMap", mktgPkgQohMap);
         return results;
     }
-
+
 
     public static Map<String, Object> getProductInventoryAndFacilitySummary(DispatchContext dctx, Map<String, ? extends Object> context) {
         GenericDelegator delegator = dctx.getDelegator();
@@ -842,15 +842,15 @@
             availableToPromiseTotal = (BigDecimal)resultOutput.get("availableToPromiseTotal");
         }
         BigDecimal offsetATPQtyAvailable = availableToPromiseTotal.subtract(minimumStock);
-
+
         BigDecimal quantityOnOrder = InventoryWorker.getOutstandingPurchasedQuantity(productId, delegator);
         result.put("totalQuantityOnHand", resultOutput.get("quantityOnHandTotal").toString());
         result.put("totalAvailableToPromise", resultOutput.get("availableToPromiseTotal").toString());
         result.put("quantityOnOrder", quantityOnOrder);
-
+
         result.put("offsetQOHQtyAvailable", offsetQOHQtyAvailable);
         result.put("offsetATPQtyAvailable", offsetATPQtyAvailable);
-
+
         List<GenericValue> productPrices = null;
         try {
             productPrices = delegator.findByAndCache("ProductPrice", UtilMisc.toMap("productId",productId), UtilMisc.toList("-fromDate"));
@@ -872,11 +872,11 @@
                 result.put("wholeSalePrice", onePrice.getBigDecimal("price"));
             }
         }
-
+
         DynamicViewEntity salesUsageViewEntity = new DynamicViewEntity();
         DynamicViewEntity productionUsageViewEntity = new DynamicViewEntity();
         if (! UtilValidate.isEmpty(checkTime)) {
-
+
             // Construct a dynamic view entity to search against for sales usage quantities
             salesUsageViewEntity.addMemberEntity("OI", "OrderItem");
             salesUsageViewEntity.addMemberEntity("OH", "OrderHeader");
@@ -892,7 +892,7 @@
             salesUsageViewEntity.addAlias("ItIss", "inventoryItemId");
             salesUsageViewEntity.addAlias("ItIss", "quantity");
             salesUsageViewEntity.addAlias("InvIt", "facilityId");
-
+
             // Construct a dynamic view entity to search against for production usage quantities
             productionUsageViewEntity.addMemberEntity("WEIA", "WorkEffortInventoryAssign");
             productionUsageViewEntity.addMemberEntity("WE", "WorkEffort");
@@ -907,7 +907,7 @@
 
         }
         if (! UtilValidate.isEmpty(checkTime)) {
-
+
             // Make a query against the sales usage view entity
             EntityListIterator salesUsageIt = null;
             try {
@@ -926,7 +926,7 @@
                 // TODO Auto-generated catch block
                 e2.printStackTrace();
             }
-
+
             // Sum the sales usage quantities found
             BigDecimal salesUsageQuantity = BigDecimal.ZERO;
             GenericValue salesUsageItem = null;
@@ -945,7 +945,7 @@
                 // TODO Auto-generated catch block
                 e2.printStackTrace();
             }
-
+
             // Make a query against the production usage view entity
             EntityListIterator productionUsageIt = null;
             try {
@@ -963,7 +963,7 @@
                 // TODO Auto-generated catch block
                 e1.printStackTrace();
             }
-
+
             // Sum the production usage quantities found
             BigDecimal productionUsageQuantity = BigDecimal.ZERO;
             GenericValue productionUsageItem = null;
@@ -982,7 +982,7 @@
                 // TODO Auto-generated catch block
                 e.printStackTrace();
             }
-
+
             result.put("usageQuantity", salesUsageQuantity.add(productionUsageQuantity));
 
         }

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/inventory/InventoryWorker.java Fri Mar 27 17:01:36 2009
@@ -38,7 +38,7 @@
 import org.ofbiz.entity.condition.EntityOperator;
 
 public class InventoryWorker {
-
+
     public final static String module = InventoryWorker.class.getName();
 
     /**
@@ -65,7 +65,7 @@
             return null;
         }
     }
-
+
     /**
      * Finds the net outstanding ordered quantity for a productId, netting quantity on outstanding purchase orders against cancelQuantity
      * @param productId

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/price/PriceServices.java Fri Mar 27 17:01:36 2009
@@ -96,7 +96,7 @@
         String checkIncludeVat = (String) context.get("checkIncludeVat");
         String surveyResponseId = (String) context.get("surveyResponseId");
         Map<String, Object> customAttributes = UtilGenerics.checkMap(context.get("customAttributes"));
-
+
         String findAllQuantityPricesStr = (String) context.get("findAllQuantityPrices");
         boolean findAllQuantityPrices = "Y".equals(findAllQuantityPricesStr);
 
@@ -139,7 +139,7 @@
                 productStoreGroupId = "_NA_";
             }
         }
-
+
         // if currencyUomId is null get from properties file, if nothing there assume USD (USD: American Dollar) for now
         String currencyUomId = (String) context.get("currencyUomId");
         if (UtilValidate.isEmpty(currencyUomId)) {
@@ -151,7 +151,7 @@
         if (UtilValidate.isEmpty(productPricePurposeId)) {
             productPricePurposeId = "PURCHASE";
         }
-
+
         // termUomId, for things like recurring prices specifies the term (time/frequency measure for example) of the recurrence
         // if this is empty it will simply not be used to constrain the selection
         String termUomId = (String) context.get("termUomId");
@@ -566,7 +566,7 @@
                     nonQuantityProductPriceRules = FastList.newInstance();
                     for (GenericValue productPriceRule: allProductPriceRules) {
                         List<GenericValue> productPriceCondList = delegator.findByAndCache("ProductPriceCond", UtilMisc.toMap("productPriceRuleId", productPriceRule.get("productPriceRuleId")));
-
+
                         boolean foundQuantityInputParam = false;
                         // only consider a rule if all conditions except the quantity condition are true
                         boolean allExceptQuantTrue = true;
@@ -579,7 +579,7 @@
                                 }
                             }
                         }
-
+
                         if (foundQuantityInputParam && allExceptQuantTrue) {
                             quantityProductPriceRules.add(productPriceRule);
                         } else {
@@ -590,14 +590,14 @@
 
                 if (findAllQuantityPrices) {
                     List<Map<String, Object>> allQuantityPrices = FastList.newInstance();
-
+
                     // if findAllQuantityPrices then iterate through quantityProductPriceRules
                     // foreach create an entry in the out list and eval that rule and all nonQuantityProductPriceRules rather than a single rule
                     for (GenericValue quantityProductPriceRule: quantityProductPriceRules) {
                         List<GenericValue> ruleListToUse = FastList.newInstance();
                         ruleListToUse.add(quantityProductPriceRule);
                         ruleListToUse.addAll(nonQuantityProductPriceRules);
-
+
                         Map<String, Object> quantCalcResults = calcPriceResultFromRules(ruleListToUse, listPrice, defaultPrice, promoPrice,
                             wholesalePrice, maximumPriceValue, minimumPriceValue, validPriceFound,
                             averageCostValue, productId, virtualProductId, prodCatalogId, productStoreGroupId,
@@ -605,10 +605,10 @@
                         Map<String, Object> quantErrorResult = addGeneralResults(quantCalcResults, competitivePriceValue, specialPromoPriceValue, productStore,
                             checkIncludeVat, currencyUomId, productId, quantity, partyId, dispatcher);
                         if (quantErrorResult != null) return quantErrorResult;
-
+
                         // also add the quantityProductPriceRule to the Map so it can be used for quantity break information
                         quantCalcResults.put("quantityProductPriceRule", quantityProductPriceRule);
-
+
                         allQuantityPrices.add(quantCalcResults);
                     }
                     result.put("allQuantityPrices", allQuantityPrices);
@@ -659,7 +659,7 @@
         // utilTimer.timerString("Finished price calc [productId=" + productId + "]", module);
         return result;
     }
-
+
     public static Map<String, Object> addGeneralResults(Map<String, Object> result, GenericValue competitivePriceValue, GenericValue specialPromoPriceValue, GenericValue productStore,
         String checkIncludeVat, String currencyUomId, String productId, BigDecimal quantity, String partyId, LocalDispatcher dispatcher) {
         result.put("competitivePrice", competitivePriceValue != null ? competitivePriceValue.getBigDecimal("price") : null);
@@ -674,7 +674,7 @@
             if (UtilValidate.isNotEmpty(partyId)) {
                 calcTaxForDisplayContext.put("billToPartyId", partyId);
             }
-
+
             try {
                 Map<String, Object> calcTaxForDisplayResult = dispatcher.runSync("calcTaxForDisplay", calcTaxForDisplayContext);
                 if (ServiceUtil.isError(calcTaxForDisplayResult)) {
@@ -707,10 +707,10 @@
                 return ServiceUtil.returnError(errMsg);
             }
         }
-
+
         return null;
     }
-
+
     public static List<GenericValue> makeProducePriceRuleList(GenericDelegator delegator, boolean optimizeForLargeRuleSet, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId, String webSiteId, String partyId, String currencyUomId) throws GenericEntityException {
         List<GenericValue> productPriceRules = null;
 
@@ -856,20 +856,20 @@
             productPriceRules = delegator.findList("ProductPriceRule", null, null, null, null, true);
             if (productPriceRules == null) productPriceRules = FastList.newInstance();
         }
-
+
         return productPriceRules;
     }
-
+
     public static Map<String, Object> calcPriceResultFromRules(List<GenericValue> productPriceRules, BigDecimal listPrice, BigDecimal defaultPrice, BigDecimal promoPrice,
         BigDecimal wholesalePrice, GenericValue maximumPriceValue, GenericValue minimumPriceValue, boolean validPriceFound,
         GenericValue averageCostValue, String productId, String virtualProductId, String prodCatalogId, String productStoreGroupId,
         String webSiteId, String partyId, BigDecimal quantity, String currencyUomId, GenericDelegator delegator, Timestamp nowTimestamp) throws GenericEntityException {
-
+
         Map<String, Object> calcResults = FastMap.newInstance();
 
         List<GenericValue> orderItemPriceInfos = FastList.newInstance();
         boolean isSale = false;
-
+
         // ========= go through each price rule by id and eval all conditions =========
         // utilTimer.timerString("Before eval rules", module);
         int totalConds = 0;
@@ -882,7 +882,7 @@
 
         // calculate running sum based on listPrice and rules found
         BigDecimal price = listPrice;
-
+
         for (GenericValue productPriceRule: productPriceRules) {
             String productPriceRuleId = productPriceRule.getString("productPriceRuleId");
 
@@ -1102,7 +1102,7 @@
         calcResults.put("orderItemPriceInfos", orderItemPriceInfos);
         calcResults.put("isSale", Boolean.valueOf(isSale));
         calcResults.put("validPriceFound", Boolean.valueOf(validPriceFound));
-
+
         return calcResults;
     }
 
@@ -1143,7 +1143,7 @@
             }
         } else if ("PRIP_PROD_FEAT_ID".equals(productPriceCond.getString("inputParamEnumId"))) {
             // NOTE: DEJ20070130 don't retry this condition with the virtualProductId as well; this breaks various things you might want to do with price rules, like have different pricing for a variant products with a certain distinguishing feature
-
+
             // if a ProductFeatureAppl exists for this productId and the specified productFeatureId
             String productFeatureId = productPriceCond.getString("condValue");
             List<GenericValue> productFeatureAppls = delegator.findByAndCache("ProductFeatureAppl",
@@ -1297,7 +1297,7 @@
         String currencyUomId = (String)context.get("currencyUomId");
         String partyId = (String)context.get("partyId");
         BigDecimal quantity = (BigDecimal)context.get("quantity");
-
+
         // a) Get the Price from the Agreement* data model
         // TODO: Implement this
 

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/KeywordIndex.java Fri Mar 27 17:01:36 2009
@@ -44,7 +44,7 @@
  *  Does indexing in preparation for a keyword search.
  */
 public class KeywordIndex {
-
+
     public static final String module = KeywordIndex.class.getName();
 
     public static void forceIndexKeywords(GenericValue product) throws GenericEntityException {
@@ -58,7 +58,7 @@
     public static void indexKeywords(GenericValue product, boolean doAll) throws GenericEntityException {
         if (product == null) return;
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
-
+
         if (!doAll) {
             if ("N".equals(product.getString("autoCreateKeywords"))) {
                 return;
@@ -72,7 +72,7 @@
                 return;
             }
         }
-
+
         GenericDelegator delegator = product.getDelegator();
         if (delegator == null) return;
         String productId = product.getString("productId");
@@ -83,7 +83,7 @@
         String stopWordBagAnd = KeywordSearchUtil.getStopWordBagAnd();
         boolean removeStems = KeywordSearchUtil.getRemoveStems();
         Set<String> stemSet = KeywordSearchUtil.getStemSet();
-
+
         Map<String, Long> keywords = new TreeMap<String, Long>();
         List<String> strings = FastList.newInstance();
 
@@ -142,7 +142,7 @@
                 addWeightedKeywordSourceString(goodIdentification, "idValue", strings);
             }
         }
-
+
         // Variant Product IDs
         if ("Y".equals(product.getString("isVirtual"))) {
             if (!"0".equals(UtilProperties.getPropertyValue("prodsearch", "index.weight.Variant.Product.productId", "0"))) {
@@ -161,7 +161,7 @@
                 }
             }
         }
-
+
         String productContentTypes = UtilProperties.getPropertyValue("prodsearch", "index.include.ProductContentTypes");
         for (String productContentTypeId: productContentTypes.split(",")) {
             int weight = 1;
@@ -171,11 +171,11 @@
             } catch (Exception e) {
                 Debug.logWarning("Could not parse weight number: " + e.toString(), module);
             }
-
+
             List<GenericValue> productContentAndInfos = delegator.findByAnd("ProductContentAndInfo", UtilMisc.toMap("productId", productId, "productContentTypeId", productContentTypeId), null);
             for (GenericValue productContentAndInfo: productContentAndInfos) {
                 addWeightedDataResourceString(productContentAndInfo, weight, strings, delegator, product);
-
+
                 List<GenericValue> alternateViews = productContentAndInfo.getRelated("ContentAssocDataResourceViewTo", UtilMisc.toMap("caContentAssocTypeId", "ALTERNATE_LOCALE"), UtilMisc.toList("-caFromDate"));
                 alternateViews = EntityUtil.filterByDate(alternateViews, UtilDateTime.nowTimestamp(), "caFromDate", "caThruDate", true);
                 for (GenericValue thisView: alternateViews) {
@@ -183,7 +183,7 @@
                 }
             }
         }
-
+
         for (String str: strings) {
             // call process keywords method here
             KeywordSearchUtil.processKeywordsForIndex(str, keywords, separators, stopWordBagAnd, stopWordBagOr, removeStems, stemSet);
@@ -205,7 +205,7 @@
             delegator.storeAll(toBeStored);
         }
     }
-
+
     public static void addWeightedDataResourceString(GenericValue drView, int weight, List<String> strings, GenericDelegator delegator, GenericValue product) {
         Map<String, GenericValue> drContext = UtilMisc.toMap("product", product);
         try {

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductContentWrapper.java Fri Mar 27 17:01:36 2009
@@ -50,12 +50,12 @@
  * Product Content Worker: gets product content to display
  */
 public class ProductContentWrapper implements ContentWrapper {
-
+
     public static final String module = ProductContentWrapper.class.getName();
     public static final String SEPARATOR = "::";    // cache key separator
-
+
     public static UtilCache<String, String> productContentCache = new UtilCache<String, String>("product.content.rendered", true);
-
+
     public static ProductContentWrapper makeProductContentWrapper(GenericValue product, HttpServletRequest request) {
         return new ProductContentWrapper(product, request);
     }
@@ -64,21 +64,21 @@
     protected GenericValue product;
     protected Locale locale;
     protected String mimeTypeId;
-
+
     public ProductContentWrapper(LocalDispatcher dispatcher, GenericValue product, Locale locale, String mimeTypeId) {
         this.dispatcher = dispatcher;
         this.product = product;
         this.locale = locale;
         this.mimeTypeId = mimeTypeId;
     }
-
+
     public ProductContentWrapper(GenericValue product, HttpServletRequest request) {
         this.dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         this.product = product;
         this.locale = UtilHttp.getLocale(request);
         this.mimeTypeId = "text/html";
     }
-
+
     public StringUtil.StringWrapper get(String productContentTypeId) {
         if (this.product == null) {
             Debug.logWarning("Tried to get ProductContent for type [" + productContentTypeId + "] but the product field in the ProductContentWrapper is null", module);
@@ -86,7 +86,7 @@
         }
         return StringUtil.makeStringWrapper(getProductContentAsText(this.product, productContentTypeId, locale, mimeTypeId, this.product.getDelegator(), dispatcher));
     }
-
+
     public static String getProductContentAsText(GenericValue product, String productContentTypeId, HttpServletRequest request) {
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         return getProductContentAsText(product, productContentTypeId, UtilHttp.getLocale(request), "text/html", product.getDelegator(), dispatcher);
@@ -95,12 +95,12 @@
     public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, LocalDispatcher dispatcher) {
         return getProductContentAsText(product, productContentTypeId, locale, null, null, dispatcher);
     }
-
+
     public static String getProductContentAsText(GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher) {
         if (product == null) {
             return null;
         }
-
+
         String candidateFieldName = ModelUtil.dbNameToVarName(productContentTypeId);
         /* caching: there is one cache created, "product.content"  Each product's content is cached with a key of
          * contentTypeId::locale::mimeType::productId, or whatever the SEPARATOR is defined above to be.
@@ -110,7 +110,7 @@
             if (productContentCache.get(cacheKey) != null) {
                 return productContentCache.get(cacheKey);
             }
-
+
             Writer outWriter = new StringWriter();
             getProductContentAsText(null, product, productContentTypeId, locale, mimeTypeId, delegator, dispatcher, outWriter);
             String outString = outWriter.toString();
@@ -133,16 +133,16 @@
             return candidateOut == null? "" : candidateOut;
         }
     }
-
+
     public static void getProductContentAsText(String productId, GenericValue product, String productContentTypeId, Locale locale, String mimeTypeId, GenericDelegator delegator, LocalDispatcher dispatcher, Writer outWriter) throws GeneralException, IOException {
         if (productId == null && product != null) {
             productId = product.getString("productId");
         }
-
+
         if (delegator == null && product != null) {
             delegator = product.getDelegator();
         }
-
+
         if (UtilValidate.isEmpty(mimeTypeId)) {
             mimeTypeId = "text/html";
         }
@@ -150,7 +150,7 @@
         if (delegator == null) {
             throw new GeneralRuntimeException("Unable to find a delegator to use!");
         }
-
+
         String candidateFieldName = ModelUtil.dbNameToVarName(productContentTypeId);
         ModelEntity productModel = delegator.getModelEntity("Product");
         if (productModel.isField(candidateFieldName)) {
@@ -175,7 +175,7 @@
                 }
             }
         }
-
+
         List<GenericValue> productContentList = delegator.findByAndCache("ProductContent", UtilMisc.toMap("productId", productId, "productContentTypeId", productContentTypeId), UtilMisc.toList("-fromDate"));
         productContentList = EntityUtil.filterByDate(productContentList);
         GenericValue productContent = EntityUtil.getFirst(productContentList);

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductEvents.java Fri Mar 27 17:01:36 2009
@@ -437,25 +437,25 @@
                         product.set("productWidth", UtilParse.parseBigDecimalForEntity(request.getParameter("productWidth")));
                         product.set("productDepth", UtilParse.parseBigDecimalForEntity(request.getParameter("productDepth")));
                         product.set("weight", UtilParse.parseBigDecimalForEntity(request.getParameter("weight")));
-
+
                         // default unit settings for shipping parameters
                         product.set("heightUomId", "LEN_in");
                         product.set("widthUomId", "LEN_in");
                         product.set("depthUomId", "LEN_in");
                         product.set("weightUomId", "WT_oz");
-
+
                         BigDecimal floz = UtilParse.parseBigDecimalForEntity(request.getParameter("~floz"));
                         BigDecimal ml = UtilParse.parseBigDecimalForEntity(request.getParameter("~ml"));
                         BigDecimal ntwt = UtilParse.parseBigDecimalForEntity(request.getParameter("~ntwt"));
                         BigDecimal grams = UtilParse.parseBigDecimalForEntity(request.getParameter("~grams"));
-
+
                         List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
                         setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
                         setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ml", "AMOUNT", ml);
                         setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_g", "AMOUNT", grams);
                         setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "WT_oz", "AMOUNT", ntwt);
                         product.store();
-
+
                     } catch (NumberFormatException nfe) {
                         String errMsg = "Shipping Dimensions and Weights must be numbers.";
                         request.setAttribute("_ERROR_MESSAGE_", errMsg);
@@ -478,7 +478,7 @@
                             BigDecimal ml = UtilParse.parseBigDecimalForEntity(request.getParameter("~ml" + attribIdx));
                             BigDecimal ntwt = UtilParse.parseBigDecimalForEntity(request.getParameter("~ntwt" + attribIdx));
                             BigDecimal grams = UtilParse.parseBigDecimalForEntity(request.getParameter("~grams" + attribIdx));
-
+
                             List<GenericValue> currentProductFeatureAndAppls = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureApplTypeId", "STANDARD_FEATURE")), true);
                             setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ozUS", "AMOUNT", floz);
                             setOrCreateProdFeature(delegator, productId, currentProductFeatureAndAppls, "VLIQ_ml", "AMOUNT", ml);
@@ -528,10 +528,10 @@
      */
     private static void setOrCreateProdFeature(GenericDelegator delegator, String productId, List<GenericValue> currentProductFeatureAndAppls,
                                           String uomId, String productFeatureTypeId, BigDecimal numberSpecified) throws GenericEntityException {
-
+
         GenericValue productFeatureType = delegator.findByPrimaryKey("ProductFeatureType", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId));
         GenericValue uom = delegator.findByPrimaryKey("Uom", UtilMisc.toMap("uomId", uomId));
-
+
         Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
 
         // filter list of features to the one we'll be editing
@@ -565,7 +565,7 @@
                 }
                 prodFeature.set("numberSpecified", numberSpecified);
                 prodFeature.set("description", numberSpecified.toString() + (uom == null ? "" : (" " + uom.getString("description"))));
-
+
                 // if there is a productFeatureCategory with the same id as the productFeatureType, use that category.
                 // otherwise, use a default category from the configuration
                 if (delegator.findByPrimaryKey("ProductFeatureCategory", UtilMisc.toMap("productFeatureCategoryId", productFeatureTypeId)) == null) {
@@ -591,7 +591,7 @@
         String variantProductId = request.getParameter("productId0");
         String useImagesProdId = request.getParameter("useImages");
         String productFeatureTypeId = request.getParameter("productFeatureTypeId");
-
+
         if (UtilValidate.isEmpty(productFeatureTypeId)) {
             String errMsg = "Error: please select a ProductFeature Type to add or update variant features.";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
@@ -607,7 +607,7 @@
                     request.setAttribute("_ERROR_MESSAGE_", errMsg);
                     return "error";
                 }
-
+
                 // check for variantProductId - this will mean that we have multiple variants to update
                 if (variantProductId != null) {
                     // multiple products, so use a numeric suffix to get them all
@@ -620,7 +620,7 @@
                         if ((description != null) && (description.trim().length() < 1)) {
                             description = null;
                         }
-
+
                         Set<String> variantDescRemoveToRemoveOnVirtual = FastSet.newInstance();
                         checkUpdateFeatureApplByDescription(variantProductId, variantProduct, description, productFeatureTypeId, productFeatureType, "STANDARD_FEATURE", nowTimestamp, delegator, null, variantDescRemoveToRemoveOnVirtual);
                         checkUpdateFeatureApplByDescription(productId, product, description, productFeatureTypeId, productFeatureType, "SELECTABLE_FEATURE", nowTimestamp, delegator, variantDescRemoveToRemoveOnVirtual, null);
@@ -637,7 +637,7 @@
                         variantProductId = request.getParameter("productId" + attribIdx);
                     } while (variantProductId != null);
                 }
-
+
                 TransactionUtil.commit(beganTransaction);
             } catch (GenericEntityException e) {
                 String errMsg = "Error updating quick admin selectable feature settings: " + e.toString();
@@ -654,7 +654,7 @@
         }
         return "success";
     }
-
+
     protected static void checkUpdateFeatureApplByDescription(String productId, GenericValue product, String description,
             String productFeatureTypeId, GenericValue productFeatureType, String productFeatureApplTypeId,
             Timestamp nowTimestamp, GenericDelegator delegator, Set<String> descriptionsToRemove, Set<String> descriptionsRemoved) throws GenericEntityException {
@@ -695,13 +695,13 @@
                                     foundFeatureOnVariant = true;
                                 }
                             }
-
+
                             if (foundFeatureOnVariant) {
                                 // don't remove this one!
                                 continue;
                             }
                         }
-
+
                         if (descriptionsRemoved != null) {
                             descriptionsRemoved.add(productFeatureAndAppl.getString("description"));
                         }
@@ -709,15 +709,15 @@
                         continue;
                     }
                 }
-
+
                 // we got here, is still a valid description associated with this product
                 descriptionsForThisType.add(productFeatureAndAppl.getString("description"));
             }
         }
-
+
         if (description != null && (productFeatureAndAppl == null || (productFeatureAndAppl != null && !descriptionsForThisType.contains(description)))) {
             // need to add an appl, and possibly the feature
-
+
             // see if a feature exists with the type and description specified (if doesn't exist will create later)
             String productFeatureId = null;
             List<GenericValue> existingProductFeatureList = delegator.findByAnd("ProductFeature", UtilMisc.toMap("productFeatureTypeId", productFeatureTypeId, "description", description));
@@ -731,7 +731,7 @@
                         UtilMisc.toMap("productFeatureId", productFeatureId,
                                 "productFeatureTypeId", productFeatureTypeId,
                                 "description", description));
-
+
                 // if there is a productFeatureCategory with the same id as the productFeatureType, use that category.
                 // otherwise, create a category for the feature type
                 if (delegator.findByPrimaryKey("ProductFeatureCategory", UtilMisc.toMap("productFeatureCategoryId", productFeatureTypeId)) == null) {
@@ -743,11 +743,11 @@
                 newProductFeature.set("productFeatureCategoryId", productFeatureTypeId);
                 newProductFeature.create();
             }
-
+
             // check to see if the productFeatureId is already attached to the virtual or variant, if not attach them...
             List<GenericValue> specificProductFeatureApplList = EntityUtil.filterByDate(delegator.findByAnd("ProductFeatureAppl", UtilMisc.toMap("productId", productId,
                     "productFeatureApplTypeId", productFeatureApplTypeId, "productFeatureId", productFeatureId)), true);
-
+
             if (specificProductFeatureApplList.size() == 0) {
                 delegator.create("ProductFeatureAppl",
                         UtilMisc.toMap("productId", productId,
@@ -800,7 +800,7 @@
         //GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
         String productId = request.getParameter("productId");
         String productFeatureId = request.getParameter("productFeatureId");
-
+
         if (UtilValidate.isEmpty(productId) || UtilValidate.isEmpty(productFeatureId)) {
             String errMsg = "Must specify both a productId [was:" + productId + "] and a productFeatureId [was:" + productFeatureId + "] to remove the feature from the product.";
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
@@ -935,7 +935,7 @@
             if (localeStr == null && productStore.get("defaultLocaleString") != null) {
                 localeStr = productStore.getString("defaultLocaleString");
             }
-
+
             UtilHttp.setCurrencyUom(session, currencyStr);
             UtilHttp.setLocale(request, localeStr);
 
@@ -994,7 +994,7 @@
             return "error";
         }
         String productStoreId = productStore.getString("productStoreId");
-
+
         GenericValue productStoreEmail = null;
         try {
             productStoreEmail = delegator.findByPrimaryKey("ProductStoreEmailSetting",
@@ -1015,7 +1015,7 @@
         if (UtilValidate.isEmpty(bodyScreenLocation)) {
             bodyScreenLocation = defaultScreenLocation;
         }
-
+
         Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
         paramMap.put("locale", UtilHttp.getLocale(request));
         paramMap.put("userLogin", session.getAttribute("userLogin"));

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?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- 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 27 17:01:36 2009
@@ -167,14 +167,14 @@
 
         public List<Set<String>> includeCategoryIdOrSetAndList = FastList.newInstance();
         public List<Set<String>> alwaysIncludeCategoryIdOrSetAndList = FastList.newInstance();
-
+
         public Set<String> includeFeatureIds = FastSet.newInstance();
         public Set<String> excludeFeatureIds = FastSet.newInstance();
         public Set<String> alwaysIncludeFeatureIds = FastSet.newInstance();
 
         public List<Set<String>> includeFeatureIdOrSetAndList = FastList.newInstance();
         public List<Set<String>> alwaysIncludeFeatureIdOrSetAndList = FastList.newInstance();
-
+
         public Set<String> includeFeatureCategoryIds = FastSet.newInstance();
         public Set<String> excludeFeatureCategoryIds = FastSet.newInstance();
         public Set<String> alwaysIncludeFeatureCategoryIds = FastSet.newInstance();
@@ -231,7 +231,7 @@
                     Debug.logError(e, "Error closing ProductSearch EntityListIterator");
                 }
             }
-
+
             long endMillis = System.currentTimeMillis();
             double totalSeconds = ((double)endMillis - (double)startMillis)/1000.0;
 
@@ -341,18 +341,18 @@
                     includeFeatureGroupIds.size() == 0 && excludeFeatureGroupIds.size() == 0 && alwaysIncludeFeatureGroupIds.size() == 0) {
                 return;
             }
-
+
             // create new view members with logic:
             // ((each Id = category includes AND Id IN feature includes) AND (Id NOT IN category excludes AND Id NOT IN feature excludes))
             // OR (each Id = category alwaysIncludes AND each Id = feature alwaysIncludes)
             List<EntityCondition> incExcCondList = FastList.newInstance();
             EntityCondition incExcCond = null;
-
+
             List<EntityCondition> alwIncCondList = FastList.newInstance();
             EntityCondition alwIncCond = null;
-
+
             EntityCondition topCond = null;
-
+
             if (includeCategoryIds.size() > 0) {
                 for (String includeCategoryId: includeCategoryIds) {
                     String categoryPrefix = "pcm" + this.index;
@@ -429,7 +429,7 @@
                     incExcCondList.add(EntityCondition.makeCondition(otherFeaturePrefix + "ProductFeatureGroupId", EntityOperator.EQUALS, includeFeatureGroupId));
                 }
             }
-
+
             if (excludeCategoryIds.size() > 0) {
                 List<EntityCondition> idExcludeCondList = FastList.newInstance();
                 idExcludeCondList.add(EntityCondition.makeCondition(EntityCondition.makeCondition("thruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, this.nowTimestamp)));
@@ -464,12 +464,12 @@
                 EntityConditionValue subSelCond = new EntityConditionSubSelect("ProdFeaGrpAppAndProdFeaApp", "productId", EntityCondition.makeCondition(idExcludeCondList, EntityOperator.AND), true, delegator);
                 incExcCondList.add(EntityCondition.makeCondition("mainProductId", EntityOperator.NOT_EQUAL, subSelCond));
             }
-
+
             if (alwaysIncludeCategoryIds.size() > 0) {
                 String categoryPrefix = "pcm" + this.index;
                 String entityAlias = "PCM" + this.index;
                 this.index++;
-
+
                 this.dynamicViewEntity.addMemberEntity(entityAlias, "ProductCategoryMember");
                 this.dynamicViewEntity.addAlias(entityAlias, categoryPrefix + "ProductCategoryId", "productCategoryId", null, null, null, null);
                 this.dynamicViewEntity.addAlias(entityAlias, categoryPrefix + "FromDate", "fromDate", null, null, null, null);
@@ -620,18 +620,18 @@
             } else if (alwIncCond != null) {
                 topCond = alwIncCond;
             }
-
+
             this.entityConditionList.add(topCond);
-
+
             Debug.logInfo("topCond=" + topCond.makeWhereString(null, FastList.<EntityConditionParam>newInstance(), EntityConfigUtil.getDatasourceInfo(delegator.getEntityHelperName("Product"))), module);
         }
-
+
         public EntityListIterator doQuery(GenericDelegator delegator) {
             // handle the now assembled or and and keyword fixed lists
             this.finishKeywordConstraints();
 
             this.finishCategoryAndFeatureConstraints();
-
+
             if (resultSortOrder != null) {
                 resultSortOrder.setSortOrder(this);
             }
@@ -663,7 +663,7 @@
             try {
                 boolean hasResults = false;
                 Object initialResult = null;
-
+
                 /* this method has been replaced by the following to address issue with SAP DB and possibly other DBs
                 if (resultOffset != null) {
                     Debug.logInfo("Before relative, current index=" + eli.currentIndex(), module);
@@ -685,7 +685,7 @@
                     hasResults = eli.relative(resultOffset.intValue() - 1);
                     initialResult = null;
                 }
-
+
                 // get the first as the current one
                 GenericValue searchResult = null;
                 if (hasResults) {
@@ -706,13 +706,13 @@
                     return productIds;
                 }
 
-
+
                 // init numRetreived to one since we have already grabbed the initial one
                 int numRetreived = 1;
                 int duplicatesFound = 0;
 
                 Set<String> productIdSet = FastSet.newInstance();
-
+
                 productIds.add(searchResult.getString("mainProductId"));
                 productIdSet.add(searchResult.getString("mainProductId"));
 
@@ -725,7 +725,7 @@
                     } else {
                         duplicatesFound++;
                     }
-
+
                     /*
                     StringBuilder lineMsg = new StringBuilder("Got search result line: ");
                     for (String fieldName: fieldsToSelect) {
@@ -818,29 +818,29 @@
         /** pretty print for log messages and even UI stuff */
         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 List<GenericValue> productCategories;
-
+
         public CatalogConstraint(String prodCatalogId, List<GenericValue> productCategories) {
             this.prodCatalogId = prodCatalogId;
             this.productCategories = productCategories;
         }
-
+
         public void addConstraint(ProductSearchContext productSearchContext) {
             List<String> productCategoryIds = FastList.newInstance();
             for (GenericValue category: productCategories) {
                 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);
@@ -848,11 +848,11 @@
             productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));            productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductCategoryId", EntityOperator.IN, productCategoryIds));
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition(EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition(prefix + "ThruDate", EntityOperator.GREATER_THAN, productSearchContext.nowTimestamp)));
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition(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;
@@ -868,7 +868,7 @@
             }
             return ppBuf.toString();
         }
-
+
         public boolean equals(Object obj) {
             ProductSearchConstraint psc = (ProductSearchConstraint) obj;
             if (psc instanceof CatalogConstraint) {
@@ -888,7 +888,7 @@
             }
         }
     }
-
+
     public static class CategoryConstraint extends ProductSearchConstraint {
         public static final String constraintName = "Category";
         protected String productCategoryId;
@@ -925,7 +925,7 @@
             } else if (exclude.equals(Boolean.FALSE)) {
                 productSearchContext.alwaysIncludeCategoryIdOrSetAndList.add(productCategoryIdSet);
             }
-
+
             // 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.productCategoryId, "includeSubCategories", this.includeSubCategories ? "Y" : "N")));
         }
@@ -1059,7 +1059,7 @@
         }
     }
 
-
+
     public static class FeatureCategoryConstraint extends ProductSearchConstraint {
         public static final String constraintName = "FeatureCategory";
         protected String productFeatureCategoryId;
@@ -1105,7 +1105,7 @@
                 } else {
                     ppBuf.append("[").append(this.productFeatureCategoryId).append("]");
                 }
-
+
             }
             if (this.exclude != null) {
                 if (Boolean.TRUE.equals(this.exclude)) {
@@ -1213,7 +1213,7 @@
         }
     }
 
-
+
     public static class FeatureSetConstraint extends ProductSearchConstraint {
         public static final String constraintName = "Feature Set";
         protected Set<String> productFeatureIdSet;
@@ -1249,7 +1249,7 @@
                 }
                 featureIdInfo.append(featureId);
             }
-
+
             productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint", UtilMisc.toMap("constraintName", constraintName, "infoString", featureIdInfo.toString())));
         }
 
@@ -1275,12 +1275,12 @@
                     } else {
                         infoOut.append(productFeature.getString("description"));
                     }
-
+
                 }
             } catch (GenericEntityException e) {
                 Debug.logError(e, "Error finding ProductFeature and Type information for constraint pretty print", module);
             }
-
+
             return infoOut.toString();
         }
 
@@ -1545,7 +1545,7 @@
             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);
@@ -1555,7 +1555,7 @@
             productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "Price", "price", null, null, null, null);
 
             productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));
-
+
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductPriceTypeId", EntityOperator.EQUALS, "LIST_PRICE"));
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "ProductPricePurposeId", EntityOperator.EQUALS, "PURCHASE"));
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "CurrencyUomId", EntityOperator.EQUALS, currencyUomId));
@@ -1582,7 +1582,7 @@
             StringBuilder msgBuf = new StringBuilder();
             msgBuf.append(UtilProperties.getMessage(resource, "ProductListPriceRange", locale));
             msgBuf.append(": ");
-
+
             // NOTE: at this point we know that only one or none are null
             if (this.lowPrice == null) {
                 msgBuf.append(UtilProperties.getMessage(resourceCommon, "CommonLessThan", locale));
@@ -1731,7 +1731,7 @@
             }
         }
     }
-
+
     public static class GoodIdentificationConstraint extends ProductSearchConstraint {
         public static final String constraintName = "GoodIdentification";
         protected String goodIdentificationTypeId;
@@ -1748,33 +1748,33 @@
             if (UtilValidate.isNotEmpty(goodIdentificationTypeId) ||
                 UtilValidate.isNotEmpty(goodIdentificationValue) ||
                 UtilValidate.isNotEmpty(include)) {
-
+
                 // make index based values and increment
                 String entityAlias = "GI" + productSearchContext.index;
                 String prefix = "gi" + productSearchContext.index;
                 productSearchContext.index++;
 
-
+
                 EntityComparisonOperator operator = EntityOperator.EQUALS;
-
+
                 if (UtilValidate.isNotEmpty(include) && include == Boolean.FALSE) {
                     operator = EntityOperator.NOT_EQUAL;
                 }
-
+
                 productSearchContext.dynamicViewEntity.addMemberEntity(entityAlias, "GoodIdentification");
-
+
                 if (UtilValidate.isNotEmpty(goodIdentificationTypeId)) {
                     productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "GoodIdentificationTypeId", "goodIdentificationTypeId", null, null, null, null);
                     productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "GoodIdentificationTypeId", operator, goodIdentificationTypeId));
                 }
-
+
                 if (UtilValidate.isNotEmpty(goodIdentificationValue)) {
                     productSearchContext.dynamicViewEntity.addAlias(entityAlias, prefix + "GoodIdentificationValue", "idValue", null, null, null, null);
                     productSearchContext.entityConditionList.add(EntityCondition.makeCondition(prefix + "GoodIdentificationValue", operator, goodIdentificationValue));
                 }
-
+
                 productSearchContext.dynamicViewEntity.addViewLink("PROD", entityAlias, Boolean.FALSE, ModelKeyMap.makeKeyMapList("productId"));
-
+
                 productSearchContext.productSearchConstraintList.add(productSearchContext.getDelegator().makeValue("ProductSearchConstraint",
                         UtilMisc.toMap("constraintName", constraintName, "infoString", "goodIdentificationTypeId [" + this.goodIdentificationTypeId + "] goodIdentificationValue [" + this.goodIdentificationValue + "] include [" + this.include + "]")));
             }
@@ -1786,9 +1786,9 @@
                 UtilValidate.isEmpty(include)) {
                 return null;
             }
-
+
             StringBuilder msgBuf = new StringBuilder();
-
+
             if (UtilValidate.isNotEmpty(include) && include == Boolean.FALSE) {
                 msgBuf.append(UtilProperties.getMessage(resourceCommon, "CommonExclude", locale));
                 msgBuf.append(" ");
@@ -1796,14 +1796,14 @@
                 msgBuf.append(UtilProperties.getMessage(resourceCommon, "CommonInclude", locale));
                 msgBuf.append(" ");
             }
-
+
             if (UtilValidate.isNotEmpty(goodIdentificationTypeId)) {
                 msgBuf.append(UtilProperties.getMessage(resource, "ProductIdType", locale));
                 msgBuf.append(": ");
                 msgBuf.append(goodIdentificationTypeId);
                 msgBuf.append(" ");
             }
-
+
             if (UtilValidate.isNotEmpty(goodIdentificationValue)) {
                 msgBuf.append(UtilProperties.getMessage(resource, "ProductIdValue", locale));
                 msgBuf.append(" ");
@@ -1948,7 +1948,7 @@
             productSearchContext.dynamicViewEntity.addAlias("SPPRC", "sortFromDate", "fromDate", null, null, null, null);
             productSearchContext.dynamicViewEntity.addAlias("SPPRC", "sortThruDate", "thruDate", null, null, null, null);
             productSearchContext.dynamicViewEntity.addAlias("SPPRC", "sortPrice", "price", null, null, null, null);
-
+
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition("sortProductPriceTypeId", EntityOperator.EQUALS, this.productPriceTypeId));
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition("sortCurrencyUomId", EntityOperator.EQUALS, this.currencyUomId));
             productSearchContext.entityConditionList.add(EntityCondition.makeCondition("sortProductStoreGroupId", EntityOperator.EQUALS, this.productStoreGroupId));
@@ -1986,7 +1986,7 @@
                     priceTypeName += UtilProperties.getMessage(resource, "ProductHighToLow", locale)+")";
                 }
             }
-
+
             return priceTypeName;
         }
 

Modified: ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java (original)
+++ ofbiz/trunk/applications/product/src/org/ofbiz/product/product/ProductSearchEvents.java Fri Mar 27 17:01:36 2009
@@ -412,11 +412,11 @@
                     Map<String, Object> productMap = FastMap.newInstance();
                     String productId = searchResultView.getString("mainProductId");
                     productMap.put("productId", productId);
-
+
                     List<GenericValue> productFeaturesCustomRaw = delegator.findByAnd("ProductFeatureAndAppl", UtilMisc.toMap("productId", productId, "productFeatureTypeId", "HAZMAT") );
                     List<GenericValue> productFeaturesCustom = EntityUtil.filterByDate(productFeaturesCustomRaw);
                     productMap.put("productFeatureCustom", EntityUtil.getFirst(productFeaturesCustom));
-
+
                     List<GenericValue> productCategoriesRaw = delegator.findByAnd("ProductCategoryAndMember", UtilMisc.toMap("productId", productId));
                     List<GenericValue> productCategories = EntityUtil.filterByDate(productCategoriesRaw);
                     productMap.put("productCategories", productCategories);

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?rev=759254&r1=759253&r2=759254&view=diff
==============================================================================
--- 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 27 17:01:36 2009
@@ -130,14 +130,14 @@
             productSearchOptions.resultSortOrder = resultSortOrder;
             productSearchOptions.changed = true;
         }
-
+
         public static void clearSearchOptions(HttpSession session) {
             ProductSearchOptions productSearchOptions = getProductSearchOptions(session);
             productSearchOptions.constraintList = null;
             productSearchOptions.topProductCategoryId = null;
             productSearchOptions.resultSortOrder = null;
         }
-
+
         public void clearViewInfo() {
             this.viewIndex = null;
             this.viewSize = null;
@@ -180,7 +180,7 @@
         public Integer getViewSize() {
             return viewSize;
         }
-
+
         /**
          * @param viewSize The viewSize to set.
          */
@@ -188,7 +188,7 @@
             setPreviousViewSize(getViewSize());
             this.viewSize = viewSize;
         }
-
+
         /**
          * @param viewSize The viewSize to set.
          */
@@ -205,14 +205,14 @@
                 }
             }
         }
-
+
         /**
          * @return Returns the paging.
          */
         public String getPaging() {
             return paging;
         }
-
+
         /**
          * @param paging The paging to set.
          */
@@ -222,7 +222,7 @@
             }
             this.paging = paging;
         }
-
+
         /**
          * @return Returns the previousViewSize.
          */
@@ -239,7 +239,7 @@
                 this.previousViewSize = previousViewSize;
             }
         }
-
+
         public String getTopProductCategoryId() {
             return topProductCategoryId;
         }
@@ -311,7 +311,7 @@
     public static void clearSearchOptionsHistoryList(HttpSession session) {
         session.removeAttribute("_PRODUCT_SEARCH_OPTIONS_HISTORY_");
     }
-
+
     public static void setCurrentSearchFromHistory(int index, boolean removeOld, HttpSession session) {
         List<ProductSearchOptions> searchOptionsHistoryList = getSearchOptionsHistoryList(session);
         if (index < searchOptionsHistoryList.size()) {
@@ -332,17 +332,17 @@
         clearSearchOptionsHistoryList(session);
         return "success";
     }
-
+
     public static String setCurrentSearchFromHistory(HttpServletRequest request, HttpServletResponse response) {
         HttpSession session = request.getSession();
         String searchHistoryIndexStr = request.getParameter("searchHistoryIndex");
         String removeOldStr = request.getParameter("removeOld");
-
+
         if (UtilValidate.isEmpty(searchHistoryIndexStr)) {
             request.setAttribute("_ERROR_MESSAGE_", "No search history index passed, cannot set current search to previous.");
             return "error";
         }
-
+
         try {
             int searchHistoryIndex = Integer.parseInt(searchHistoryIndexStr);
             boolean removeOld = true;
@@ -354,10 +354,10 @@
             request.setAttribute("_ERROR_MESSAGE_", e.toString());
             return "error";
         }
-
+
         return "success";
     }
-
+
     /** A ControlServlet event method used to check to see if there is an override for any of the current keywords in the search */
     public static final String checkDoKeywordOverride(HttpServletRequest request, HttpServletResponse response) {
         HttpSession session = request.getSession();
@@ -442,14 +442,14 @@
 
         // if the search options have changed since the last search, put at the beginning of the options history list
         checkSaveSearchOptionsHistory(session);
-
+
         return ProductSearch.searchProducts(productSearchConstraintList, resultSortOrder, delegator, visitId);
     }
 
     public static void searchClear(HttpSession session) {
         ProductSearchOptions.clearSearchOptions(session);
     }
-
+
     public static List<String> searchGetConstraintStrings(boolean detailed, HttpSession session, GenericDelegator delegator) {
         Locale locale = UtilHttp.getLocale(session);
         ProductSearchOptions productSearchOptions = getProductSearchOptions(session);
@@ -505,13 +505,13 @@
         } else {
             request.setAttribute("processSearchParametersAlreadyRun", Boolean.TRUE);
         }
-
+
         //Debug.logInfo("Processing Product Search parameters: " + parameters, module);
-
+
         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");
         if (!"N".equals(clearSearchString)) {
@@ -528,7 +528,7 @@
                 }
             }
         }
-
+
         String prioritizeCategoryId = null;
         if (UtilValidate.isNotEmpty((String) parameters.get("PRIORITIZE_CATEGORY_ID"))) {
             prioritizeCategoryId = (String) parameters.get("PRIORITIZE_CATEGORY_ID");
@@ -539,7 +539,7 @@
             ProductSearchOptions.setTopProductCategoryId(prioritizeCategoryId, session);
             constraintsChanged = true;
         }
-
+
         // if there is another category, add a constraint for it
         if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_CATEGORY_ID"))) {
             String searchCategoryId = (String) parameters.get("SEARCH_CATEGORY_ID");
@@ -549,7 +549,7 @@
             searchAddConstraint(new ProductSearch.CategoryConstraint(searchCategoryId, !"N".equals(searchSubCategories), exclude), 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);
@@ -582,7 +582,7 @@
                 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");
@@ -690,7 +690,7 @@
             searchAddConstraint(new ProductSearch.SupplierConstraint(supplierPartyId), session);
             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"))) {
             BigDecimal listPriceLow = null;
@@ -748,7 +748,7 @@
             searchAddConstraint(new ProductSearch.ListPriceRangeConstraint(listPriceLow, listPriceHigh, listPriceCurrency), session);
             constraintsChanged = true;
         }
-
+
         // check the ProductStore to see if we should add the ExcludeVariantsConstraint
         if (productStore != null && !"N".equals(productStore.getString("prodSearchExcludeVariants"))) {
             searchAddConstraint(new ProductSearch.ExcludeVariantsConstraint(), session);
@@ -759,7 +759,7 @@
             searchAddConstraint(new ProductSearch.AvailabilityDateConstraint(), session);
             constraintsChanged = true;
         }
-
+
         if (UtilValidate.isNotEmpty((String) parameters.get("SEARCH_GOOD_IDENTIFICATION_TYPE")) ||
             UtilValidate.isNotEmpty((String) parameters.get("SEARCH_GOOD_IDENTIFICATION_VALUE"))) {
             String include = (String) parameters.get("SEARCH_GOOD_IDENTIFICATION_INCL");
@@ -770,7 +770,7 @@
             if ("N".equalsIgnoreCase(include)) {
                 inc =  Boolean.FALSE;
             }
-
+
             searchAddConstraint(new ProductSearch.GoodIdentificationConstraint((String)parameters.get("SEARCH_GOOD_IDENTIFICATION_TYPE"),
                                 (String) parameters.get("SEARCH_GOOD_IDENTIFICATION_VALUE"), inc), session);
             constraintsChanged = true;
@@ -783,7 +783,7 @@
             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");
         if (UtilValidate.isEmpty(sortOrder)) sortOrder = (String) parameters.get("S_O");
@@ -807,7 +807,7 @@
                 searchSetSortOrder(new ProductSearch.SortProductPrice(priceTypeId, ascending), session);
             }
         }
-
+
         ProductSearchOptions productSearchOptions = getProductSearchOptions(session);
         if (constraintsChanged) {
             // query changed, clear out the VIEW_INDEX & VIEW_SIZE
@@ -832,29 +832,29 @@
 
         HttpSession session = request.getSession();
         ProductSearchOptions productSearchOptions = getProductSearchOptions(session);
-
+
         String addOnTopProdCategoryId = productSearchOptions.getTopProductCategoryId();
-
+
         Integer viewIndexInteger = productSearchOptions.getViewIndex();
         if (viewIndexInteger != null) {
             viewIndex = viewIndexInteger.intValue();
         }
-
+
         Integer viewSizeInteger = productSearchOptions.getViewSize();
         if (viewSizeInteger != null) {
             viewSize = viewSizeInteger.intValue();
         }
-
+
         Integer previousViewSizeInteger = productSearchOptions.getPreviousViewSize();
         if (previousViewSizeInteger != null) {
             previousViewSize = previousViewSizeInteger.intValue();
         }
-
+
         String pag = productSearchOptions.getPaging();
         if (paging != null) {
             paging = pag;
         }
-
+
         lowIndex = viewIndex * viewSize;
         highIndex = (viewIndex + 1) * viewSize;
 
@@ -955,7 +955,7 @@
 
         return result;
     }
-
+
     public static String makeSearchParametersString(HttpSession session) {
         return makeSearchParametersString(getProductSearchOptions(session));
     }
@@ -1098,7 +1098,7 @@
                 }
             }
         }
-
+
         String topProductCategoryId = productSearchOptions.getTopProductCategoryId();
         if (topProductCategoryId != null) {
             searchParamString.append("&amp;S_TPC");