fixes BUG-43151:Applied new HQL Style + license msg added
authorIñigo Lerga <inigo.lerga@openbravo.com>
Thu, 13 Feb 2020 17:33:34 +0100
changeset 37096 2af9d85febef
parent 37095 9d1c6b92f4ee
child 37097 039bcab72e6d
fixes BUG 43151:Applied new HQL Style + license msg added
src/org/openbravo/costing/ResetStockValuation.java
--- a/src/org/openbravo/costing/ResetStockValuation.java	Thu Feb 20 11:09:36 2020 +0100
+++ b/src/org/openbravo/costing/ResetStockValuation.java	Thu Feb 13 17:33:34 2020 +0100
@@ -1,3 +1,21 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
+ * Version 1.1  with a permitted attribution clause; you may not  use this
+ * file except in compliance with the License. You  may  obtain  a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License  is  distributed  on  an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific  language  governing  rights  and  limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo SLU
+ * All portions are Copyright (C) 2012-2020 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s):  ______________________________________.
+ *************************************************************************
+ */
 package org.openbravo.costing;
 
 import java.util.ArrayList;
@@ -13,7 +31,6 @@
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.erpCommon.utility.OBMessageUtils;
-import org.openbravo.model.materialmgmt.cost.StockValuation;
 import org.openbravo.service.db.CallStoredProcedure;
 
 public class ResetStockValuation extends BaseProcessActionHandler {
@@ -51,17 +68,23 @@
       JSONObject msg = new JSONObject();
       boolean errorMessage = false;
       // delete existing records
-      StringBuffer sql = new StringBuffer();
-      sql.append("delete from");
-      sql.append("\n " + StockValuation.ENTITY_NAME + " sv");
-      sql.append("\n where sv." + StockValuation.PROPERTY_CLIENT + ".id = :client");
+      //@formatter:off
+      String hql =
+              "delete from  M_Stock_Valuation sv" +
+              " where sv.client.id = :clientId";
+      //@formatter:on
       if (strOrgID != null) {
-        sql.append("\n and sv." + StockValuation.PROPERTY_ORGANIZATION + ".id = :org");
+        //@formatter:off
+        hql +=
+              "   and sv.organization.id = :org";
+        //@formatter:on
       }
 
       @SuppressWarnings("rawtypes")
-      Query delQry = OBDal.getInstance().getSession().createQuery(sql.toString());
-      delQry.setParameter("client", OBContext.getOBContext().getCurrentClient().getId());
+      Query delQry = OBDal.getInstance()
+          .getSession()
+          .createQuery(hql)
+          .setParameter("clientId", OBContext.getOBContext().getCurrentClient().getId());
       if (strOrgID != null) {
         delQry.setParameter("org", strOrgID);
       }