Review FR: [ 2214883 ] Remove SQL code and Replace for Query >> to incorporate Best Practice. No unit testing done but compiler tested OK.

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
Redhuan D. Oon 2010-03-02 15:44:42 +00:00
parent 7fb5e6b54d
commit 3486415202
17 changed files with 57 additions and 57 deletions

View File

@ -95,8 +95,8 @@ public class MRMA extends X_M_RMA implements DocAction
set_TrxName(m_lines, get_TrxName());
return m_lines;
}
List<MRMALine> list = new Query(getCtx(), MRMALine.Table_Name, "M_RMA_ID=?", get_TrxName())
.setParameters(new Object[]{getM_RMA_ID()})
List<MRMALine> list = new Query(getCtx(), I_M_RMALine.Table_Name, "M_RMA_ID=?", get_TrxName())
.setParameters(getM_RMA_ID())
.setOrderBy(MRMALine.COLUMNNAME_Line)
.list();

View File

@ -168,8 +168,8 @@ public class MRMALine extends X_M_RMALine
*/
private int getInvoiceLineId()
{
int invoiceLine_ID = new Query(getCtx(), MInvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName())
.setParameters(new Object[]{getM_InOutLine_ID()})
int invoiceLine_ID = new Query(getCtx(), I_C_InvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName())
.setParameters(getM_InOutLine_ID())
.firstIdOnly();
return invoiceLine_ID <= 0 ? 0 : invoiceLine_ID;
}

View File

@ -58,7 +58,7 @@ public class MRefList extends X_AD_Ref_List
public static MRefList get (Properties ctx, int AD_Reference_ID, String Value, String trxName)
{
return new Query(ctx, Table_Name, "AD_Reference_ID=? AND Value=?", trxName)
.setParameters(new Object[]{AD_Reference_ID, Value})
.setParameters(AD_Reference_ID, Value)
.firstOnly();
} // get

View File

@ -78,9 +78,9 @@ public class MReplenish extends X_M_Replenish {
* @return A list of active replenish lines for given product.
*/
public static List<MReplenish> getForProduct(Properties ctx, int M_ProductID, String trxName) {
String whereClause= "M_Product_ID=? AND AD_Client_ID=? AND AD_Org_ID IN (0, ?) ";
return new Query(ctx, MReplenish.Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_ProductID, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx)})
final String whereClause= "M_Product_ID=? AND AD_Client_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))
.setOrderBy("AD_Org_ID")
.setOnlyActiveRecords(true)
.list();

View File

@ -57,10 +57,10 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
* @return the collection the X_AD_ReplicationTable
*/
public Collection <X_AD_ReplicationTable> getReplicationTables() {
String whereClause = new StringBuffer(X_AD_ReplicationTable.COLUMNNAME_AD_ReplicationStrategy_ID)+"=?"; // #1
final String whereClause = new StringBuffer(X_AD_ReplicationTable.COLUMNNAME_AD_ReplicationStrategy_ID)+"=?"; // #1
return new Query(getCtx(), X_AD_ReplicationTable.Table_Name, whereClause, get_TrxName())
.setClient_ID()
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
.setParameters(getAD_ReplicationStrategy_ID())
.setOnlyActiveRecords(true)
.setApplyAccessFilter(false)
.list()
@ -74,7 +74,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
String whereClause = "AD_ReplicationStrategy_ID=?"; // #1
return new Query(getCtx(),X_AD_ReplicationDocument.Table_Name,whereClause,get_TrxName())
.setClient_ID()
.setParameters(new Object[]{getAD_ReplicationStrategy_ID()})
.setParameters(getAD_ReplicationStrategy_ID())
.setOnlyActiveRecords(true)
.setApplyAccessFilter(false)
.list()
@ -88,12 +88,12 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
*/
public static X_AD_ReplicationTable getReplicationTable(Properties ctx ,int AD_ReplicationStrategy_ID, int AD_Table_ID)
{
String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
final String whereClause = "AD_ReplicationStrategy_ID=? AND AD_Table_ID=?";
return new Query(ctx, X_AD_ReplicationTable.Table_Name, whereClause, null)
.setClient_ID()
.setOnlyActiveRecords(true)
.setApplyAccessFilter(false)
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID})
.setParameters(AD_ReplicationStrategy_ID, AD_Table_ID)
.first()
;
}
@ -110,7 +110,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
.setClient_ID()
.setOnlyActiveRecords(true)
.setApplyAccessFilter(false)
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID})
.setParameters(AD_ReplicationStrategy_ID, AD_Table_ID)
.first()
;
}
@ -127,7 +127,7 @@ public class MReplicationStrategy extends X_AD_ReplicationStrategy {
.setClient_ID()
.setOnlyActiveRecords(true)
.setApplyAccessFilter(false)
.setParameters(new Object[]{AD_ReplicationStrategy_ID, AD_Table_ID, C_DocType_ID})
.setParameters(AD_ReplicationStrategy_ID, AD_Table_ID, C_DocType_ID)
.first();
}

