You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacopo Cappellato <ja...@hotwaxsystems.com> on 2017/03/23 08:03:01 UTC

Fwd: svn commit: r1788065 - in /ofbiz/ofbiz-framework/trunk/applications: accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

Forwarding an email that I sent yesterday and seems to be lost in the net.

Jacopo

---------- Forwarded message ----------
From: Jacopo Cappellato <ja...@hotwaxsystems.com>
Date: Wed, Mar 22, 2017 at 10:00 AM
Subject: Re: svn commit: r1788065 - in
/ofbiz/ofbiz-framework/trunk/applications:
accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
To: dev@ofbiz.apache.org
Cc: commits@ofbiz.apache.org


On Wed, Mar 22, 2017 at 9:26 AM, <jl...@apache.org> wrote:

> ...

+        try (EntityListIterator eli = EntityQuery.use(delegator)
> +                .from("OrderPaymentPreference")
> +                .where(EntityCondition.makeCondition("statusId",
> EntityOperator.EQUALS, "PAYMENT_NOT_AUTH"),
>                              EntityCondition.
> makeCondition("processAttempt", EntityOperator.GREATER_THAN,
> Long.valueOf(0)))
> -                    .orderBy("orderId").queryIterator()) {
> +                .orderBy("orderId")
> +                .queryIterator()) {
> +


With code like the above, I think that embedding everything in the try
clause makes the code a bit less readable.
One option would be to split the entity query code in two lines:

EntityQuery eq = EntityQuery.use(delegator)
                .from("OrderPaymentPreference")
                .where(EntityCondition.makeCondition("statusId",
EntityOperator.EQUALS, "PAYMENT_NOT_AUTH"),
                             EntityCondition.makeCondition("processAttempt",
EntityOperator.GREATER_THAN, Long.valueOf(0)))
                .orderBy("orderId");

try (EntityListIterator eli = eq.queryIterator()) {
...

Jacopo

Re: Fwd: svn commit: r1788065 - in /ofbiz/ofbiz-framework/trunk/applications: accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGateway Services.java order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java

Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Jacopo,

Thanks for you review, this is indeed a good idea. I'll revisit related changes

Jacques


Le 23/03/2017 � 09:03, Jacopo Cappellato a �crit :
> Forwarding an email that I sent yesterday and seems to be lost in the net.
>
> Jacopo
>
> ---------- Forwarded message ----------
> From: Jacopo Cappellato <ja...@hotwaxsystems.com>
> Date: Wed, Mar 22, 2017 at 10:00 AM
> Subject: Re: svn commit: r1788065 - in
> /ofbiz/ofbiz-framework/trunk/applications:
> accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
> order/src/main/java/org/apache/ofbiz/order/shoppingcart/ShoppingCart.java
> To: dev@ofbiz.apache.org
> Cc: commits@ofbiz.apache.org
>
>
> On Wed, Mar 22, 2017 at 9:26 AM, <jl...@apache.org> wrote:
>
>> ...
> +        try (EntityListIterator eli = EntityQuery.use(delegator)
>> +                .from("OrderPaymentPreference")
>> +                .where(EntityCondition.makeCondition("statusId",
>> EntityOperator.EQUALS, "PAYMENT_NOT_AUTH"),
>>                               EntityCondition.
>> makeCondition("processAttempt", EntityOperator.GREATER_THAN,
>> Long.valueOf(0)))
>> -                    .orderBy("orderId").queryIterator()) {
>> +                .orderBy("orderId")
>> +                .queryIterator()) {
>> +
>
> With code like the above, I think that embedding everything in the try
> clause makes the code a bit less readable.
> One option would be to split the entity query code in two lines:
>
> EntityQuery eq = EntityQuery.use(delegator)
>                  .from("OrderPaymentPreference")
>                  .where(EntityCondition.makeCondition("statusId",
> EntityOperator.EQUALS, "PAYMENT_NOT_AUTH"),
>                               EntityCondition.makeCondition("processAttempt",
> EntityOperator.GREATER_THAN, Long.valueOf(0)))
>                  .orderBy("orderId");
>
> try (EntityListIterator eli = eq.queryIterator()) {
> ...
>
> Jacopo
>