Related to ISSUE-43305. Code Review changes:
authorDavid Miguelez <david.miguelez@openbravo.com>
Mon, 02 Mar 2020 17:29:15 +0100
changeset 37127 a01177def4a2
parent 37126 bc583dbe363d
child 37128 cb93d1d1453f
Related to ISSUE 43305. Code Review changes:
* Changed variable name to reflect that it is an id
* Split case when clauses in different lines to improve
redability
src/org/openbravo/erpCommon/ad_process/MRPPurchaseCreateReservations.java
--- a/src/org/openbravo/erpCommon/ad_process/MRPPurchaseCreateReservations.java	Tue Feb 25 10:05:53 2020 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/MRPPurchaseCreateReservations.java	Mon Mar 02 17:29:15 2020 +0100
@@ -166,16 +166,20 @@
   private ScrollableResults getPRLinesIncoming(final PurchasingRun mrpPurchaseRun) {
     //@formatter:off
     final String hql =
-                  " where purchasingPlan.id = :purchaserun" +
+                  " where purchasingPlan.id = :purchaserunId" +
                   "   and quantity > 0" +
                   " order by product" +
                   "   ,plannedDate " +
-                  "   , CASE transactionType WHEN 'ST' THEN 0 WHEN 'MS' THEN 2 ELSE 1 END";
+                  "   , case transactionType " +
+                  "       when 'ST' then 0 " +
+                  "       when 'MS' then 2 " +
+                  "       else 1 " +
+                  "     end";
     //@formatter:on
 
     return OBDal.getInstance()
         .createQuery(PurchasingRunLine.class, hql)
-        .setNamedParameter("purchaserun", mrpPurchaseRun.getId())
+        .setNamedParameter("purchaserunId", mrpPurchaseRun.getId())
         .setFetchSize(1000)
         .scroll(ScrollMode.FORWARD_ONLY);
   }
@@ -183,16 +187,20 @@
   private ScrollableResults getPRLinesOutgoing(final PurchasingRun mrpPurchaseRun) {
     //@formatter:off
     final String hql =
-                  " where purchasingPlan.id = :purchaserun" +
+                  " where purchasingPlan.id = :purchaserunId" +
                   "   and quantity < 0" +
                   " order by product" +
                   "   , plannedDate" +
-                  "   , CASE transactionType WHEN 'ST' THEN 0 WHEN 'MS' THEN 2 ELSE 3 END";
+                  "   , case transactionType " +
+                  "       when 'ST' then 0 " +
+                  "       when 'MS' then 2 " +
+                  "       else 3 " +
+                  "     end";
     //@formatter:on
 
     return OBDal.getInstance()
         .createQuery(PurchasingRunLine.class, hql)
-        .setNamedParameter("purchaserun", mrpPurchaseRun.getId())
+        .setNamedParameter("purchaserunId", mrpPurchaseRun.getId())
         .setFetchSize(1000)
         .scroll(ScrollMode.FORWARD_ONLY);
   }