Related To ISSUE-42879: Apply new HQL style in
authorAtul Gaware <atul.gaware@openbravo.com>
Fri, 17 Jan 2020 09:35:25 +0530
changeset 36994 4b54c2f66cb0
parent 36993 8c6c8e505183
child 36995 5ab3c9946be6
Related To ISSUE 42879: Apply new HQL style in
ProductServiceConfigurationObserver

**Applied SonarLint suggestions to use equals() method instead of
!= when comparing Boolean Object
**Simplied call to query object
src/org/openbravo/event/ProductServiceConfigurationObserver.java
--- a/src/org/openbravo/event/ProductServiceConfigurationObserver.java	Fri Jan 17 09:31:57 2020 +0530
+++ b/src/org/openbravo/event/ProductServiceConfigurationObserver.java	Fri Jan 17 09:35:25 2020 +0530
@@ -28,7 +28,6 @@
 import org.openbravo.client.kernel.event.EntityPersistenceEventObserver;
 import org.openbravo.client.kernel.event.EntityUpdateEvent;
 import org.openbravo.dal.service.OBDal;
-import org.openbravo.dal.service.OBQuery;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
 import org.openbravo.model.common.order.OrderLine;
 import org.openbravo.model.common.plm.Product;
@@ -66,7 +65,7 @@
       qtyRule = "";
     }
     final Product product = OBDal.getInstance().get(Product.class, (String) event.getId());
-    if (linkedToProductPrevious != linkedToProduct || !qtyRulePrevious.equals(qtyRule)) {
+    if (!linkedToProductPrevious.equals(linkedToProduct) || !qtyRulePrevious.equals(qtyRule)) {
       checkNotDeliveredOrders(product);
     }
   }
@@ -79,11 +78,11 @@
                + "and ol.product = :product "
                + "and ol.deliveredQuantity <> ol.orderedQuantity ";
     //@formatter:on
-    OBQuery<OrderLine> notDeliveredOrderLineQuery = OBDal.getInstance()
-        .createQuery(OrderLine.class, hql);
-    notDeliveredOrderLineQuery.setNamedParameter("product", product);
-    notDeliveredOrderLineQuery.setMaxResult(1);
-    OrderLine notDeliveredOrderLine = notDeliveredOrderLineQuery.uniqueResult();
+    OrderLine notDeliveredOrderLine = OBDal.getInstance()
+        .createQuery(OrderLine.class, hql)
+        .setNamedParameter("product", product)
+        .setMaxResult(1)
+        .uniqueResult();
     if (notDeliveredOrderLine != null) {
       String[] params = { notDeliveredOrderLine.getSalesOrder().getDocumentNo() };
       throw new OBException(OBMessageUtils.getI18NMessage("ServiceCannotBeModified", params));