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
This commit is contained in:
Carlos Ruiz 2010-03-04 00:06:16 +00:00
parent 08e0deb5cd
commit 21f04ba76f
9 changed files with 27 additions and 26 deletions

View File

@ -78,9 +78,10 @@ public class MReplenish extends X_M_Replenish {
* @return A list of active replenish lines for given product. * @return A list of active replenish lines for given product.
*/ */
public static List<MReplenish> getForProduct(Properties ctx, int M_ProductID, String trxName) { public static List<MReplenish> 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) 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") .setOrderBy("AD_Org_ID")
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();

View File

@ -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 * Get Request ID from mail text

View File

@ -102,7 +102,7 @@ public class MRequisition extends X_M_Requisition implements DocAction
} }
//red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query //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 <MRequisitionLine> list = new Query(getCtx(), I_M_RequisitionLine.Table_Name, whereClause, get_TrxName()) List <MRequisitionLine> list = new Query(getCtx(), I_M_RequisitionLine.Table_Name, whereClause, get_TrxName())
.setParameters(get_ID()) .setParameters(get_ID())
.setOrderBy(I_M_RequisitionLine.COLUMNNAME_Line) .setOrderBy(I_M_RequisitionLine.COLUMNNAME_Line)

View File

@ -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 * Get corresponding Requisition Line for given Order Line

View File

@ -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 * Check if a resource is not available

View File

@ -187,8 +187,8 @@ public class MScheduler extends X_AD_Scheduler
if (!reload && m_recipients != null) if (!reload && m_recipients != null)
return m_recipients; return m_recipients;
// //
String whereClause = MSchedulerRecipient.COLUMNNAME_AD_Scheduler_ID+"=?"; final String whereClause = MSchedulerRecipient.COLUMNNAME_AD_Scheduler_ID+"=?";
final List<MSchedulerRecipient> list = new Query(getCtx(), I_AD_SchedulerRecipient.Table_Name, whereClause, get_TrxName()) List<MSchedulerRecipient> list = new Query(getCtx(), I_AD_SchedulerRecipient.Table_Name, whereClause, get_TrxName())
.setParameters(getAD_Scheduler_ID()) .setParameters(getAD_Scheduler_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();

View File

@ -40,7 +40,7 @@ public class MTax extends X_C_Tax
/** /**
* *
*/ */
private static final long serialVersionUID = 4140382472528327237L; private static final long serialVersionUID = 6423328193350641479L;
/** Cache */ /** Cache */
private static CCache<Integer,MTax> s_cache = new CCache<Integer,MTax>(Table_Name, 5); private static CCache<Integer,MTax> s_cache = new CCache<Integer,MTax>(Table_Name, 5);
@ -69,9 +69,8 @@ public class MTax extends X_C_Tax
// Create it // Create it
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "AD_Client_ID=?"; List<MTax> list = new Query(ctx, I_C_Tax.Table_Name, null, null)
List<MTax> list = new Query(ctx, I_C_Tax.Table_Name, whereClause, null) .setClient_ID()
.setParameters(AD_Client_ID)
.setOrderBy("C_Country_ID, C_Region_ID, To_Country_ID, To_Region_ID") .setOrderBy("C_Country_ID, C_Region_ID, To_Country_ID, To_Region_ID")
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
@ -169,7 +168,7 @@ public class MTax extends X_C_Tax
return m_childTaxes; return m_childTaxes;
// //
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = COLUMNNAME_Parent_Tax_ID+"=?"; final String whereClause = COLUMNNAME_Parent_Tax_ID+"=?";
List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName()) List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName())
.setParameters(getC_Tax_ID()) .setParameters(getC_Tax_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)

View File

@ -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 * Standard Constructor
@ -71,7 +71,7 @@ public class MTaxCategory extends X_C_TaxCategory
{ {
MTax m_tax = new MTax(getCtx(), 0, get_TrxName()); 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<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName()) List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName())
.setParameters(getC_TaxCategory_ID()) .setParameters(getC_TaxCategory_ID())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)

View File

@ -76,9 +76,10 @@ public class MWarehouse extends X_M_Warehouse
*/ */
public static MWarehouse[] getForOrg (Properties ctx, int AD_Org_ID) public static MWarehouse[] getForOrg (Properties ctx, int AD_Org_ID)
{ {
String whereClause = "IsActive=? AND AD_Org_ID=?"; final String whereClause = "AD_Org_ID=?";
List<MWarehouse> list = new Query(ctx, Table_Name, whereClause, null) List<MWarehouse> list = new Query(ctx, Table_Name, whereClause, null)
.setParameters("Y", AD_Org_ID) .setParameters(AD_Org_ID)
.setOnlyActiveRecords(true)
.setOrderBy(COLUMNNAME_M_Warehouse_ID) .setOrderBy(COLUMNNAME_M_Warehouse_ID)
.list(); .list();
return list.toArray(new MWarehouse[list.size()]); 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) 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<MWarehouse> list = new Query(ctx, Table_Name, whereClause, null) List<MWarehouse> 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) .setOrderBy(COLUMNNAME_M_Warehouse_ID)
.list(); .list();
return list.toArray(new MWarehouse[list.size()]); return list.toArray(new MWarehouse[list.size()]);
@ -159,9 +161,10 @@ public class MWarehouse extends X_M_Warehouse
if (!reload && m_locators != null) if (!reload && m_locators != null)
return m_locators; return m_locators;
// //
final String whereClause = "IsActive=? AND M_Warehouse_ID=?"; final String whereClause = "M_Warehouse_ID=?";
List<MLocator> list = new Query(getCtx(), I_M_Locator.Table_Name, whereClause, null) List<MLocator> 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") .setOrderBy("X,Y,Z")
.list(); .list();
m_locators = list.toArray(new MLocator[list.size()]); m_locators = list.toArray(new MLocator[list.size()]);