Author: mbrohl
Date: Sat Dec 9 17:13:15 2017
New Revision: 1817634
URL: http://svn.apache.org/viewvc?rev=1817634&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.product.price.
(OFBIZ-9779)
Thanks Julian Leichert for reporting and providing the patch.
Modified:
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java
Modified:
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java?rev=1817634&r1=1817633&r2=1817634&view=diff
==============================================================================
---
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java
(original)
+++
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/price/PriceServices.java
Sat Dec 9 17:13:15 2017
@@ -291,9 +291,6 @@ public class PriceServices {
if (listPriceValue == null) {
listPriceValue =
getPriceValueForType("LIST_PRICE", variantProductPrices, null);
}
- if (defaultPriceValue == null) {
- defaultPriceValue =
getPriceValueForType("DEFAULT_PRICE", variantProductPrices, null);
- }
if (competitivePriceValue == null) {
competitivePriceValue =
getPriceValueForType("COMPETITIVE_PRICE", variantProductPrices, null);
}
@@ -315,6 +312,7 @@ public class PriceServices {
if (specialPromoPriceValue == null) {
specialPromoPriceValue =
getPriceValueForType("SPECIAL_PROMO_PRICE", variantProductPrices, null);
}
+ defaultPriceValue =
getPriceValueForType("DEFAULT_PRICE", variantProductPrices, null);
}
} catch (GenericEntityException e) {
Debug.logError(e, "An error occurred while getting the
product prices", module);
@@ -520,22 +518,25 @@ public class PriceServices {
Map<String, Object> convertPriceMap = new HashMap<String,
Object>();
for (Map.Entry<String, Object> entry : result.entrySet()) {
BigDecimal tempPrice = BigDecimal.ZERO;
- if(entry.getKey() == "basePrice")
+ switch (entry.getKey()) {
+ case "basePrice":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "price")
+ case "price":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "defaultPrice")
+ case "defaultPrice":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "competitivePrice")
+ case "competitivePrice":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "averageCost")
+ case "averageCost":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "promoPrice")
+ case "promoPrice":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "specialPromoPrice")
+ case "specialPromoPrice":
tempPrice = (BigDecimal) entry.getValue();
- else if (entry.getKey() == "listPrice")
+ case "listPrice":
tempPrice = (BigDecimal) entry.getValue();
+
+ }
if (tempPrice != null && tempPrice != BigDecimal.ZERO)
{
Map<String, Object> priceResults = new
HashMap<String, Object>();