From 5fba554eab5bf7b7b2817408fe4d1e62ef14b537 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Mon, 1 Mar 2010 07:18:20 +0000 Subject: [PATCH] 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 --- base/src/org/compiere/model/MDocType.java | 4 ++-- base/src/org/compiere/model/MDunningRun.java | 4 ++-- base/src/org/compiere/model/MEXPFormat.java | 8 ++++---- base/src/org/compiere/model/MElementValue.java | 4 ++-- base/src/org/compiere/model/MFreightCategory.java | 4 ++-- base/src/org/compiere/model/MInOut.java | 8 ++++---- base/src/org/compiere/model/MInOutConfirm.java | 6 +++--- base/src/org/compiere/model/MInOutLine.java | 4 ++-- base/src/org/compiere/model/MInOutLineMA.java | 4 ++-- base/src/org/compiere/model/MInventory.java | 2 +- base/src/org/compiere/model/MInventoryLine.java | 4 ++-- base/src/org/compiere/model/MInvoice.java | 12 ++++++------ base/src/org/compiere/model/MInvoiceTax.java | 2 +- base/src/org/compiere/model/MJournal.java | 6 +++--- base/src/org/compiere/model/MLanguage.java | 6 +++--- 15 files changed, 39 insertions(+), 39 deletions(-) diff --git a/base/src/org/compiere/model/MDocType.java b/base/src/org/compiere/model/MDocType.java index c434f889b6..4dccd1de18 100644 --- a/base/src/org/compiere/model/MDocType.java +++ b/base/src/org/compiere/model/MDocType.java @@ -77,9 +77,9 @@ public class MDocType extends X_C_DocType */ static public MDocType[] getOfClient (Properties ctx) { - String whereClause = "AD_Client_ID=?"; + final String whereClause = "AD_Client_ID=?"; List list = new Query(ctx, Table_Name, whereClause, null) - .setParameters(new Object[]{Env.getAD_Client_ID(ctx)}) + .setParameters(Env.getAD_Client_ID(ctx)) .setOnlyActiveRecords(true) .list(); return list.toArray(new MDocType[list.size()]); diff --git a/base/src/org/compiere/model/MDunningRun.java b/base/src/org/compiere/model/MDunningRun.java index 9b1b4c1dca..1d3d2ec3ac 100644 --- a/base/src/org/compiere/model/MDunningRun.java +++ b/base/src/org/compiere/model/MDunningRun.java @@ -85,11 +85,11 @@ public class MDunningRun extends X_C_DunningRun // just one level levels = new Query( getCtx(), - MDunningLevel.Table_Name, + I_C_DunningLevel.Table_Name, "C_Dunning_ID=? AND C_DunningLevel_ID=?", get_TrxName()) .setOnlyActiveRecords(true) - .setParameters(new Object[]{getC_Dunning_ID(), getC_DunningLevel_ID()}) + .setParameters(getC_Dunning_ID(), getC_DunningLevel_ID()) .setOrderBy("DaysAfterDue DESC, C_DunningLevel_ID") .list(); } else { diff --git a/base/src/org/compiere/model/MEXPFormat.java b/base/src/org/compiere/model/MEXPFormat.java index 961b108497..eec9a8bdf3 100644 --- a/base/src/org/compiere/model/MEXPFormat.java +++ b/base/src/org/compiere/model/MEXPFormat.java @@ -87,7 +87,7 @@ public class MEXPFormat extends X_EXP_Format { final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID + "=?"; m_lines = new Query(getCtx() , I_EXP_FormatLine.Table_Name, clauseWhere , get_TrxName()) .setOnlyActiveRecords(true) - .setParameters(new Object[]{getEXP_Format_ID()}) + .setParameters(getEXP_Format_ID()) .setOrderBy(orderBy) .list(); return m_lines; @@ -102,7 +102,7 @@ public class MEXPFormat extends X_EXP_Format { + " AND " + X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex +"= ?"; m_lines_unique = new Query(getCtx(), I_EXP_FormatLine.Table_Name, clauseWhere, get_TrxName()) .setOnlyActiveRecords(true) - .setParameters(new Object[]{getEXP_Format_ID(), "Y"}) + .setParameters(getEXP_Format_ID(), "Y") .setOrderBy(X_EXP_FormatLine.COLUMNNAME_Position) .list(); return m_lines_unique; @@ -135,7 +135,7 @@ public class MEXPFormat extends X_EXP_Format { .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); 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) { @@ -161,7 +161,7 @@ public class MEXPFormat extends X_EXP_Format { .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); 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(); if(retValue!=null) { diff --git a/base/src/org/compiere/model/MElementValue.java b/base/src/org/compiere/model/MElementValue.java index dc22b34655..14f997a68d 100644 --- a/base/src/org/compiere/model/MElementValue.java +++ b/base/src/org/compiere/model/MElementValue.java @@ -213,8 +213,8 @@ public class MElementValue extends X_C_ElementValue { // // Check if we have accounting facts - boolean match = new Query(getCtx(), MFactAcct.Table_Name, MFactAcct.COLUMNNAME_Account_ID+"=?", get_TrxName()) - .setParameters(new Object[]{getC_ElementValue_ID()}) + boolean match = new Query(getCtx(), I_Fact_Acct.Table_Name, I_Fact_Acct.COLUMNNAME_Account_ID+"=?", get_TrxName()) + .setParameters(getC_ElementValue_ID()) .match(); if (match) { diff --git a/base/src/org/compiere/model/MFreightCategory.java b/base/src/org/compiere/model/MFreightCategory.java index f9f5d59356..3a8fe57947 100644 --- a/base/src/org/compiere/model/MFreightCategory.java +++ b/base/src/org/compiere/model/MFreightCategory.java @@ -80,8 +80,8 @@ public class MFreightCategory extends X_M_FreightCategory { */ public static MFreightCategory getByValue(Properties ctx, String value, String trxName) { - Query q = new Query(ctx, MFreightCategory.Table_Name, "Value=? AND AD_Client_ID=?", trxName); - q.setParameters(new Object[]{value, Env.getAD_Client_ID(ctx)}); + Query q = new Query(ctx, I_M_FreightCategory.Table_Name, "Value=? AND AD_Client_ID=?", trxName); + q.setParameters(value, Env.getAD_Client_ID(ctx)); return q.first(); } diff --git a/base/src/org/compiere/model/MInOut.java b/base/src/org/compiere/model/MInOut.java index 63a298b694..b0c8730d33 100644 --- a/base/src/org/compiere/model/MInOut.java +++ b/base/src/org/compiere/model/MInOut.java @@ -623,8 +623,8 @@ public class MInOut extends X_M_InOut implements DocAction set_TrxName(m_lines, get_TrxName()); return m_lines; } - List list = new Query(getCtx(), MInOutLine.Table_Name, "M_InOut_ID=?", get_TrxName()) - .setParameters(new Object[]{getM_InOut_ID()}) + List list = new Query(getCtx(), I_M_InOutLine.Table_Name, "M_InOut_ID=?", get_TrxName()) + .setParameters(getM_InOut_ID()) .setOrderBy(MInOutLine.COLUMNNAME_Line) .list(); // @@ -655,8 +655,8 @@ public class MInOut extends X_M_InOut implements DocAction set_TrxName(m_confirms, get_TrxName()); return m_confirms; } - List list = new Query(getCtx(), MInOutConfirm.Table_Name, "M_InOut_ID=?", get_TrxName()) - .setParameters(new Object[]{getM_InOut_ID()}) + List list = new Query(getCtx(), I_M_InOutConfirm.Table_Name, "M_InOut_ID=?", get_TrxName()) + .setParameters(getM_InOut_ID()) .list(); m_confirms = new MInOutConfirm[list.size ()]; list.toArray (m_confirms); diff --git a/base/src/org/compiere/model/MInOutConfirm.java b/base/src/org/compiere/model/MInOutConfirm.java index 52aa998696..29c027ca58 100644 --- a/base/src/org/compiere/model/MInOutConfirm.java +++ b/base/src/org/compiere/model/MInOutConfirm.java @@ -151,9 +151,9 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction set_TrxName(m_lines, get_TrxName()); return m_lines; } - final String whereClause = MInOutLineConfirm.COLUMNNAME_M_InOutConfirm_ID+"=?"; - List list = new Query(getCtx(), MInOutLineConfirm.Table_Name, whereClause, get_TrxName()) - .setParameters(new Object[]{getM_InOutConfirm_ID()}) + final String whereClause = I_M_InOutLineConfirm.COLUMNNAME_M_InOutConfirm_ID+"=?"; + List list = new Query(getCtx(), I_M_InOutLineConfirm.Table_Name, whereClause, get_TrxName()) + .setParameters(getM_InOutConfirm_ID()) .list(); m_lines = new MInOutLineConfirm[list.size ()]; list.toArray (m_lines); diff --git a/base/src/org/compiere/model/MInOutLine.java b/base/src/org/compiere/model/MInOutLine.java index 73e481aa7e..2843290c54 100644 --- a/base/src/org/compiere/model/MInOutLine.java +++ b/base/src/org/compiere/model/MInOutLine.java @@ -60,7 +60,7 @@ public class MInOutLine extends X_M_InOutLine { String whereClause = "C_OrderLine_ID=?" + (!Util.isEmpty(where, true) ? " AND "+where : ""); List list = new Query(ctx, Table_Name, whereClause, trxName) - .setParameters(new Object[]{C_OrderLine_ID}) + .setParameters(C_OrderLine_ID) .list(); return list.toArray (new MInOutLine[list.size()]); } // getOfOrderLine @@ -78,7 +78,7 @@ public class MInOutLine extends X_M_InOutLine { String whereClause = "M_RMALine_ID=? " + (!Util.isEmpty(where, true) ? " AND "+where : ""); List list = new Query(ctx, Table_Name, whereClause, trxName) - .setParameters(new Object[]{M_RMALine_ID}) + .setParameters(M_RMALine_ID) .list(); return list.toArray (new MInOutLine[list.size()]); } // getOfRMALine diff --git a/base/src/org/compiere/model/MInOutLineMA.java b/base/src/org/compiere/model/MInOutLineMA.java index eb7bd4d43e..c1d422aa61 100644 --- a/base/src/org/compiere/model/MInOutLineMA.java +++ b/base/src/org/compiere/model/MInOutLineMA.java @@ -46,8 +46,8 @@ public class MInOutLineMA extends X_M_InOutLineMA public static MInOutLineMA[] get (Properties ctx, int M_InOutLine_ID, String trxName) { Query query = MTable.get(ctx, MInOutLineMA.Table_Name) - .createQuery(MInOutLineMA.COLUMNNAME_M_InOutLine_ID+"=?", trxName); - query.setParameters(new Object[]{M_InOutLine_ID}); + .createQuery(I_M_InOutLineMA.COLUMNNAME_M_InOutLine_ID+"=?", trxName); + query.setParameters(M_InOutLine_ID); List list = query.list(); MInOutLineMA[] retValue = new MInOutLineMA[list.size ()]; list.toArray (retValue); diff --git a/base/src/org/compiere/model/MInventory.java b/base/src/org/compiere/model/MInventory.java index dc5a45ffc8..abe3cd21c5 100644 --- a/base/src/org/compiere/model/MInventory.java +++ b/base/src/org/compiere/model/MInventory.java @@ -146,7 +146,7 @@ public class MInventory extends X_M_Inventory implements DocAction } // List list = new Query(getCtx(), MInventoryLine.Table_Name, "M_Inventory_ID=?", get_TrxName()) - .setParameters(new Object[]{get_ID()}) + .setParameters(get_ID()) .setOrderBy(MInventoryLine.COLUMNNAME_Line) .list(); m_lines = list.toArray(new MInventoryLine[list.size()]); diff --git a/base/src/org/compiere/model/MInventoryLine.java b/base/src/org/compiere/model/MInventoryLine.java index c3b356d20b..a074e86cdf 100644 --- a/base/src/org/compiere/model/MInventoryLine.java +++ b/base/src/org/compiere/model/MInventoryLine.java @@ -55,8 +55,8 @@ public class MInventoryLine extends X_M_InventoryLine { final String whereClause = "M_Inventory_ID=? AND M_Locator_ID=?" +" AND M_Product_ID=? AND M_AttributeSetInstance_ID=?"; - return new Query(inventory.getCtx(), MInventoryLine.Table_Name, whereClause, inventory.get_TrxName()) - .setParameters(new Object[]{inventory.get_ID(), M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID}) + return new Query(inventory.getCtx(), I_M_InventoryLine.Table_Name, whereClause, inventory.get_TrxName()) + .setParameters(inventory.get_ID(), M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID) .firstOnly(); } // get diff --git a/base/src/org/compiere/model/MInvoice.java b/base/src/org/compiere/model/MInvoice.java index 29b1393375..2814883cde 100644 --- a/base/src/org/compiere/model/MInvoice.java +++ b/base/src/org/compiere/model/MInvoice.java @@ -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) { List list = new Query(ctx, Table_Name, COLUMNNAME_C_BPartner_ID+"=?", trxName) - .setParameters(new Object[]{C_BPartner_ID}) + .setParameters(C_BPartner_ID) .list(); return list.toArray(new MInvoice[list.size()]); } // getOfBPartner @@ -630,9 +630,9 @@ public class MInvoice extends X_C_Invoice implements DocAction String whereClauseFinal = "C_Invoice_ID=? "; if (whereClause != null) whereClauseFinal += whereClause; - List list = new Query(getCtx(), MInvoiceLine.Table_Name, whereClauseFinal, get_TrxName()) - .setParameters(new Object[]{getC_Invoice_ID()}) - .setOrderBy(MInvoiceLine.COLUMNNAME_Line) + List list = new Query(getCtx(), I_C_InvoiceLine.Table_Name, whereClauseFinal, get_TrxName()) + .setParameters(getC_Invoice_ID()) + .setOrderBy(I_C_InvoiceLine.COLUMNNAME_Line) .list(); return list.toArray(new MInvoiceLine[list.size()]); } // getLines @@ -784,8 +784,8 @@ public class MInvoice extends X_C_Invoice implements DocAction return m_taxes; final String whereClause = MInvoiceTax.COLUMNNAME_C_Invoice_ID+"=?"; - List list = new Query(getCtx(), MInvoiceTax.Table_Name, whereClause, get_TrxName()) - .setParameters(new Object[]{get_ID()}) + List list = new Query(getCtx(), I_C_InvoiceTax.Table_Name, whereClause, get_TrxName()) + .setParameters(get_ID()) .list(); m_taxes = list.toArray(new MInvoiceTax[list.size()]); return m_taxes; diff --git a/base/src/org/compiere/model/MInvoiceTax.java b/base/src/org/compiere/model/MInvoiceTax.java index 30ba02884c..d1eee99490 100644 --- a/base/src/org/compiere/model/MInvoiceTax.java +++ b/base/src/org/compiere/model/MInvoiceTax.java @@ -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) - .setParameters(new Object[]{line.getC_Invoice_ID(), C_Tax_ID}) + .setParameters(line.getC_Invoice_ID(), C_Tax_ID) .firstOnly(); if (retValue != null) { diff --git a/base/src/org/compiere/model/MJournal.java b/base/src/org/compiere/model/MJournal.java index 270fbf736a..17556987f6 100644 --- a/base/src/org/compiere/model/MJournal.java +++ b/base/src/org/compiere/model/MJournal.java @@ -215,9 +215,9 @@ public class MJournal extends X_GL_Journal implements DocAction public MJournalLine[] getLines (boolean requery) { //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 - String whereClause = "GL_Journal_ID=?"; - List list = new Query(getCtx(), MJournalLine.Table_Name, whereClause.toString(), null) - .setParameters(new Object[]{getGL_Journal_ID()}) + final String whereClause = "GL_Journal_ID=?"; + List list = new Query(getCtx(), I_GL_JournalLine.Table_Name, whereClause.toString(), null) + .setParameters(getGL_Journal_ID()) .setOrderBy("Line") .list(); // diff --git a/base/src/org/compiere/model/MLanguage.java b/base/src/org/compiere/model/MLanguage.java index 5904b5a4d0..466743097b 100644 --- a/base/src/org/compiere/model/MLanguage.java +++ b/base/src/org/compiere/model/MLanguage.java @@ -70,7 +70,7 @@ public class MLanguage extends X_AD_Language public static MLanguage get (Properties ctx, String AD_Language) { return new Query(ctx, Table_Name, COLUMNNAME_AD_Language+"=?", null) - .setParameters(new Object[]{AD_Language}) + .setParameters(AD_Language) .firstOnly(); } // get @@ -83,7 +83,7 @@ public class MLanguage extends X_AD_Language public static MLanguage[] getWithLanguage (Properties ctx, String LanguageISO) { List list = new Query(ctx, Table_Name, COLUMNNAME_LanguageISO+"=?", null) - .setParameters(new Object[]{LanguageISO}) + .setParameters(LanguageISO) .list(); return list.toArray(new MLanguage[list.size()]); } // get @@ -95,7 +95,7 @@ public class MLanguage extends X_AD_Language public static void maintain (Properties ctx) { List list = new Query(ctx, Table_Name, "IsSystemLanguage=? AND IsBaseLanguage=?", null) - .setParameters(new Object[]{true, false}) + .setParameters(true, false) .setOnlyActiveRecords(true) .list(); for (MLanguage language : list) {