View File

@ -237,8 +237,8 @@ public class MRequest extends X_R_Request
public MRequestAction[] getActions()
{
final String whereClause = MRequestAction.COLUMNNAME_R_Request_ID+"=?";
List<MRequestAction> list = new Query(getCtx(), MRequestAction.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()})
List<MRequestAction> list = new Query(getCtx(), I_R_RequestAction.Table_Name, whereClause, get_TrxName())
.setParameters(get_ID())
.setOrderBy("Created DESC")
.list();
return list.toArray(new MRequestAction[list.size()]);
@ -252,8 +252,8 @@ public class MRequest extends X_R_Request
public MRequestUpdate[] getUpdates(String confidentialType)
{
final String whereClause = MRequestUpdate.COLUMNNAME_R_Request_ID+"=?";
List<MRequestUpdate> listUpdates = new Query(getCtx(), MRequestUpdate.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()})
List<MRequestUpdate> listUpdates = new Query(getCtx(), I_R_RequestUpdate.Table_Name, whereClause, get_TrxName())
.setParameters(get_ID())
.setOrderBy("Created DESC")
.list();
ArrayList<MRequestUpdate> list = new ArrayList<MRequestUpdate>();

View File

@ -102,10 +102,10 @@ public class MRequisition extends X_M_Requisition implements DocAction
}
//red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query
String whereClause = MRequisitionLine.COLUMNNAME_M_Requisition_ID+"=?";
List <MRequisitionLine> list = new Query(getCtx(), MRequisitionLine.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()})
.setOrderBy(MRequisitionLine.COLUMNNAME_Line)
String whereClause = I_M_RequisitionLine.COLUMNNAME_M_Requisition_ID+"=?";
List <MRequisitionLine> list = new Query(getCtx(), I_M_RequisitionLine.Table_Name, whereClause, get_TrxName())
.setParameters(get_ID())
.setOrderBy(I_M_RequisitionLine.COLUMNNAME_Line)
.list();
// red1 - end -

View File

@ -59,8 +59,8 @@ public class MRequisitionLine extends X_M_RequisitionLine
final String whereClause = "EXISTS (SELECT 1 FROM C_OrderLine ol"
+" WHERE ol.C_OrderLine_ID=M_RequisitionLine.C_OrderLine_ID"
+" AND ol.C_Order_ID=?)";
List<MRequisitionLine> list = new Query(ctx, MRequisitionLine.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_Order_ID})
List<MRequisitionLine> list = new Query(ctx, I_M_RequisitionLine.Table_Name, whereClause, trxName)
.setParameters(C_Order_ID)
.list();
return list.toArray(new MRequisitionLine[list.size()]);
}
@ -91,8 +91,8 @@ public class MRequisitionLine extends X_M_RequisitionLine
public static MRequisitionLine[] forC_OrderLine_ID(Properties ctx, int C_OrderLine_ID, String trxName)
{
final String whereClause = COLUMNNAME_C_OrderLine_ID+"=?";
List<MRequisitionLine> list = new Query(ctx, MRequisitionLine.Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_OrderLine_ID})
List<MRequisitionLine> list = new Query(ctx, I_M_RequisitionLine.Table_Name, whereClause, trxName)
.setParameters(C_OrderLine_ID)
.list();
return list.toArray(new MRequisitionLine[list.size()]);
}

View File

@ -54,8 +54,8 @@ public class MResourceUnAvailable extends X_S_ResourceUnAvailable
+" AND TRUNC("+COLUMNNAME_DateFrom+") <= ?"
+" AND TRUNC("+COLUMNNAME_DateTo+") >= ?";
Properties ctx = r instanceof PO ? ((PO)r).getCtx() : Env.getCtx();
return new Query(ctx, MResourceUnAvailable.Table_Name, whereClause, null)
.setParameters(new Object[]{r.getS_Resource_ID(), r.getAD_Client_ID(), date, date})
return new Query(ctx, I_S_ResourceUnAvailable.Table_Name, whereClause, null)
.setParameters(r.getS_Resource_ID(), r.getAD_Client_ID(), date, date)
.match();
}

