[jira] [Updated] (OFBIZ-11208) OrderReadHelper.getOrderItemAttributes as non static function

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

[jira] [Updated] (OFBIZ-11208) OrderReadHelper.getOrderItemAttributes as non static function

Nicolas Malin (Jira)

     [ https://issues.apache.org/jira/browse/OFBIZ-11208?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nicolas Malin updated OFBIZ-11208:
----------------------------------
    Description:
Currenlty if we use the java helper class OrderReadHelper to resolve the orderItemAttributes, it didn't use the a local cache and call each time the delegator throw a static function.

I propose to use also as non static function optimise database calling when you have multiple get to do.

Origin: On customer site we have a huge table orderItemAttributes (8M tuples) with several call. Use a local cache throw OrderReadHelper divide by nine the calling.
{code:java}
public String getOrderItemAttribute(String orderItemSeqId, String attributeName) {
     GenericValue orderItemAttribute = null;
     if (orderHeader != null) {
         if (orderItemAttributes == null) {
             try{
                   orderItemAttributes = EntityQuery.use(orderHeader.getDelegator()) .from("OrderItemAttribute") .where("orderId", getOrderId()) .queryList();
            } catch (GenericEntityException e) { Debug.logError(e, module); }
         }
         orderItemAttribute = EntityUtil.getFirst(
             EntityUtil.filterByAnd(orderItemAttributes,
                 UtilMisc.toMap("orderItemSeqId", orderItemSeqId, "attrName", attributeName)));
     }
     return orderItemAttribute != null ? orderItemAttribute.getString("attrValue"): null;
 }
 {code}
At the first call, we populate the OrderReadHelper with all orderItemAttributes liked to an order, and after just filter with the orderItemSeqId and the attribute name wanted

Example:
{code:java}
    OrderReadHelper orh = new OrderReadHelper(orderHeader)
    ...
    for (GenericValue orderItem : orh.getOrderItems()) {
                listAttr <<
                       [startValue   : orh.getOrderItemAttribute(orderItem.orderItemSeqId, "MyStartValue"),
                        endValue     : orh.getOrderItemAttribute(orderItem.orderItemSeqId, "MyEndValue")]
    }
{code}
We request only for the first passage, after for all other line we use the local OrderReadHelper cache.

  was:Currenltu if we use the java helper class


> OrderReadHelper.getOrderItemAttributes as non static function
> -------------------------------------------------------------
>
>                 Key: OFBIZ-11208
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-11208
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: order
>    Affects Versions: Trunk
>            Reporter: Nicolas Malin
>            Assignee: Nicolas Malin
>            Priority: Minor
>
> Currenlty if we use the java helper class OrderReadHelper to resolve the orderItemAttributes, it didn't use the a local cache and call each time the delegator throw a static function.
> I propose to use also as non static function optimise database calling when you have multiple get to do.
> Origin: On customer site we have a huge table orderItemAttributes (8M tuples) with several call. Use a local cache throw OrderReadHelper divide by nine the calling.
> {code:java}
> public String getOrderItemAttribute(String orderItemSeqId, String attributeName) {
>      GenericValue orderItemAttribute = null;
>      if (orderHeader != null) {
>          if (orderItemAttributes == null) {
>              try{
>                    orderItemAttributes = EntityQuery.use(orderHeader.getDelegator()) .from("OrderItemAttribute") .where("orderId", getOrderId()) .queryList();
>             } catch (GenericEntityException e) { Debug.logError(e, module); }
>          }
>          orderItemAttribute = EntityUtil.getFirst(
>              EntityUtil.filterByAnd(orderItemAttributes,
>                  UtilMisc.toMap("orderItemSeqId", orderItemSeqId, "attrName", attributeName)));
>      }
>      return orderItemAttribute != null ? orderItemAttribute.getString("attrValue"): null;
>  }
>  {code}
> At the first call, we populate the OrderReadHelper with all orderItemAttributes liked to an order, and after just filter with the orderItemSeqId and the attribute name wanted
> Example:
> {code:java}
>     OrderReadHelper orh = new OrderReadHelper(orderHeader)
>     ...
>     for (GenericValue orderItem : orh.getOrderItems()) {
>                 listAttr <<
>                        [startValue   : orh.getOrderItemAttribute(orderItem.orderItemSeqId, "MyStartValue"),
>                         endValue     : orh.getOrderItemAttribute(orderItem.orderItemSeqId, "MyEndValue")]
>     }
> {code}
> We request only for the first passage, after for all other line we use the local OrderReadHelper cache.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)