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

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

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

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

Jacopo

---------- Forwarded message ----------
From: Jacopo Cappellato <[hidden email]>
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: [hidden email]
Cc: [hidden email]


On Wed, Mar 22, 2017 at 9:26 AM, <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

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

Jacques Le Roux
Administrator
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 <[hidden email]>
> 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: [hidden email]
> Cc: [hidden email]
>
>
> On Wed, Mar 22, 2017 at 9:26 AM, <[hidden email]> 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
>