Fixes BUG-42879: Apply new HQL style in
authorAtul Gaware <atul.gaware@openbravo.com>
Fri, 17 Jan 2020 09:31:57 +0530
changeset 36993 8c6c8e505183
parent 36992 fbb1a6a2b4cd
child 36994 4b54c2f66cb0
Fixes BUG 42879: Apply new HQL style in
ProductServiceConfigurationObserver

**Avoid StringBuilder, use Strings for hql queries, formatter off
on to improve readability.
**Avoid use of Property Constants
src/org/openbravo/event/ProductServiceConfigurationObserver.java
--- a/src/org/openbravo/event/ProductServiceConfigurationObserver.java	Tue Jan 21 13:17:31 2020 +0100
+++ b/src/org/openbravo/event/ProductServiceConfigurationObserver.java	Fri Jan 17 09:31:57 2020 +0530
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2015-2019 Openbravo SLU 
+ * All portions are Copyright (C) 2015-2020 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -30,7 +30,6 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
-import org.openbravo.model.common.order.Order;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.common.plm.Product;
 
@@ -73,17 +72,15 @@
   }
 
   private void checkNotDeliveredOrders(Product product) {
-    StringBuilder hql = new StringBuilder();
-    hql.append("as ol ");
-    hql.append("join ol." + OrderLine.PROPERTY_SALESORDER + " as o ");
-    hql.append("where o." + Order.PROPERTY_DOCUMENTSTATUS);
-    hql.append(" = 'CO' ");
-    hql.append("and ol." + OrderLine.PROPERTY_PRODUCT);
-    hql.append(" = :product ");
-    hql.append("and ol." + OrderLine.PROPERTY_DELIVEREDQUANTITY + "<> ol."
-        + OrderLine.PROPERTY_ORDEREDQUANTITY);
+    //@formatter:off
+    String hql = "as ol "
+               + "join ol.salesOrder as o "
+               + "where o.documentStatus = 'CO' "
+               + "and ol.product = :product "
+               + "and ol.deliveredQuantity <> ol.orderedQuantity ";
+    //@formatter:on
     OBQuery<OrderLine> notDeliveredOrderLineQuery = OBDal.getInstance()
-        .createQuery(OrderLine.class, hql.toString());
+        .createQuery(OrderLine.class, hql);
     notDeliveredOrderLineQuery.setNamedParameter("product", product);
     notDeliveredOrderLineQuery.setMaxResult(1);
     OrderLine notDeliveredOrderLine = notDeliveredOrderLineQuery.uniqueResult();