Author: jleroux
Date: Thu Mar 23 15:09:23 2017
New Revision: 1788263

URL: http://svn.apache.org/viewvc?rev=1788263&view=rev
Log:
No functional change, as suggested by Jacopo on dev ML referring to r1788065 

<<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>>

I used this suggestion on all locations it made sense. In few places it was
better to let it as is; separating would rather make the code a bit less 
readable.

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
    
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
    
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
    
ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java

Modified: 
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java?rev=1788263&r1=1788262&r2=1788263&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/payment/PaymentGatewayServices.java
 Thu Mar 23 15:09:23 2017
@@ -2687,14 +2687,13 @@ public class PaymentGatewayServices {
         Delegator delegator = dctx.getDelegator();
         LocalDispatcher dispatcher = dctx.getDispatcher();
         GenericValue userLogin = (GenericValue) context.get("userLogin");
-
-        try (EntityListIterator eli = EntityQuery.use(delegator)
+        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")
-                .queryIterator()) {
-            
+                        
EntityCondition.makeCondition("processAttempt",EntityOperator.GREATER_THAN, 
Long.valueOf(0)))
+                .orderBy("orderId");
+
+        try (EntityListIterator eli = eq.queryIterator()) {
             List<String> processList = new LinkedList<String>();
             if (eli != null) {
                 Debug.logInfo("Processing failed order re-auth(s)", module);
@@ -2730,13 +2729,13 @@ public class PaymentGatewayServices {
         calcCal.add(Calendar.WEEK_OF_YEAR, -1);
         Timestamp oneWeekAgo = new Timestamp(calcCal.getTimeInMillis());
 
-
-        try (EntityListIterator eli = EntityQuery.use(delegator)
+        EntityQuery eq = EntityQuery.use(delegator)
                 .from("OrderPaymentPreference")
                 .where(EntityCondition.makeCondition("needsNsfRetry", 
EntityOperator.EQUALS, "Y"), 
                         EntityCondition.makeCondition(ModelEntity.STAMP_FIELD, 
EntityOperator.LESS_THAN_EQUAL_TO, oneWeekAgo))
-                .orderBy("orderId").queryIterator()) {
-
+                .orderBy("orderId");
+        
+        try (EntityListIterator eli = eq.queryIterator()) {
             List<String> processList = new LinkedList<String>();
             if (eli != null) {
                 Debug.logInfo("Processing failed order re-auth(s)", module);

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java?rev=1788263&r1=1788262&r2=1788263&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/order/OrderServices.java
 Thu Mar 23 15:09:23 2017
@@ -1503,12 +1503,7 @@ public class OrderServices {
             cond = EntityCondition.makeCondition(exprs, EntityOperator.OR);
         }
 
-        try (EntityListIterator eli = EntityQuery.use(delegator)
-                .select("orderId")
-                .from("OrderHeader")
-                .where(cond)
-                .queryIterator()) {
-            
+        try (EntityListIterator eli = 
EntityQuery.use(delegator).select("orderId").from("OrderHeader").where(cond).queryIterator())
 {
             if (eli != null) {
                 // reset each order
                 GenericValue orderHeader = null;
@@ -5565,10 +5560,8 @@ public class OrderServices {
         List<EntityExpr> exprs = 
UtilMisc.toList(EntityCondition.makeCondition("automaticExtend", 
EntityOperator.EQUALS, "Y"),
                 EntityCondition.makeCondition("orderId", 
EntityOperator.NOT_EQUAL, null),
                 EntityCondition.makeCondition("productId", 
EntityOperator.NOT_EQUAL, null));
-        try (EntityListIterator eli = EntityQuery.use(delegator)
-                .from("Subscription")
-                .where(exprs)
-                .queryIterator()) {
+        
+        try (EntityListIterator eli = 
EntityQuery.use(delegator).from("Subscription").where(exprs).queryIterator()) {
             
             beganTransaction = TransactionUtil.begin();
             if (eli != null) {
@@ -6194,13 +6187,14 @@ public class OrderServices {
                 @Override
                 public List<String> call() throws Exception {
                     List<String> orderIds = new LinkedList<String>();
-                    try (EntityListIterator eli = EntityQuery.use(delegator)
+                    
+                    EntityQuery eq = EntityQuery.use(delegator)
                             .select("orderId")
                             .from("OrderHeader")
                             .where(cond)
-                            .orderBy("entryDate ASC")
-                            .queryIterator()){
-                        
+                            .orderBy("entryDate ASC");
+
+                    try (EntityListIterator eli = eq.queryIterator()){
                         GenericValue orderHeader;
                         while ((orderHeader = eli.next()) != null) {
                             orderIds.add(orderHeader.getString("orderId"));

Modified: 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java?rev=1788263&r1=1788262&r2=1788263&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/order/src/main/java/org/apache/ofbiz/order/shoppinglist/ShoppingListServices.java
 Thu Mar 23 15:09:23 2017
@@ -123,14 +123,14 @@ public class ShoppingListServices {
 
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         Locale locale = (Locale) context.get("locale");
-
+        
         boolean beganTransaction = false;
-        try (EntityListIterator eli = EntityQuery.use(delegator)
+        EntityQuery eq = EntityQuery.use(delegator)
                 .from("ShoppingList")
                 .where("shoppingListTypeId", "SLT_AUTO_REODR", "isActive", "Y")
-                .orderBy("-lastOrderedDate")
-                .queryIterator()) {
-
+                .orderBy("-lastOrderedDate");
+        
+        try (EntityListIterator eli = eq.queryIterator()) {
             beganTransaction = TransactionUtil.begin();
             if (eli != null) {
                 GenericValue shoppingList;

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java?rev=1788263&r1=1788262&r2=1788263&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/product/product/ProductSearchSession.java
 Thu Mar 23 15:09:23 2017
@@ -1230,14 +1230,14 @@ public class ProductSearchSession {
         
entityConditionList.add(EntityCondition.makeCondition("pfcProductFeatureTypeId",
 EntityOperator.EQUALS, productFeatureTypeId));
 
         List<Map<String, String>> featureCountList = null;
-        try (EntityListIterator eli = EntityQuery.use(delegator)
-                    .select(UtilMisc.toSet("pfacProductFeatureId", 
"featureCount", "pfcDescription", "pfcProductFeatureTypeId"))
-                    .from(dynamicViewEntity)
-                    .where(entityConditionList)
-                    .orderBy(productSearchContext.orderByList)
-                    .cursorScrollInsensitive()
-                    .queryIterator()) {
-
+        EntityQuery eq = EntityQuery.use(delegator)
+                .select(UtilMisc.toSet("pfacProductFeatureId", "featureCount", 
"pfcDescription", "pfcProductFeatureTypeId"))
+                .from(dynamicViewEntity)
+                .where(entityConditionList)
+                .orderBy(productSearchContext.orderByList)
+                .cursorScrollInsensitive();
+        
+        try (EntityListIterator eli = eq.queryIterator()) {
             featureCountList = new LinkedList<Map<String,String>>();
             GenericValue searchResult = null;
             while ((searchResult = eli.next()) != null) {
@@ -1302,14 +1302,14 @@ public class ProductSearchSession {
         
entityConditionList.add(EntityCondition.makeCondition("ppcProductPriceTypeId", 
EntityOperator.EQUALS, "LIST_PRICE"));
 
         Long priceRangeCount = Long.valueOf(0);
-        try (EntityListIterator eli = EntityQuery.use(delegator)
+        EntityQuery eq = EntityQuery.use(delegator)
                 .select(UtilMisc.toSet(fieldsToSelect))
                 .from(dynamicViewEntity)
                 .where(entityConditionList)
                 .orderBy(productSearchContext.orderByList)
-                .cursorScrollInsensitive()
-                .queryIterator()) {
+                .cursorScrollInsensitive();
 
+        try (EntityListIterator eli = eq.queryIterator()) {
             GenericValue searchResult = null;
             while ((searchResult = eli.next()) != null) {
                 priceRangeCount = searchResult.getLong("priceRangeCount");
@@ -1358,14 +1358,14 @@ public class ProductSearchSession {
         
entityConditionList.add(EntityCondition.makeCondition("pcmcProductCategoryId", 
EntityOperator.IN, productCategoryIdSet));
 
         Long categoryCount = Long.valueOf(0);
-        try (EntityListIterator eli = EntityQuery.use(delegator)
+        EntityQuery eq = EntityQuery.use(delegator)
                 .select(UtilMisc.toSet(fieldsToSelect))
                 .from(dynamicViewEntity)
                 .where(entityConditionList)
                 .orderBy(productSearchContext.orderByList)
-                .cursorScrollInsensitive()
-                .queryIterator()) {
-            
+                .cursorScrollInsensitive();
+        
+        try (EntityListIterator eli = eq.queryIterator()) {
             GenericValue searchResult = null;
             while ((searchResult = eli.next()) != null) {
                 categoryCount = searchResult.getLong("categoryCount");

Modified: 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java?rev=1788263&r1=1788262&r2=1788263&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/product/src/main/java/org/apache/ofbiz/shipment/shipment/ShipmentServices.java
 Thu Mar 23 15:09:23 2017
@@ -670,11 +670,11 @@ public class ShipmentServices {
         Locale locale = (Locale) context.get("locale");
         Map<String, String> shipmentMap = new HashMap<String, String>();
 
-        try (EntityListIterator eli = EntityQuery.use(delegator)
+        EntityQuery eq = EntityQuery.use(delegator)
                 .from("OdbcPackageIn")
-                .orderBy("shipmentId", "shipmentPackageSeqId", "voidIndicator")
-                .queryIterator()) {
-            
+                .orderBy("shipmentId", "shipmentPackageSeqId", 
"voidIndicator");
+        
+        try (EntityListIterator eli = eq.queryIterator()) {
             GenericValue pkgInfo;
             while ((pkgInfo = eli.next()) != null) {
                 String packageSeqId = 
pkgInfo.getString("shipmentPackageSeqId");

Modified: 
ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java?rev=1788263&r1=1788262&r2=1788263&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataServices.java
 Thu Mar 23 15:09:23 2017
@@ -422,6 +422,7 @@ public class EntityDataServices {
         String entityName = (String) context.get("entityName");
         String fieldName = (String) context.get("fieldName");
         Locale locale = (Locale) context.get("locale");
+        
         try (EntityListIterator eli = EntityQuery.use(delegator)
                 .from(entityName)
                 .queryIterator()) {


Reply via email to