Author: ashish
Date: Sat Feb 21 10:19:40 2015
New Revision: 1661317
URL: http://svn.apache.org/r1661317
Log:
Applied bug fix from trunk r1661316.
=========================================================================
Applied patch from jira issue - OFBIZ-5570 - appendOrderItem Service Not
Applying Order Item Attributes.
Thanks Darrell Donati for creating the issue and thanks Divesh for providing
the patch. Thanks Pierre for your active participation in the discussion.
=========================================================================
Modified:
ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/order/OrderServices.java
Modified:
ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=1661317&r1=1661316&r2=1661317&view=diff
==============================================================================
---
ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/order/OrderServices.java
(original)
+++
ofbiz/branches/release14.12/applications/order/src/org/ofbiz/order/order/OrderServices.java
Sat Feb 21 10:19:40 2015
@@ -3553,6 +3553,8 @@ public class OrderServices {
String orderItemTypeId = (String) context.get("orderItemTypeId");
String changeComments = (String) context.get("changeComments");
Boolean calcTax = (Boolean) context.get("calcTax");
+ Map<String, String> itemAttributesMap =
UtilGenerics.checkMap(context.get("itemAttributesMap"));
+
if (calcTax == null) {
calcTax = Boolean.TRUE;
}
@@ -3593,9 +3595,9 @@ public class OrderServices {
// add in the new product
try {
+ ShoppingCartItem item = null;
if ("PURCHASE_ORDER".equals(cart.getOrderType())) {
GenericValue supplierProduct =
cart.getSupplierProduct(productId, quantity, dispatcher);
- ShoppingCartItem item = null;
if (supplierProduct != null) {
item = ShoppingCartItem.makePurchaseOrderItem(null,
productId, null, quantity, null, null, prodCatalogId, null, orderItemTypeId,
null, dispatcher, cart, supplierProduct, itemDesiredDeliveryDate,
itemDesiredDeliveryDate, null);
cart.addItem(0, item);
@@ -3613,7 +3615,7 @@ public class OrderServices {
cart.clearItemShipInfo(item);
cart.setItemShipGroupQty(item, item.getQuantity(),
shipGroupIdx);
} else {
- ShoppingCartItem item = ShoppingCartItem.makeItem(null,
productId, null, quantity, null, null, null, null, null, null, null, null,
prodCatalogId, null, null, null, dispatcher, cart, null, null, null,
Boolean.FALSE, Boolean.FALSE);
+ item = ShoppingCartItem.makeItem(null, productId, null,
quantity, null, null, null, null, null, null, null, null, prodCatalogId, null,
null, null, dispatcher, cart, null, null, null, Boolean.FALSE, Boolean.FALSE);
if (basePrice != null && overridePrice != null) {
item.setBasePrice(basePrice);
// special hack to make sure we re-calc the promos after a
price change
@@ -3631,6 +3633,23 @@ public class OrderServices {
cart.clearItemShipInfo(item);
cart.setItemShipGroupQty(item, item.getQuantity(),
shipGroupIdx);
}
+ // set the order item attributes
+ if (itemAttributesMap != null) {
+ // go through the item attributes map once to get a list of
key names
+ Set<String> attributeNames =FastSet.newInstance();
+ Set<String> keys = itemAttributesMap.keySet();
+ for (String key : keys) {
+ attributeNames.add(key);
+ }
+ String attrValue = null;
+ for (String attrName : attributeNames) {
+ attrValue = itemAttributesMap.get(attrName);
+ if (UtilValidate.isNotEmpty(attrName)) {
+ item.setOrderItemAttribute(attrName, attrValue);
+ Debug.logInfo("Set item attribute Name: " + attrName +
" , Value:" + attrValue, module);
+ }
+ }
+ }
} catch (CartItemModifyException e) {
Debug.logError(e, module);
return ServiceUtil.returnError(e.getMessage());