related to ISSUE-43453: Applied Sonarlint suggestions and more
authorIñigo Lerga <inigo.lerga@openbravo.com>
Mon, 09 Mar 2020 16:44:05 +0100
changeset 37179 2c0e4eb6a5df
parent 37178 5220437cfead
child 37180 dfdffb7bcad7
related to ISSUE 43453: Applied Sonarlint suggestions and more

-Finals added
-Sonarlint suggestions applied
src/org/openbravo/materialmgmt/ReservationUtils.java
--- a/src/org/openbravo/materialmgmt/ReservationUtils.java	Mon Mar 09 16:42:28 2020 +0100
+++ b/src/org/openbravo/materialmgmt/ReservationUtils.java	Mon Mar 09 16:44:05 2020 +0100
@@ -48,8 +48,8 @@
   String returnValue;
   String exito;
 
-  public static Reservation createReserveFromSalesOrderLine(OrderLine soLine, boolean doProcess)
-      throws OBException {
+  public static Reservation createReserveFromSalesOrderLine(final OrderLine soLine,
+      final boolean doProcess) {
     if (!soLine.getSalesOrder().isSalesTransaction()) {
       throw new OBException(OBMessageUtils.messageBD("cannotReservePurchaseOrder", false));
     }
@@ -66,7 +66,7 @@
       cs = ReservationUtilsData.createReserveFromSalesOrderLine(
           OBDal.getInstance().getConnection(false), new DalConnectionProvider(false),
           soLine.getId(), doProcess ? "Y" : "N", OBContext.getOBContext().getUser().getId());
-    } catch (ServletException e) {
+    } catch (final ServletException e) {
     }
 
     if (cs != null && cs.returnValue != null) {
@@ -76,7 +76,7 @@
     return null;
   }
 
-  public static OBError reserveStockAuto(Reservation reservation) throws OBException {
+  public static OBError reserveStockAuto(final Reservation reservation) {
 
     OBDal.getInstance().flush();
     CSResponse cs = null;
@@ -84,8 +84,8 @@
       cs = ReservationUtilsData.reserveStockAuto(OBDal.getInstance().getConnection(false),
           new DalConnectionProvider(false), reservation.getId(),
           OBContext.getOBContext().getUser().getId());
-    } catch (ServletException e) {
-      String message = OBMessageUtils.translateError(e.getMessage()).getMessage();
+    } catch (final ServletException e) {
+      final String message = OBMessageUtils.translateError(e.getMessage()).getMessage();
       throw new OBException(message, e);
     }
 
@@ -94,7 +94,7 @@
       message = cs.returnValue;
     }
 
-    OBError obmessage = new OBError();
+    final OBError obmessage = new OBError();
     obmessage.setType("SUCCESS");
     obmessage.setMessage(message);
     return obmessage;
@@ -107,8 +107,8 @@
    * - OrderLine: reserves stock pending to receipt purchase order line.
    */
 
-  public static ReservationStock reserveStockManual(Reservation reservation, BaseOBObject obObject,
-      BigDecimal quantity, String allocated) throws OBException {
+  public static ReservationStock reserveStockManual(final Reservation reservation,
+      final BaseOBObject obObject, final BigDecimal quantity, final String allocated) {
 
     String strType = "";
 
@@ -127,8 +127,8 @@
           new DalConnectionProvider(false), reservation.getId(), strType,
           obObject.getId().toString(), quantity.toString(),
           OBContext.getOBContext().getUser().getId(), allocated);
-    } catch (ServletException e) {
-      String message = OBMessageUtils.translateError(e.getMessage()).getMessage();
+    } catch (final ServletException e) {
+      final String message = OBMessageUtils.translateError(e.getMessage()).getMessage();
       throw new OBException(message, e);
     }
 
@@ -149,7 +149,7 @@
    * <li>CL Close</li>
    * </ul>
    */
-  public static OBError processReserve(Reservation reservation, String action) throws OBException {
+  public static OBError processReserve(final Reservation reservation, final String action) {
 
     OBContext.setAdminMode(true);
     Process process = null;
@@ -159,7 +159,7 @@
       OBContext.restorePreviousMode();
     }
 
-    Map<String, String> parameters = new HashMap<String, String>();
+    final Map<String, String> parameters = new HashMap<>();
     parameters.put("RES_Action", action);
 
     final ProcessInstance pinstance = CallProcess.getInstance()
@@ -176,9 +176,9 @@
    *          Sales Order Line owner of the reservation.
    * @return a Reservation related to the Sales Order Line
    */
-  public static Reservation getReservationFromOrder(OrderLine salesOrderLine) {
+  public static Reservation getReservationFromOrder(final OrderLine salesOrderLine) {
     OBDal.getInstance().refresh(salesOrderLine);
-    for (Reservation res : salesOrderLine.getMaterialMgmtReservationList()) {
+    for (final Reservation res : salesOrderLine.getMaterialMgmtReservationList()) {
       if (!StringUtils.equals(res.getRESStatus(), "CL")) {
         return res;
       }
@@ -190,8 +190,8 @@
    * Function to reallocate given reservation stock on given attributes and storage bin.
    */
 
-  public static OBError reallocateStock(Reservation reservation, Locator storageBin,
-      AttributeSetInstance asi, BigDecimal quantity) throws OBException {
+  public static OBError reallocateStock(final Reservation reservation, final Locator storageBin,
+      final AttributeSetInstance asi, final BigDecimal quantity) {
 
     OBDal.getInstance().flush();
     CSResponse cs = null;
@@ -199,8 +199,8 @@
       cs = ReservationUtilsData.reallocateStock(OBDal.getInstance().getConnection(false),
           new DalConnectionProvider(false), reservation.getId(), storageBin.getId(), asi.getId(),
           quantity.toPlainString(), OBContext.getOBContext().getUser().getId());
-    } catch (ServletException e) {
-      String message = OBMessageUtils.translateError(e.getMessage()).getMessage();
+    } catch (final ServletException e) {
+      final String message = OBMessageUtils.translateError(e.getMessage()).getMessage();
       throw new OBException(message, e);
     }
 
@@ -210,9 +210,9 @@
     }
     result.setType("Success");
     result.setMessage(OBMessageUtils.messageBD("Success", false));
-    if (cs.returnValue == "0") {
+    if (cs.returnValue.equals("0")) {
       result.setType("Error");
-    } else if (cs.returnValue == "2") {
+    } else if (cs.returnValue.equals("2")) {
       result.setType("Warning");
     }
     if (StringUtils.isNotEmpty(cs.returnValueMsg)) {
@@ -228,7 +228,7 @@
    *          A StorageDetail object that contains the information about the Stock
    * @return true if there are Reservations created against this Stock, false otherwise
    */
-  public static boolean existsReservationForStock(StorageDetail storageDetail) {
+  public static boolean existsReservationForStock(final StorageDetail storageDetail) {
     //@formatter:off
     final String hql = 
             "select 1" +
@@ -265,7 +265,7 @@
    * @return a list of related Reservations Stock
    */
   public static List<ReservationStock> getReservationStockFromStorageDetail(
-      StorageDetail storageDetail) {
+      final StorageDetail storageDetail) {
     //@formatter:off
     final String hql = 
             "select rs" +