View File

@ -124,8 +124,8 @@ public class MScheduler extends X_AD_Scheduler
public AdempiereProcessorLog[] getLogs ()
{
final String whereClause = MSchedulerLog.COLUMNNAME_AD_Scheduler_ID+"=?";
List<MSchedulerLog> list = new Query(getCtx(), MSchedulerLog.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getAD_Scheduler_ID()})
List<MSchedulerLog> list = new Query(getCtx(), I_AD_SchedulerLog.Table_Name, whereClause, get_TrxName())
.setParameters(getAD_Scheduler_ID())
.setOrderBy("Created DESC")
.list();
MSchedulerLog[] retValue = new MSchedulerLog[list.size ()];
@ -168,8 +168,8 @@ public class MScheduler extends X_AD_Scheduler
return m_parameter;
//
final String whereClause = MSchedulerPara.COLUMNNAME_AD_Scheduler_ID+"=?";
List<MSchedulerPara> list = new Query(getCtx(), MSchedulerPara.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getAD_Scheduler_ID()})
List<MSchedulerPara> list = new Query(getCtx(), I_AD_Scheduler_Para.Table_Name, whereClause, get_TrxName())
.setParameters(getAD_Scheduler_ID())
.setOnlyActiveRecords(true)
.list();
m_parameter = new MSchedulerPara[list.size()];
@ -188,8 +188,8 @@ public class MScheduler extends X_AD_Scheduler
return m_recipients;
//
String whereClause = MSchedulerRecipient.COLUMNNAME_AD_Scheduler_ID+"=?";
final List<MSchedulerRecipient> list = new Query(getCtx(), MSchedulerRecipient.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getAD_Scheduler_ID()})
final List<MSchedulerRecipient> list = new Query(getCtx(), I_AD_SchedulerRecipient.Table_Name, whereClause, get_TrxName())
.setParameters(getAD_Scheduler_ID())
.setOnlyActiveRecords(true)
.list();
m_recipients = new MSchedulerRecipient[list.size()];

View File

@ -67,10 +67,10 @@ public class MShipper extends X_M_Shipper
* @return A list of shippers having the given freight category
*/
public static List<MShipper> getShippersForFreightCategory(Properties ctx, int FreightCategory_ID, String trxName) {
Query q = new Query(ctx, MShipper.Table_Name,
Query q = new Query(ctx, I_M_Shipper.Table_Name,
"M_Shipper.AD_Client_ID=? AND M_Shipper.AD_Org_ID IN (0,?) AND M_Shipper_ID " +
"IN (SELECT M_Shipper_ID FROM M_Freight WHERE M_FreightCategory_ID=?)", trxName);
q.setParameters(new Object[]{Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx), FreightCategory_ID});
q.setParameters(Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx), FreightCategory_ID);
List<MShipper> result = q.list();
return(result);
}

View File

@ -83,7 +83,7 @@ public class MTableScriptValidator extends X_AD_Table_ScriptValidator
// Fetch now
final String whereClause = "AD_Table_ID=? AND EventModelValidator=?";
mvrs = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{ad_table_id, event})
.setParameters(ad_table_id, event)
.setOnlyActiveRecords(true)
.setOrderBy(COLUMNNAME_SeqNo)
.list();

View File

