From 042083872b6ad3d1f2c115745c1dcfec505bbce5 Mon Sep 17 00:00:00 2001 From: "Redhuan D. Oon" Date: Sun, 28 Feb 2010 05:12:58 +0000 Subject: [PATCH] Review FR: [ 2214883 ] Remove SQL code and Replace for Query >> to incorporate Heng Sin's advice. No unit testing done but compiler tested OK. Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883 --- .../process/rpl/exp/ExportHelper.java | 18 +++++------------- .../process/rpl/imp/ImportHelper.java | 2 +- .../org/compiere/process/BPartnerValidate.java | 7 ++++--- .../org/compiere/process/DistributionRun.java | 5 +++-- .../process/ExportFormatGenerator.java | 4 ++-- 5 files changed, 15 insertions(+), 21 deletions(-) diff --git a/base/src/org/adempiere/process/rpl/exp/ExportHelper.java b/base/src/org/adempiere/process/rpl/exp/ExportHelper.java index 2b4ebfbbd6..63e84cd277 100644 --- a/base/src/org/adempiere/process/rpl/exp/ExportHelper.java +++ b/base/src/org/adempiere/process/rpl/exp/ExportHelper.java @@ -83,12 +83,6 @@ public class ExportHelper { /** XML Document */ private Document outDocument = null; - /** Date Time Format */ - private SimpleDateFormat m_dateTimeFormat = null; - - /** Date Format */ - private SimpleDateFormat m_dateFormat = null; - /** Custom Date Format */ private SimpleDateFormat m_customDateFormat = null; @@ -103,14 +97,14 @@ public class ExportHelper { m_AD_Client_ID = client.getAD_Client_ID(); m_rplStrategy = rplStrategy; - m_dateTimeFormat = DisplayType.getDateFormat(DisplayType.DateTime, Language.getLanguage(Env.getAD_Language(client.getCtx()))); - m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(client.getCtx()))); + DisplayType.getDateFormat(DisplayType.DateTime, Language.getLanguage(Env.getAD_Language(client.getCtx()))); + DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(client.getCtx()))); } public ExportHelper(Properties ctx , int AD_Client_ID) { m_AD_Client_ID = AD_Client_ID; - m_dateTimeFormat = DisplayType.getDateFormat(DisplayType.DateTime, Language.getLanguage(Env.getAD_Language(ctx))); - m_dateFormat = DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(ctx))); + DisplayType.getDateFormat(DisplayType.DateTime, Language.getLanguage(Env.getAD_Language(ctx))); + DisplayType.getDateFormat(DisplayType.Date, Language.getLanguage(Env.getAD_Language(ctx))); } /** @@ -224,8 +218,6 @@ public class ExportHelper { throw new Exception(Msg.getMsg (po.getCtx(), "ExportNoneColumnKeyNotSupported"));//TODO: Create Mesagge. } - // TODO - get proper Export Format! - String version = "3.2.0"; outDocument = createNewDocument(); @@ -443,7 +435,7 @@ public class ExportHelper { Collection instances = new Query(masterPO.getCtx(),tableEmbedded.getTableName(), whereClause.toString(),masterPO.get_TrxName()) .setClient_ID() - .setParameters(new Object[] { value }) + .setParameters(value) .list(); for (PO instance : instances) diff --git a/base/src/org/adempiere/process/rpl/imp/ImportHelper.java b/base/src/org/adempiere/process/rpl/imp/ImportHelper.java index 3a27aba87b..cf33b1adb7 100755 --- a/base/src/org/adempiere/process/rpl/imp/ImportHelper.java +++ b/base/src/org/adempiere/process/rpl/imp/ImportHelper.java @@ -526,7 +526,7 @@ public class ImportHelper { { final String whereClause = I_AD_Client.COLUMNNAME_Value + "= ? "; MClient result = new Query(ctx,I_AD_Client.Table_Name,whereClause,trxName) - .setParameters(new Object[]{value}) + .setParameters(value) .firstOnly(); s_log.info("Client_Value =[" + value + "]"); diff --git a/base/src/org/compiere/process/BPartnerValidate.java b/base/src/org/compiere/process/BPartnerValidate.java index 0d6c754ac6..5aac8008ab 100644 --- a/base/src/org/compiere/process/BPartnerValidate.java +++ b/base/src/org/compiere/process/BPartnerValidate.java @@ -21,6 +21,7 @@ import java.sql.SQLException; import java.util.Iterator; import java.util.logging.Level; +import org.compiere.model.I_C_BPartner; import org.compiere.model.MBPartner; import org.compiere.model.MInvoice; import org.compiere.model.MPayment; @@ -84,9 +85,9 @@ public class BPartnerValidate extends SvrProcess } else { - String whereClause = "C_BP_Group_ID=?"; - Iterator it = new Query(getCtx(), MBPartner.Table_Name, whereClause, get_TrxName()) - .setParameters(new Object[]{p_C_BP_Group_ID}) + final String whereClause = "C_BP_Group_ID=?"; + Iterator it = new Query(getCtx(), I_C_BPartner.Table_Name, whereClause, get_TrxName()) + .setParameters(p_C_BP_Group_ID) .setOnlyActiveRecords(true) .iterate(); while(it.hasNext()) diff --git a/base/src/org/compiere/process/DistributionRun.java b/base/src/org/compiere/process/DistributionRun.java index fd0cc0bc1d..75a728e1db 100644 --- a/base/src/org/compiere/process/DistributionRun.java +++ b/base/src/org/compiere/process/DistributionRun.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; +import org.compiere.model.I_T_DistributionRunDetail; import org.compiere.model.MBPartner; import org.compiere.model.MDistributionRun; import org.compiere.model.MDistributionRunDetail; @@ -723,9 +724,9 @@ public class DistributionRun extends SvrProcess +" WHERE rl.M_DistributionRun_ID="+p_M_DistributionRun_ID+" AND l.RatioTotal<>0 AND rl.IsActive='Y' AND ll.IsActive='Y'"; no = DB.executeUpdate(sql, get_TrxName()); - Query query = MTable.get(getCtx(), MDistributionRunDetail.Table_ID). + Query query = MTable.get(getCtx(), I_T_DistributionRunDetail.Table_ID). createQuery(MDistributionRunDetail.COLUMNNAME_M_DistributionRun_ID + "=?", get_TrxName()); - query.setParameters(new Object[]{p_M_DistributionRun_ID}); + query.setParameters(p_M_DistributionRun_ID); List records = query.list(); diff --git a/base/src/org/eevolution/process/ExportFormatGenerator.java b/base/src/org/eevolution/process/ExportFormatGenerator.java index f082ed621d..fb00d16f74 100644 --- a/base/src/org/eevolution/process/ExportFormatGenerator.java +++ b/base/src/org/eevolution/process/ExportFormatGenerator.java @@ -15,11 +15,11 @@ *****************************************************************************/ package org.eevolution.process; -import java.sql.SQLException; import java.util.Hashtable; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; +import org.compiere.model.I_EXP_Format; import org.compiere.model.MColumn; import org.compiere.model.MEXPFormat; import org.compiere.model.MEXPFormatLine; @@ -147,7 +147,7 @@ public class ExportFormatGenerator extends SvrProcess return format.getValue(); String where=" value = ? "; - Query sql = new Query(getCtx(),MEXPFormat.Table_Name,where,get_TrxName()).setParameters(new Object[]{formatValue}); + Query sql = new Query(getCtx(),I_EXP_Format.Table_Name,where,get_TrxName()).setParameters(formatValue); if(sql.match()) { format = (MEXPFormat) sql.first();