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-01 07:18:20 +00:00
parent ce29e05125
commit 5fba554eab
15 changed files with 39 additions and 39 deletions

View File

@ -77,9 +77,9 @@ public class MDocType extends X_C_DocType
*/ */
static public MDocType[] getOfClient (Properties ctx) static public MDocType[] getOfClient (Properties ctx)
{ {
String whereClause = "AD_Client_ID=?"; final String whereClause = "AD_Client_ID=?";
List<MDocType> list = new Query(ctx, Table_Name, whereClause, null) List<MDocType> list = new Query(ctx, Table_Name, whereClause, null)
.setParameters(new Object[]{Env.getAD_Client_ID(ctx)}) .setParameters(Env.getAD_Client_ID(ctx))
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
return list.toArray(new MDocType[list.size()]); return list.toArray(new MDocType[list.size()]);

View File

@ -85,11 +85,11 @@ public class MDunningRun extends X_C_DunningRun
// just one level // just one level
levels = new Query( levels = new Query(
getCtx(), getCtx(),
MDunningLevel.Table_Name, I_C_DunningLevel.Table_Name,
"C_Dunning_ID=? AND C_DunningLevel_ID=?", "C_Dunning_ID=? AND C_DunningLevel_ID=?",
get_TrxName()) get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getC_Dunning_ID(), getC_DunningLevel_ID()}) .setParameters(getC_Dunning_ID(), getC_DunningLevel_ID())
.setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID") .setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID")
.list(); .list();
} else { } else {

View File

@ -87,7 +87,7 @@ public class MEXPFormat extends X_EXP_Format {
final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID + "=?"; final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID + "=?";
m_lines = new Query(getCtx() , I_EXP_FormatLine.Table_Name, clauseWhere , get_TrxName()) m_lines = new Query(getCtx() , I_EXP_FormatLine.Table_Name, clauseWhere , get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getEXP_Format_ID()}) .setParameters(getEXP_Format_ID())
.setOrderBy(orderBy) .setOrderBy(orderBy)
.list(); .list();
return m_lines; return m_lines;
@ -102,7 +102,7 @@ public class MEXPFormat extends X_EXP_Format {
+ " AND " + X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex +"= ?"; + " AND " + X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex +"= ?";
m_lines_unique = new Query(getCtx(), I_EXP_FormatLine.Table_Name, clauseWhere, get_TrxName()) m_lines_unique = new Query(getCtx(), I_EXP_FormatLine.Table_Name, clauseWhere, get_TrxName())
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.setParameters(new Object[]{getEXP_Format_ID(), "Y"}) .setParameters(getEXP_Format_ID(), "Y")
.setOrderBy(X_EXP_FormatLine.COLUMNNAME_Position) .setOrderBy(X_EXP_FormatLine.COLUMNNAME_Position)
.list(); .list();
return m_lines_unique; return m_lines_unique;
@ -135,7 +135,7 @@ public class MEXPFormat extends X_EXP_Format {
.append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?");
retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereCluse.toString(),trxName) retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereCluse.toString(),trxName)
.setParameters(new Object[] {value,AD_Client_ID,version}).first(); .setParameters(value,AD_Client_ID,version).first();
if(retValue != null) if(retValue != null)
{ {
@ -161,7 +161,7 @@ public class MEXPFormat extends X_EXP_Format {
.append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?");
retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereClause.toString(),trxName) retValue = (MEXPFormat) new Query(ctx,X_EXP_Format.Table_Name,whereClause.toString(),trxName)
.setParameters(new Object[] {AD_Client_ID,AD_Table_ID,version}) .setParameters(AD_Client_ID,AD_Table_ID,version)
.first(); .first();
if(retValue!=null) if(retValue!=null)
{ {

View File

@ -213,8 +213,8 @@ public class MElementValue extends X_C_ElementValue
{ {
// //
// Check if we have accounting facts // Check if we have accounting facts
boolean match = new Query(getCtx(), MFactAcct.Table_Name, MFactAcct.COLUMNNAME_Account_ID+"=?", get_TrxName()) boolean match = new Query(getCtx(), I_Fact_Acct.Table_Name, I_Fact_Acct.COLUMNNAME_Account_ID+"=?", get_TrxName())
.setParameters(new Object[]{getC_ElementValue_ID()}) .setParameters(getC_ElementValue_ID())
.match(); .match();
if (match) if (match)
{ {

View File

@ -80,8 +80,8 @@ public class MFreightCategory extends X_M_FreightCategory {
*/ */
public static MFreightCategory getByValue(Properties ctx, String value, String trxName) { public static MFreightCategory getByValue(Properties ctx, String value, String trxName) {
Query q = new Query(ctx, MFreightCategory.Table_Name, "Value=? AND AD_Client_ID=?", trxName); Query q = new Query(ctx, I_M_FreightCategory.Table_Name, "Value=? AND AD_Client_ID=?", trxName);
q.setParameters(new Object[]{value, Env.getAD_Client_ID(ctx)}); q.setParameters(value, Env.getAD_Client_ID(ctx));
return q.first(); return q.first();
} }

View File

@ -623,8 +623,8 @@ public class MInOut extends X_M_InOut implements DocAction
set_TrxName(m_lines, get_TrxName()); set_TrxName(m_lines, get_TrxName());
return m_lines; return m_lines;
} }
List<MInOutLine> list = new Query(getCtx(), MInOutLine.Table_Name, "M_InOut_ID=?", get_TrxName()) List<MInOutLine> list = new Query(getCtx(), I_M_InOutLine.Table_Name, "M_InOut_ID=?", get_TrxName())
.setParameters(new Object[]{getM_InOut_ID()}) .setParameters(getM_InOut_ID())
.setOrderBy(MInOutLine.COLUMNNAME_Line) .setOrderBy(MInOutLine.COLUMNNAME_Line)
.list(); .list();
// //
@ -655,8 +655,8 @@ public class MInOut extends X_M_InOut implements DocAction
set_TrxName(m_confirms, get_TrxName()); set_TrxName(m_confirms, get_TrxName());
return m_confirms; return m_confirms;
} }
List<MInOutConfirm> list = new Query(getCtx(), MInOutConfirm.Table_Name, "M_InOut_ID=?", get_TrxName()) List<MInOutConfirm> list = new Query(getCtx(), I_M_InOutConfirm.Table_Name, "M_InOut_ID=?", get_TrxName())
.setParameters(new Object[]{getM_InOut_ID()}) .setParameters(getM_InOut_ID())
.list(); .list();
m_confirms = new MInOutConfirm[list.size ()]; m_confirms = new MInOutConfirm[list.size ()];
list.toArray (m_confirms); list.toArray (m_confirms);

View File

@ -151,9 +151,9 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
set_TrxName(m_lines, get_TrxName()); set_TrxName(m_lines, get_TrxName());
return m_lines; return m_lines;
} }
final String whereClause = MInOutLineConfirm.COLUMNNAME_M_InOutConfirm_ID+"=?"; final String whereClause = I_M_InOutLineConfirm.COLUMNNAME_M_InOutConfirm_ID+"=?";
List<MInOutLineConfirm> list = new Query(getCtx(), MInOutLineConfirm.Table_Name, whereClause, get_TrxName()) List<MInOutLineConfirm> list = new Query(getCtx(), I_M_InOutLineConfirm.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getM_InOutConfirm_ID()}) .setParameters(getM_InOutConfirm_ID())
.list(); .list();
m_lines = new MInOutLineConfirm[list.size ()]; m_lines = new MInOutLineConfirm[list.size ()];
list.toArray (m_lines); list.toArray (m_lines);

View File

@ -60,7 +60,7 @@ public class MInOutLine extends X_M_InOutLine
{ {
String whereClause = "C_OrderLine_ID=?" + (!Util.isEmpty(where, true) ? " AND "+where : ""); String whereClause = "C_OrderLine_ID=?" + (!Util.isEmpty(where, true) ? " AND "+where : "");
List<MInOutLine> list = new Query(ctx, Table_Name, whereClause, trxName) List<MInOutLine> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(new Object[]{C_OrderLine_ID}) .setParameters(C_OrderLine_ID)
.list(); .list();
return list.toArray (new MInOutLine[list.size()]); return list.toArray (new MInOutLine[list.size()]);
} // getOfOrderLine } // getOfOrderLine
@ -78,7 +78,7 @@ public class MInOutLine extends X_M_InOutLine
{ {
String whereClause = "M_RMALine_ID=? " + (!Util.isEmpty(where, true) ? " AND "+where : ""); String whereClause = "M_RMALine_ID=? " + (!Util.isEmpty(where, true) ? " AND "+where : "");
List<MRMALine> list = new Query(ctx, Table_Name, whereClause, trxName) List<MRMALine> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(new Object[]{M_RMALine_ID}) .setParameters(M_RMALine_ID)
.list(); .list();
return list.toArray (new MInOutLine[list.size()]); return list.toArray (new MInOutLine[list.size()]);
} // getOfRMALine } // getOfRMALine

View File

@ -46,8 +46,8 @@ public class MInOutLineMA extends X_M_InOutLineMA
public static MInOutLineMA[] get (Properties ctx, int M_InOutLine_ID, String trxName) public static MInOutLineMA[] get (Properties ctx, int M_InOutLine_ID, String trxName)
{ {
Query query = MTable.get(ctx, MInOutLineMA.Table_Name) Query query = MTable.get(ctx, MInOutLineMA.Table_Name)
.createQuery(MInOutLineMA.COLUMNNAME_M_InOutLine_ID+"=?", trxName); .createQuery(I_M_InOutLineMA.COLUMNNAME_M_InOutLine_ID+"=?", trxName);
query.setParameters(new Object[]{M_InOutLine_ID}); query.setParameters(M_InOutLine_ID);
List<MInOutLineMA> list = query.list(); List<MInOutLineMA> list = query.list();
MInOutLineMA[] retValue = new MInOutLineMA[list.size ()]; MInOutLineMA[] retValue = new MInOutLineMA[list.size ()];
list.toArray (retValue); list.toArray (retValue);

View File

@ -146,7 +146,7 @@ public class MInventory extends X_M_Inventory implements DocAction
} }
// //
List<MInventoryLine> list = new Query(getCtx(), MInventoryLine.Table_Name, "M_Inventory_ID=?", get_TrxName()) List<MInventoryLine> list = new Query(getCtx(), MInventoryLine.Table_Name, "M_Inventory_ID=?", get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.setOrderBy(MInventoryLine.COLUMNNAME_Line) .setOrderBy(MInventoryLine.COLUMNNAME_Line)
.list(); .list();
m_lines = list.toArray(new MInventoryLine[list.size()]); m_lines = list.toArray(new MInventoryLine[list.size()]);

View File

@ -55,8 +55,8 @@ public class MInventoryLine extends X_M_InventoryLine
{ {
final String whereClause = "M_Inventory_ID=? AND M_Locator_ID=?" final String whereClause = "M_Inventory_ID=? AND M_Locator_ID=?"
+" AND M_Product_ID=? AND M_AttributeSetInstance_ID=?"; +" AND M_Product_ID=? AND M_AttributeSetInstance_ID=?";
return new Query(inventory.getCtx(), MInventoryLine.Table_Name, whereClause, inventory.get_TrxName()) return new Query(inventory.getCtx(), I_M_InventoryLine.Table_Name, whereClause, inventory.get_TrxName())
.setParameters(new Object[]{inventory.get_ID(), M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID}) .setParameters(inventory.get_ID(), M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID)
.firstOnly(); .firstOnly();
} // get } // get

View File

@ -74,7 +74,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
public static MInvoice[] getOfBPartner (Properties ctx, int C_BPartner_ID, String trxName) public static MInvoice[] getOfBPartner (Properties ctx, int C_BPartner_ID, String trxName)
{ {
List<MInvoice> list = new Query(ctx, Table_Name, COLUMNNAME_C_BPartner_ID+"=?", trxName) List<MInvoice> list = new Query(ctx, Table_Name, COLUMNNAME_C_BPartner_ID+"=?", trxName)
.setParameters(new Object[]{C_BPartner_ID}) .setParameters(C_BPartner_ID)
.list(); .list();
return list.toArray(new MInvoice[list.size()]); return list.toArray(new MInvoice[list.size()]);
} // getOfBPartner } // getOfBPartner
@ -630,9 +630,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
String whereClauseFinal = "C_Invoice_ID=? "; String whereClauseFinal = "C_Invoice_ID=? ";
if (whereClause != null) if (whereClause != null)
whereClauseFinal += whereClause; whereClauseFinal += whereClause;
List<MInvoiceLine> list = new Query(getCtx(), MInvoiceLine.Table_Name, whereClauseFinal, get_TrxName()) List<MInvoiceLine> list = new Query(getCtx(), I_C_InvoiceLine.Table_Name, whereClauseFinal, get_TrxName())
.setParameters(new Object[]{getC_Invoice_ID()}) .setParameters(getC_Invoice_ID())
.setOrderBy(MInvoiceLine.COLUMNNAME_Line) .setOrderBy(I_C_InvoiceLine.COLUMNNAME_Line)
.list(); .list();
return list.toArray(new MInvoiceLine[list.size()]); return list.toArray(new MInvoiceLine[list.size()]);
} // getLines } // getLines
@ -784,8 +784,8 @@ public class MInvoice extends X_C_Invoice implements DocAction
return m_taxes; return m_taxes;
final String whereClause = MInvoiceTax.COLUMNNAME_C_Invoice_ID+"=?"; final String whereClause = MInvoiceTax.COLUMNNAME_C_Invoice_ID+"=?";
List<MInvoiceTax> list = new Query(getCtx(), MInvoiceTax.Table_Name, whereClause, get_TrxName()) List<MInvoiceTax> list = new Query(getCtx(), I_C_InvoiceTax.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID()}) .setParameters(get_ID())
.list(); .list();
m_taxes = list.toArray(new MInvoiceTax[list.size()]); m_taxes = list.toArray(new MInvoiceTax[list.size()]);
return m_taxes; return m_taxes;

View File

@ -74,7 +74,7 @@ public class MInvoiceTax extends X_C_InvoiceTax
} }
retValue = new Query(line.getCtx(), Table_Name, "C_Invoice_ID=? AND C_Tax_ID=?", trxName) retValue = new Query(line.getCtx(), Table_Name, "C_Invoice_ID=? AND C_Tax_ID=?", trxName)
.setParameters(new Object[]{line.getC_Invoice_ID(), C_Tax_ID}) .setParameters(line.getC_Invoice_ID(), C_Tax_ID)
.firstOnly(); .firstOnly();
if (retValue != null) if (retValue != null)
{ {

View File

@ -215,9 +215,9 @@ public class MJournal extends X_GL_Journal implements DocAction
public MJournalLine[] getLines (boolean requery) public MJournalLine[] getLines (boolean requery)
{ {
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
String whereClause = "GL_Journal_ID=?"; final String whereClause = "GL_Journal_ID=?";
List <MJournalLine> list = new Query(getCtx(), MJournalLine.Table_Name, whereClause.toString(), null) List <MJournalLine> list = new Query(getCtx(), I_GL_JournalLine.Table_Name, whereClause.toString(), null)
.setParameters(new Object[]{getGL_Journal_ID()}) .setParameters(getGL_Journal_ID())
.setOrderBy("Line") .setOrderBy("Line")
.list(); .list();
// //

View File

@ -70,7 +70,7 @@ public class MLanguage extends X_AD_Language
public static MLanguage get (Properties ctx, String AD_Language) public static MLanguage get (Properties ctx, String AD_Language)
{ {
return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null) return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null)
.setParameters(new Object[]{AD_Language}) .setParameters(AD_Language)
.firstOnly(); .firstOnly();
} // get } // get
@ -83,7 +83,7 @@ public class MLanguage extends X_AD_Language
public static MLanguage[] getWithLanguage (Properties ctx, String LanguageISO) public static MLanguage[] getWithLanguage (Properties ctx, String LanguageISO)
{ {
List<MLanguage> list = new Query(ctx, Table_Name, COLUMNNAME_LanguageISO+"=?", null) List<MLanguage> list = new Query(ctx, Table_Name, COLUMNNAME_LanguageISO+"=?", null)
.setParameters(new Object[]{LanguageISO}) .setParameters(LanguageISO)
.list(); .list();
return list.toArray(new MLanguage[list.size()]); return list.toArray(new MLanguage[list.size()]);
} // get } // get
@ -95,7 +95,7 @@ public class MLanguage extends X_AD_Language
public static void maintain (Properties ctx) public static void maintain (Properties ctx)
{ {
List<MLanguage> list = new Query(ctx, Table_Name, "IsSystemLanguage=? AND IsBaseLanguage=?", null) List<MLanguage> list = new Query(ctx, Table_Name, "IsSystemLanguage=? AND IsBaseLanguage=?", null)
.setParameters(new Object[]{true, false}) .setParameters(true, false)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();
for (MLanguage language : list) { for (MLanguage language : list) {