[ 
https://issues.apache.org/jira/browse/OFBIZ-2115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12666644#action_12666644
 ] 

srufle edited comment on OFBIZ-2115 at 1/23/09 1:03 PM:
---------------------------------------------------------------

Would I want to do the first loop through and put each attribute name in
a Set instead of a Map.
{code}
        Set<String> attributeNames =FastMap.newInstance();
        Set<String> keys  = itemAttributesMap.keySet();
        for (String key : keys) {
            String[] attributeInfo = key.split(":");
            attributeNames.put(attributeInfo[0],attributeInfo[0]);
        }
{code}
 then below
{code}
             // update the order item attributes
                if (itemAttributesMap != null) {
                    String attrValue = null;
                    for (String attrName : attributeNames) {
                        attrValue = (String)
itemAttributesMap.get(attrName + ":" + itemSeqId);
                        if (UtilValidate.isNotEmpty(attrName)) {
                            cartItem.setOrderItemAttribute(attrName,
attrValue);
                            Debug.log("Set item attribute Name: [" +
itemSeqId + "] " + attrName + " , Value:" + attrValue, module);
                        }
                    }
                }
{code}



      was (Author: srufle):
    Would I want to do the first loop through and put each attribute name in
a Set instead of a Map.

        Set<String> attributeNames =FastMap.newInstance();
        Set<String> keys  = itemAttributesMap.keySet();
        for (String key : keys) {
            String[] attributeInfo = key.split(":");
            attributeNames.put(attributeInfo[0],attributeInfo[0]);
        }
 then below
             // update the order item attributes
                if (itemAttributesMap != null) {
                    String attrValue = null;
                    for (String attrName : attributeNames) {
                        attrValue = (String)
itemAttributesMap.get(attrName + ":" + itemSeqId);
                        if (UtilValidate.isNotEmpty(attrName)) {
                            cartItem.setOrderItemAttribute(attrName,
attrValue);
                            Debug.log("Set item attribute Name: [" +
itemSeqId + "] " + attrName + " , Value:" + attrValue, module);
                        }
                    }
                }



  
> OrderServices.updateApprovedOrderItems should update OrderItemAttributes
> ------------------------------------------------------------------------
>
>                 Key: OFBIZ-2115
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-2115
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: order
>    Affects Versions: SVN trunk
>         Environment: Windows XP
>            Reporter: Stephen Rufle
>            Assignee: Jacques Le Roux
>             Fix For: SVN trunk
>
>         Attachments: 2009-01-14_001_shoppingcart.patch, 
> 2009-01-14_001_shoppingcart.patch
>
>
> I wanted updateApprovedOrderItems to be able to update any 
> OrderItemAttributes there may be. added a new map (itemAttributesMap) to 
> /applications/order/servicedef/services.xml#updateOrderItems the key value of 
> the map should be in the form of
> attibuteName+ ":" + orderItemSeqId
> At the top of
> OrderServices.updateApprovedOrderItems(DispatchContext, Map) I create a new 
> map with only the attribute names, later in the same method we repopulate the 
> cartItem's OrderItemAttributes with any non-empty values. In 
> saveUpdatedCartToOrder we call my modified 
> ShoppingCart.makeAllOrderItemAttributes(String, int) I added the ability to 
> return just empty , just filled or both empty and filled. 
> For previously filled attributes that are now empty I remove them from the 
> database. for either new or chnaged ones they are just added to the toStore 
> that already existed 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to