FYI, you can also use some of groovy's other collection methods:
// Retrieve all non-promo items that aren't cancelled
context.orderItemListFiltered = orderReadHelper.getOrderItems().findAll { item 
->
  (item.isPromo == null || item.isPromo == 'N')  && 
!(item.statusId.equals('ITEM_CANCELLED'))
}

Regards
Scott

On 12/05/2013, at 12:39 AM, Jacques Le Roux wrote:

> I did not look into details, but yes seems the way
> 
> Thanks
> 
> Jacques
> 
> Jonatan Soto wrote:
>> There isn't afaik. Do you want me to create one if that's finally the case?
>> 
>> 
>> On Sat, May 11, 2013 at 1:39 PM, Jacques Le Roux <
>> [email protected]> wrote:
>> 
>>> Is there a Jira for that, should we not commit and backport?
>>> 
>>> Jacques
>>> 
>>> From: "Adrian Crum" <[email protected]>
>>>> That is correct.
>>>> 
>>>> -Adrian
>>>> 
>>>> On 5/11/2013 11:41 AM, Jonatan Soto wrote:
>>>>> Ok, I think I got it. My solution only covered first problem, but the
>>>>> second problem implies that the first problem is no longer a problem
>>>>> because the original order item list has to remain unmodified for further
>>>>> usage. So this might fix problem 2:
>>>>> 
>>>>> orderItemListFiltered = new LinkedList();
>>>>>     orderItemList = orderReadHelper.getOrderItems();
>>>>>     orderItemList.each { orderItem ->
>>>>>         if (UtilValidate.isEmpty(orderItem.get("isPromo")) ||
>>>>> "N".equals(orderItem.get("isPromo"))) {
>>>>> orderItemListFiltered.add(orderItem);
>>>>>         } else {
>>>>> if (!"ITEM_CANCELLED".equals(orderItem.get("statusId")))
>>>>> orderItemListFiltered.add(orderItem);
>>>>>         }
>>>>>     }
>>>>>     context.orderItemList = orderItemListFiltered;
>>>>> 
>>>>> HTH
>>>>> 
>>>>> 
>>>>> On Sat, May 11, 2013 at 11:47 AM, Adrian Crum <
>>>>> [email protected]> wrote:
>>>>> 
>>>>>> There are two problems with that part of the script:
>>>>>> 
>>>>>> 1. It modifies a List while iterating over it.
>>>>>> 2. It modifies a List that is contained by OrderReadHelper - so any
>>>>>> further use of OrderReadHelper will produce incorrect data.
>>>>>> 
>>>>>> The solution is to iterate over the List contained on OrderReadHelper and
>>>>>> build a new List based on the selection criteria. In other words, create 
>>>>>> a
>>>>>> new List that excludes canceled promo items instead of modifying the
>>>>>> existing List.
>>>>>> 
>>>>>> -Adrian
>>>>>> 
>>>>>> 
>>>>>> On 5/11/2013 10:41 AM, Jonatan Soto wrote:
>>>>>> 
>>>>>>> I could fix the issue by doing the following at line 122 of that groovy
>>>>>>> file:
>>>>>>> 
>>>>>>> //canceledPromoOrderItem = [:];
>>>>>>>      orderItemList = orderReadHelper.getOrderItems(**);
>>>>>>> for (Iterator iter = orderItemList.iterator(); iter.hasNext();) {
>>>>>>>      //orderItemList.each { orderItem ->
>>>>>>> orderItem = iter.next();
>>>>>>>          if("Y".equals(orderItem.get("**isPromo")) &&
>>>>>>> "ITEM_CANCELLED".equals(**orderItem.get("statusId"))) {
>>>>>>>              //canceledPromoOrderItem = orderItem;
>>>>>>> iter.remove();
>>>>>>>          }
>>>>>>> Debug.log("orderItem ==========> " + orderItem);
>>>>>>>      }
>>>>>>> 
>>>>>>> 
>>>>>>> I've proceed in that way according to what I read from the LinkedList 
>>>>>>> java
>>>>>>> doc http://docs.oracle.com/javase/**6/docs/api/java/util/**
>>>>>>> LinkedList.html<
>>> http://docs.oracle.com/javase/6/docs/api/java/util/LinkedList.html>
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> On Fri, May 10, 2013 at 2:38 PM, Adrian Crum <
>>>>>>> adrian.crum@sandglass-**software.com <
>>> [email protected]>>
>>>>>>> wrote:
>>>>>>> 
>>>>>>>  Actually, OrderView.groovy line 122 doesn't make any sense. That is
>>> a
>>>>>>>> flaw
>>>>>>>> in the groovy code, not a problem with the List implementation.
>>>>>>>> 
>>>>>>>> -Adrian
>>>>>>>> 
>>>>>>>> 
>>>>>>>> On 5/10/2013 1:09 PM, Adrian Crum wrote:
>>>>>>>> 
>>>>>>>>  It appears LinkedList was not a good replacement for FastList. I
>>> will
>>>>>>>>> take care of it this weekend.
>>>>>>>>> 
>>>>>>>>> -Adrian
>>>>>>>>> 
>>>>>>>>> On 5/10/2013 12:32 PM, Jonatan Soto wrote:
>>>>>>>>> 
>>>>>>>>>  This is a more detailed stack trace btw. Note that once this
>>> happens is
>>>>>>>>>> not
>>>>>>>>>> possible to edit the order anymore.
>>>>>>>>>> 
>>>>>>>>>> 2013-05-10 12:23:43,348 (ajp-bio-0.0.0.0-8009-exec-****511) [
>>>>>>>>>> 
>>>>>>>>>> ScreenFactory.java:130:INFO ] Got 29 screens in 0.0080s from:
>>>>>>>>>> file:/home/ofbiz/trunk/****applications/order/widget/****
>>>>>>>>>> ordermgr/OrderViewScreens.xml
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 2013-05-10 12:23:43,522 (ajp-bio-0.0.0.0-8009-exec-****511) [
>>>>>>>>>> 
>>>>>>>>>> ScriptUtil.java:347:WARN ] ---- runtime exception report
>>>>>>>>>> ------------------------------****-------------------- Error running
>>>>>>>>>> script at
>>>>>>>>>> location
>>>>>>>>>> [component://order/webapp/****ordermgr/WEB-INF/actions/****
>>>>>>>>>> order/OrderView.groovy]:
>>>>>>>>>> 
>>>>>>>>>> java.util.****ConcurrentModificationExceptio****n Exception:
>>>>>>>>>> java.util.****ConcurrentModificationExceptio****n Message: null ----
>>>>>>>>>> stack
>>>>>>>>>> trace
>>>>>>>>>> ------------------------------****----------------------------**
>>>>>>>>>> --**---
>>>>>>>>>> java.util.****ConcurrentModificationExceptio****n
>>>>>>>>>> java.util.LinkedList$ListItr.****checkForComodification(**
>>>>>>>>>> LinkedList.java:761)
>>>>>>>>>> java.util.LinkedList$ListItr.****next(LinkedList.java:696)
>>>>>>>>>> org.codehaus.groovy.runtime.****DefaultGroovyMethods.each(**
>>>>>>>>>> DefaultGroovyMethods.java:****1375)
>>>>>>>>>> org.codehaus.groovy.runtime.****DefaultGroovyMethods.each(**
>>>>>>>>>> DefaultGroovyMethods.java:****1348)
>>>>>>>>>> org.codehaus.groovy.runtime.****dgm$162.invoke(Unknown Source)
>>>>>>>>>> org.codehaus.groovy.runtime.****callsite.PojoMetaMethodSite$**
>>>>>>>>>> PojoMetaMethodSiteNoUnwrapNoCo****erce.invoke(****
>>>>>>>>>> PojoMetaMethodSite.java:271)
>>>>>>>>>> 
>>>>>>>>>> org.codehaus.groovy.runtime.****callsite.PojoMetaMethodSite.**
>>>>>>>>>> call(PojoMetaMethodSite.java:****53)
>>>>>>>>>> org.codehaus.groovy.runtime.****callsite.CallSiteArray.**
>>>>>>>>>> defaultCall(CallSiteArray.****java:42)
>>>>>>>>>> org.codehaus.groovy.runtime.****callsite.AbstractCallSite.**
>>>>>>>>>> call(AbstractCallSite.java:****108)
>>>>>>>>>> org.codehaus.groovy.runtime.****callsite.AbstractCallSite.**
>>>>>>>>>> call(AbstractCallSite.java:****116)
>>>>>>>>>> OrderView.run(OrderView.****groovy:122)
>>>>>>>>>> org.ofbiz.base.util.****GroovyUtil.****runScriptAtLocation(**
>>>>>>>>>> GroovyUtil.java:172)
>>>>>>>>>> org.ofbiz.base.util.****GroovyUtil.****runScriptAtLocation(**
>>>>>>>>>> GroovyUtil.java:165)
>>>>>>>>>> org.ofbiz.base.util.****ScriptUtil.executeScript(****
>>>>>>>>>> ScriptUtil.java:342)
>>>>>>>>>> org.ofbiz.base.util.****ScriptUtil.executeScript(****
>>>>>>>>>> ScriptUtil.java:324)
>>>>>>>>>> org.ofbiz.widget.****ModelWidgetAction$Script.**
>>>>>>>>>> runAction(ModelWidgetAction.****java:414)
>>>>>>>>>> org.ofbiz.widget.****ModelWidgetAction.****runSubActions(****
>>>>>>>>>> ModelWidgetAction.java:114)
>>>>>>>>>> 
>>>>>>>>>> org.ofbiz.widget.screen.****ModelScreenWidget$Section.**
>>>>>>>>>> renderWidgetString(****ModelScreenWidget.java:184)
>>>>>>>>>> org.ofbiz.widget.screen.****ModelScreen.****renderScreenString(****
>>>>>>>>>> ModelScreen.java:396)
>>>>>>>>>> 
>>>>>>>>>> org.ofbiz.widget.screen.****ScreenRenderer.render(**
>>>>>>>>>> ScreenRenderer.java:135)
>>>>>>>>>> org.ofbiz.widget.screen.****ScreenRenderer.render(**
>>>>>>>>>> ScreenRenderer.java:97)
>>>>>>>>>> org.ofbiz.widget.screen.****MacroScreenViewHandler.render(****
>>>>>>>>>> MacroScreenViewHandler.java:****104)
>>>>>>>>>> org.ofbiz.webapp.control.****RequestHandler.renderView(****
>>>>>>>>>> RequestHandler.java:898)
>>>>>>>>>> 
>>>>>>>>>> org.ofbiz.webapp.control.****RequestHandler.doRequest(****
>>>>>>>>>> RequestHandler.java:599)
>>>>>>>>>> 
>>>>>>>>>> org.ofbiz.webapp.control.****ControlServlet.doGet(**
>>>>>>>>>> ControlServlet.java:214)
>>>>>>>>>> org.ofbiz.webapp.control.****ControlServlet.doPost(**
>>>>>>>>>> ControlServlet.java:86)
>>>>>>>>>> 
>>> javax.servlet.http.****HttpServlet.service(****HttpServlet.java:641)
>>>>>>>>>> 
>>> javax.servlet.http.****HttpServlet.service(****HttpServlet.java:722)
>>>>>>>>>> org.apache.catalina.core.****ApplicationFilterChain.****
>>>>>>>>>> internalDoFilter(**
>>>>>>>>>> ApplicationFilterChain.java:****305)
>>>>>>>>>> org.apache.catalina.core.****ApplicationFilterChain.****doFilter(**
>>>>>>>>>> ApplicationFilterChain.java:****210)
>>>>>>>>>> org.ofbiz.webapp.control.****ContextFilter.doFilter(**
>>>>>>>>>> ContextFilter.java:314)
>>>>>>>>>> org.apache.catalina.core.****ApplicationFilterChain.****
>>>>>>>>>> internalDoFilter(**
>>>>>>>>>> ApplicationFilterChain.java:****243)
>>>>>>>>>> org.apache.catalina.core.****ApplicationFilterChain.****doFilter(**
>>>>>>>>>> ApplicationFilterChain.java:****210)
>>>>>>>>>> org.apache.catalina.core.****StandardWrapperValve.invoke(****
>>>>>>>>>> StandardWrapperValve.java:222)
>>>>>>>>>> 
>>>>>>>>>> org.apache.catalina.core.****StandardContextValve.invoke(****
>>>>>>>>>> StandardContextValve.java:123)
>>>>>>>>>> 
>>>>>>>>>> 
>>> org.apache.catalina.****authenticator.****AuthenticatorBase.invoke(***
>>>>>>>>>> *AuthenticatorBase.java:472)
>>>>>>>>>> 
>>>>>>>>>> org.apache.catalina.core.****StandardHostValve.invoke(****
>>>>>>>>>> StandardHostValve.java:171)
>>>>>>>>>> 
>>>>>>>>>> org.apache.catalina.valves.****ErrorReportValve.invoke(****
>>>>>>>>>> ErrorReportValve.java:99)
>>>>>>>>>> 
>>>>>>>>>> org.apache.catalina.core.****StandardEngineValve.invoke(****
>>>>>>>>>> StandardEngineValve.java:118)
>>>>>>>>>> 
>>>>>>>>>> org.apache.catalina.valves.****AccessLogValve.invoke(****
>>>>>>>>>> AccessLogValve.java:947)
>>>>>>>>>> 
>>>>>>>>>> org.apache.catalina.connector.****CoyoteAdapter.service(****
>>>>>>>>>> CoyoteAdapter.java:408)
>>>>>>>>>> 
>>>>>>>>>> org.apache.coyote.ajp.****AjpProcessor.process(****
>>>>>>>>>> AjpProcessor.java:200)
>>>>>>>>>> org.apache.coyote.****AbstractProtocol$****
>>>>>>>>>> AbstractConnectionHandler.**
>>>>>>>>>> process(AbstractProtocol.java:****589)
>>>>>>>>>> org.apache.tomcat.util.net.****JIoEndpoint$SocketProcessor.****
>>>>>>>>>> run(JIoEndpoint.java:310)
>>>>>>>>>> 
>>>>>>>>>> java.util.concurrent.****ThreadPoolExecutor$Worker.**
>>>>>>>>>> runTask(ThreadPoolExecutor.****java:886)
>>>>>>>>>> java.util.concurrent.****ThreadPoolExecutor$Worker.run(**
>>>>>>>>>> **ThreadPoolExecutor.java:908)
>>>>>>>>>> 
>>>>>>>>>> java.lang.Thread.run(Thread.****java:662)
>>>>>>>>>> ------------------------------****----------------------------**
>>>>>>>>>> --**--------------------
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 2013-05-10 12:23:43,522 (ajp-bio-0.0.0.0-8009-exec-****511) [
>>>>>>>>>> 
>>>>>>>>>> ModelScreen.java:401:ERROR] Error rendering screen
>>>>>>>>>> [component://order/widget/****ordermgr/OrderViewScreens.xml#**
>>>>>>>>>> **OrderHeaderView]:
>>>>>>>>>> 
>>>>>>>>>> java.lang.****IllegalArgumentException: Error running script at
>>>>>>>>>> location
>>>>>>>>>> [component://order/webapp/****ordermgr/WEB-INF/actions/****
>>>>>>>>>> order/OrderView.groovy]:
>>>>>>>>>> 
>>>>>>>>>> java.util.****ConcurrentModificationExceptio****n. Rolling back
>>>>>>>>>> transaction.
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> 
>>>>>>>>>> On Fri, May 10, 2013 at 1:21 PM, Jonatan Soto <
>>>>>>>>>> [email protected]>
>>>>>>>>>> **wrote:
>>>>>>>>>> 
>>>>>>>>>>   Hi,
>>>>>>>>>> 
>>>>>>>>>>> When cancelling an order I'm getting the following exception using 
>>>>>>>>>>> the
>>>>>>>>>>> demo (trunk) :
>>>>>>>>>>> 
>>>>>>>>>>> org.ofbiz.widget.screen.****ScreenRenderException: Error rendering
>>>>>>>>>>> screen
>>>>>>>>>>> [component://order/widget/****ordermgr/OrderViewScreens.xml#**
>>>>>>>>>>> **OrderHeaderView]:
>>>>>>>>>>> 
>>>>>>>>>>> java.lang.****IllegalArgumentException: Error running script at
>>>>>>>>>>> location
>>>>>>>>>>> [component://order/webapp/****ordermgr/WEB-INF/actions/****
>>>>>>>>>>> order/OrderView.groovy]:
>>>>>>>>>>> 
>>>>>>>>>>> java.util.****ConcurrentModificationExceptio****n (Error running
>>>>>>>>>>> script at
>>>>>>>>>>> location
>>>>>>>>>>> [component://order/webapp/****ordermgr/WEB-INF/actions/****
>>>>>>>>>>> order/OrderView.groovy]:
>>>>>>>>>>> 
>>>>>>>>>>> java.util.****ConcurrentModificationExceptio****n)
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> 
>>>>>>>>>>> If nobody is working with it or something related, I can take a look
>>>>>>>>>>> at
>>>>>>>>>>> it
>>>>>>>>>>> later.
>>>>>>>>>>> 
>>>>>>>>>>> Cheers,
>>>>>>>>>>> 
>>>>>>>>>>> --
>>>>>>>>>>> -----
>>>>>>>>>>> 
>>>>>>>>>>> Jonatan Soto

Reply via email to