From 21f04ba76f5ce29a238f258e896933f19ad0f128 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 4 Mar 2010 00:06:16 +0000 Subject: [PATCH] peer review for 11555 - refactorings to use setClientID and setOnlyActiveRecords - check serialVersionUID on affected classes - add final to whereClauses FR: [ 2214883 ] Remove SQL code and Replace for Query Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- base/src/org/compiere/model/MReplenish.java | 5 +++-- base/src/org/compiere/model/MRequest.java | 3 +-- base/src/org/compiere/model/MRequisition.java | 2 +- base/src/org/compiere/model/MRequisitionLine.java | 2 +- .../org/compiere/model/MResourceUnAvailable.java | 3 +-- base/src/org/compiere/model/MScheduler.java | 6 +++--- base/src/org/compiere/model/MTax.java | 13 ++++++------- base/src/org/compiere/model/MTaxCategory.java | 4 ++-- base/src/org/compiere/model/MWarehouse.java | 15 +++++++++------ 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/base/src/org/compiere/model/MReplenish.java b/base/src/org/compiere/model/MReplenish.java index 72fad56c84..7f50fabc8f 100644 --- a/base/src/org/compiere/model/MReplenish.java +++ b/base/src/org/compiere/model/MReplenish.java @@ -78,9 +78,10 @@ public class MReplenish extends X_M_Replenish { * @return A list of active replenish lines for given product. */ public static List getForProduct(Properties ctx, int M_ProductID, String trxName) { - final String whereClause= "M_Product_ID=? AND AD_Client_ID=? AND AD_Org_ID IN (0, ?) "; + final String whereClause= "M_Product_ID=? AND AD_Org_ID IN (0, ?) "; return new Query(ctx, I_M_Replenish.Table_Name, whereClause, trxName) - .setParameters(M_ProductID, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx)) + .setParameters(M_ProductID, Env.getAD_Org_ID(ctx)) + .setClient_ID() .setOrderBy("AD_Org_ID") .setOnlyActiveRecords(true) .list(); diff --git a/base/src/org/compiere/model/MRequest.java b/base/src/org/compiere/model/MRequest.java index 40434e6810..258be57869 100644 --- a/base/src/org/compiere/model/MRequest.java +++ b/base/src/org/compiere/model/MRequest.java @@ -43,8 +43,7 @@ public class MRequest extends X_R_Request /** * */ - private static final long serialVersionUID = 3989278951102963994L; - + private static final long serialVersionUID = -6049674214655497548L; /** * Get Request ID from mail text diff --git a/base/src/org/compiere/model/MRequisition.java b/base/src/org/compiere/model/MRequisition.java index c7b032918b..7a898efe06 100644 --- a/base/src/org/compiere/model/MRequisition.java +++ b/base/src/org/compiere/model/MRequisition.java @@ -102,7 +102,7 @@ public class MRequisition extends X_M_Requisition implements DocAction } //red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query - String whereClause = I_M_RequisitionLine.COLUMNNAME_M_Requisition_ID+"=?"; + final String whereClause = I_M_RequisitionLine.COLUMNNAME_M_Requisition_ID+"=?"; List list = new Query(getCtx(), I_M_RequisitionLine.Table_Name, whereClause, get_TrxName()) .setParameters(get_ID()) .setOrderBy(I_M_RequisitionLine.COLUMNNAME_Line) diff --git a/base/src/org/compiere/model/MRequisitionLine.java b/base/src/org/compiere/model/MRequisitionLine.java index 17612b7245..29ef5384ce 100644 --- a/base/src/org/compiere/model/MRequisitionLine.java +++ b/base/src/org/compiere/model/MRequisitionLine.java @@ -45,7 +45,7 @@ public class MRequisitionLine extends X_M_RequisitionLine /** * */ - private static final long serialVersionUID = 3556301115666692794L; + private static final long serialVersionUID = -2567343619431184322L; /** * Get corresponding Requisition Line for given Order Line diff --git a/base/src/org/compiere/model/MResourceUnAvailable.java b/base/src/org/compiere/model/MResourceUnAvailable.java index 255bc6fc59..5c7254d91b 100644 --- a/base/src/org/compiere/model/MResourceUnAvailable.java +++ b/base/src/org/compiere/model/MResourceUnAvailable.java @@ -38,8 +38,7 @@ public class MResourceUnAvailable extends X_S_ResourceUnAvailable /** * */ - private static final long serialVersionUID = 5532695704071630122L; - + private static final long serialVersionUID = 1087763356022282086L; /** * Check if a resource is not available diff --git a/base/src/org/compiere/model/MScheduler.java b/base/src/org/compiere/model/MScheduler.java index 005e7efd7c..984ee8a54c 100644 --- a/base/src/org/compiere/model/MScheduler.java +++ b/base/src/org/compiere/model/MScheduler.java @@ -1,5 +1,5 @@ /****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * + * Product: Adempiere ERP & CRM Smart Business Solution * * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * @@ -187,8 +187,8 @@ public class MScheduler extends X_AD_Scheduler if (!reload && m_recipients != null) return m_recipients; // - String whereClause = MSchedulerRecipient.COLUMNNAME_AD_Scheduler_ID+"=?"; - final List list = new Query(getCtx(), I_AD_SchedulerRecipient.Table_Name, whereClause, get_TrxName()) + final String whereClause = MSchedulerRecipient.COLUMNNAME_AD_Scheduler_ID+"=?"; + List list = new Query(getCtx(), I_AD_SchedulerRecipient.Table_Name, whereClause, get_TrxName()) .setParameters(getAD_Scheduler_ID()) .setOnlyActiveRecords(true) .list(); diff --git a/base/src/org/compiere/model/MTax.java b/base/src/org/compiere/model/MTax.java index c438dec4ab..ef4abcbe52 100644 --- a/base/src/org/compiere/model/MTax.java +++ b/base/src/org/compiere/model/MTax.java @@ -36,12 +36,12 @@ import org.compiere.util.TimeUtil; * mjmckay - BF [2948632] - Allow edits to the Defautl Tax Rate */ public class MTax extends X_C_Tax -{ +{ /** * */ - private static final long serialVersionUID = 4140382472528327237L; - + private static final long serialVersionUID = 6423328193350641479L; + /** Cache */ private static CCache s_cache = new CCache(Table_Name, 5); /** Cache of Client */ @@ -69,9 +69,8 @@ public class MTax extends X_C_Tax // Create it //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 - String whereClause = "AD_Client_ID=?"; - List list = new Query(ctx, I_C_Tax.Table_Name, whereClause, null) - .setParameters(AD_Client_ID) + List list = new Query(ctx, I_C_Tax.Table_Name, null, null) + .setClient_ID() .setOrderBy("C_Country_ID, C_Region_ID, To_Country_ID, To_Region_ID") .setOnlyActiveRecords(true) .list(); @@ -169,7 +168,7 @@ public class MTax extends X_C_Tax return m_childTaxes; // //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 - String whereClause = COLUMNNAME_Parent_Tax_ID+"=?"; + final String whereClause = COLUMNNAME_Parent_Tax_ID+"=?"; List list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName()) .setParameters(getC_Tax_ID()) .setOnlyActiveRecords(true) diff --git a/base/src/org/compiere/model/MTaxCategory.java b/base/src/org/compiere/model/MTaxCategory.java index 8d4762b03f..9285c57a1a 100644 --- a/base/src/org/compiere/model/MTaxCategory.java +++ b/base/src/org/compiere/model/MTaxCategory.java @@ -33,7 +33,7 @@ public class MTaxCategory extends X_C_TaxCategory /** * */ - private static final long serialVersionUID = 2154364435808111060L; + private static final long serialVersionUID = -5521670797405300136L; /** * Standard Constructor @@ -71,7 +71,7 @@ public class MTaxCategory extends X_C_TaxCategory { MTax m_tax = new MTax(getCtx(), 0, get_TrxName()); - String whereClause = COLUMNNAME_C_TaxCategory_ID+"=? AND "+ COLUMNNAME_IsDefault+"='Y'"; + final String whereClause = COLUMNNAME_C_TaxCategory_ID+"=? AND "+ COLUMNNAME_IsDefault+"='Y'"; List list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName()) .setParameters(getC_TaxCategory_ID()) .setOnlyActiveRecords(true) diff --git a/base/src/org/compiere/model/MWarehouse.java b/base/src/org/compiere/model/MWarehouse.java index a41bff78ef..2fb48c8513 100644 --- a/base/src/org/compiere/model/MWarehouse.java +++ b/base/src/org/compiere/model/MWarehouse.java @@ -76,9 +76,10 @@ public class MWarehouse extends X_M_Warehouse */ public static MWarehouse[] getForOrg (Properties ctx, int AD_Org_ID) { - String whereClause = "IsActive=? AND AD_Org_ID=?"; + final String whereClause = "AD_Org_ID=?"; List list = new Query(ctx, Table_Name, whereClause, null) - .setParameters("Y", AD_Org_ID) + .setParameters(AD_Org_ID) + .setOnlyActiveRecords(true) .setOrderBy(COLUMNNAME_M_Warehouse_ID) .list(); return list.toArray(new MWarehouse[list.size()]); @@ -93,9 +94,10 @@ public class MWarehouse extends X_M_Warehouse */ public static MWarehouse[] getInTransitForOrg (Properties ctx, int AD_Org_ID) { - String whereClause = "IsActive=? AND IsInTransit=? AND AD_Org_ID=?"; + final String whereClause = "IsInTransit=? AND AD_Org_ID=?"; List list = new Query(ctx, Table_Name, whereClause, null) - .setParameters("Y", "Y", AD_Org_ID) + .setParameters("Y", AD_Org_ID) + .setOnlyActiveRecords(true) .setOrderBy(COLUMNNAME_M_Warehouse_ID) .list(); return list.toArray(new MWarehouse[list.size()]); @@ -159,9 +161,10 @@ public class MWarehouse extends X_M_Warehouse if (!reload && m_locators != null) return m_locators; // - final String whereClause = "IsActive=? AND M_Warehouse_ID=?"; + final String whereClause = "M_Warehouse_ID=?"; List list = new Query(getCtx(), I_M_Locator.Table_Name, whereClause, null) - .setParameters("Y", getM_Warehouse_ID()) + .setParameters(getM_Warehouse_ID()) + .setOnlyActiveRecords(true) .setOrderBy("X,Y,Z") .list(); m_locators = list.toArray(new MLocator[list.size()]);