@ -70,8 +70,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<MTax> list = new Query(ctx, MTax.Table_Name, whereClause, null)
.setParameters(new Object[]{AD_Client_ID})
List<MTax> list = new Query(ctx, I_C_Tax.Table_Name, whereClause, null)
.setParameters(AD_Client_ID)
.setOrderBy("C_Country_ID, C_Region_ID, To_Country_ID, To_Region_ID")
.setOnlyActiveRecords(true)
.list();
@ -170,8 +170,8 @@ public class MTax extends X_C_Tax
//
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = COLUMNNAME_Parent_Tax_ID+"=?";
List<MTax> list = new Query(getCtx(), MTax.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getC_Tax_ID()})
List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName())
.setParameters(getC_Tax_ID())
.setOnlyActiveRecords(true)
.list();
//red1 - end -
@ -192,11 +192,11 @@ public class MTax extends X_C_Tax
return m_postals;
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = MTaxPostal.COLUMNNAME_C_Tax_ID+"=?";
List<MTaxPostal> list = new Query(getCtx(), MTaxPostal.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getC_Tax_ID()})
final String whereClause = MTaxPostal.COLUMNNAME_C_Tax_ID+"=?";
List<MTaxPostal> list = new Query(getCtx(), I_C_TaxPostal.Table_Name, whereClause, get_TrxName())
.setParameters(getC_Tax_ID())
.setOnlyActiveRecords(true)
.setOrderBy(MTaxPostal.COLUMNNAME_Postal+", "+MTaxPostal.COLUMNNAME_Postal_To)
.setOrderBy(I_C_TaxPostal.COLUMNNAME_Postal+", "+I_C_TaxPostal.COLUMNNAME_Postal_To)
.list();
//red1 - end -
@ -286,8 +286,8 @@ public class MTax extends X_C_Tax
String whereClause = MTax.COLUMNNAME_C_TaxCategory_ID+"=? AND " +
MTax.COLUMNNAME_C_Tax_ID+"<>? AND "+
"IsDefault='Y'";
List<MTax> list = new Query(getCtx(), MTax.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getC_TaxCategory_ID(), getC_Tax_ID()})
List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName())
.setParameters(getC_TaxCategory_ID(), getC_Tax_ID())
.setOnlyActiveRecords(true)
.list();
if (list.size() >= 1) {

View File

@ -72,8 +72,8 @@ 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'";
List<MTax> list = new Query(getCtx(), MTax.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getC_TaxCategory_ID()})
List<MTax> list = new Query(getCtx(), I_C_Tax.Table_Name, whereClause, get_TrxName())
.setParameters(getC_TaxCategory_ID())
.setOnlyActiveRecords(true)
.list();
if (list.size() == 0) {

View File

@ -604,7 +604,7 @@ public class MUOMConversion extends X_C_UOM_Conversion
+ " AND EXISTS (SELECT 1 FROM M_Product p "
+ "WHERE C_UOM_Conversion.M_Product_ID=p.M_Product_ID AND C_UOM_Conversion.C_UOM_ID=p.C_UOM_ID)";
List<MUOMConversion> conversions = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{M_Product_ID})
.setParameters(M_Product_ID)
.setOnlyActiveRecords(true)
.list();
list.addAll(conversions);

View File

@ -74,8 +74,8 @@ public class MUser extends X_AD_User
*/
public static MUser[] getOfBPartner (Properties ctx, int C_BPartner_ID, String trxName)
{
List<MUser> list = new Query(ctx, MUser.Table_Name, "C_BPartner_ID=?", trxName)
.setParameters(new Object[]{C_BPartner_ID})
List<MUser> list = new Query(ctx, I_AD_User.Table_Name, "C_BPartner_ID=?", trxName)
.setParameters(C_BPartner_ID)
.setOnlyActiveRecords(true)
.list();

View File

@ -78,7 +78,7 @@ public class MWarehouse extends X_M_Warehouse
{
String whereClause = "IsActive=? AND AD_Org_ID=?";
List<MWarehouse> list = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{"Y", AD_Org_ID})
.setParameters("Y", AD_Org_ID)
.setOrderBy(COLUMNNAME_M_Warehouse_ID)
.list();
return list.toArray(new MWarehouse[list.size()]);
@ -95,7 +95,7 @@ public class MWarehouse extends X_M_Warehouse
{
String whereClause = "IsActive=? AND IsInTransit=? AND AD_Org_ID=?";
List<MWarehouse> list = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{"Y", "Y", AD_Org_ID})
.setParameters("Y", "Y", AD_Org_ID)
.setOrderBy(COLUMNNAME_M_Warehouse_ID)
.list();
return list.toArray(new MWarehouse[list.size()]);
@ -160,8 +160,8 @@ public class MWarehouse extends X_M_Warehouse
return m_locators;
//
final String whereClause = "IsActive=? AND M_Warehouse_ID=?";
List<MLocator> list = new Query(getCtx(), MLocator.Table_Name, whereClause, null)
.setParameters(new Object[]{"Y", getM_Warehouse_ID()})
List<MLocator> list = new Query(getCtx(), I_M_Locator.Table_Name, whereClause, null)
.setParameters("Y", getM_Warehouse_ID())
.setOrderBy("X,Y,Z")
.list();
m_locators = list.toArray(new MLocator[list.size()]);