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:
parent
b690a934d3
commit
a3cf7e8d37
|
@ -221,7 +221,7 @@ public class MAttributeSet extends X_M_AttributeSet
|
|||
{
|
||||
final String whereClause = X_M_AttributeSetExclude.COLUMNNAME_M_AttributeSet_ID+"=?";
|
||||
List<X_M_AttributeSetExclude> list = new Query(getCtx(), X_M_AttributeSetExclude.Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{get_ID()})
|
||||
.setParameters(get_ID())
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
m_excludes = new X_M_AttributeSetExclude[list.size ()];
|
||||
|
@ -253,9 +253,9 @@ public class MAttributeSet extends X_M_AttributeSet
|
|||
return true;
|
||||
if (m_excludeLots == null)
|
||||
{
|
||||
String whereClause = X_M_LotCtlExclude.COLUMNNAME_M_LotCtl_ID+"=?";
|
||||
final String whereClause = X_M_LotCtlExclude.COLUMNNAME_M_LotCtl_ID+"=?";
|
||||
List<X_M_LotCtlExclude> list = new Query(getCtx(), X_M_LotCtlExclude.Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{getM_LotCtl_ID()})
|
||||
.setParameters(getM_LotCtl_ID())
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
m_excludeLots = new X_M_LotCtlExclude[list.size ()];
|
||||
|
@ -287,9 +287,9 @@ public class MAttributeSet extends X_M_AttributeSet
|
|||
return true;
|
||||
if (m_excludeSerNos == null)
|
||||
{
|
||||
String whereClause = X_M_SerNoCtlExclude.COLUMNNAME_M_SerNoCtl_ID+"=?";
|
||||
final String whereClause = X_M_SerNoCtlExclude.COLUMNNAME_M_SerNoCtl_ID+"=?";
|
||||
List<X_M_SerNoCtlExclude> list = new Query(getCtx(), X_M_SerNoCtlExclude.Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{getM_SerNoCtl_ID()})
|
||||
.setParameters(getM_SerNoCtl_ID())
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
m_excludeSerNos = new X_M_SerNoCtlExclude[list.size ()];
|
||||
|
|
|
@ -133,7 +133,7 @@ public class MBPartner extends X_C_BPartner
|
|||
*/
|
||||
public static MBPartner get (Properties ctx, int C_BPartner_ID)
|
||||
{
|
||||
String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?";
|
||||
final String whereClause = "C_BPartner_ID=? AND AD_Client_ID=?";
|
||||
MBPartner retValue = new Query(ctx,I_C_BPartner.Table_Name,whereClause.toString(),null)
|
||||
.setParameters(C_BPartner_ID,Env.getAD_Client_ID(ctx))
|
||||
.firstOnly();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location
|
|||
public static MBPartnerLocation[] getForBPartner (Properties ctx, int C_BPartner_ID, String trxName)
|
||||
{
|
||||
List<MBPartnerLocation> list = new Query(ctx, Table_Name, "C_BPartner_ID=?", trxName)
|
||||
.setParameters(new Object[]{C_BPartner_ID})
|
||||
.setParameters(C_BPartner_ID)
|
||||
.list();
|
||||
MBPartnerLocation[] retValue = new MBPartnerLocation[list.size ()];
|
||||
list.toArray (retValue);
|
||||
|
|
|
@ -69,14 +69,14 @@ public class MCash extends X_C_Cash implements DocAction
|
|||
Timestamp dateAcct, int C_Currency_ID, String trxName)
|
||||
{
|
||||
// Existing Journal
|
||||
String whereClause = "C_Cash.AD_Org_ID=?" // #1
|
||||
final String whereClause = "C_Cash.AD_Org_ID=?" // #1
|
||||
+ " AND TRUNC(C_Cash.StatementDate)=?" // #2
|
||||
+ " AND C_Cash.Processed='N'"
|
||||
+ " AND EXISTS (SELECT * FROM C_CashBook cb "
|
||||
+ "WHERE C_Cash.C_CashBook_ID=cb.C_CashBook_ID AND cb.AD_Org_ID=C_Cash.AD_Org_ID"
|
||||
+ " AND cb.C_Currency_ID=?)"; // #3
|
||||
MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{AD_Org_ID,TimeUtil.getDay(dateAcct),C_Currency_ID})
|
||||
MCash retValue = new Query(ctx, I_C_Cash.Table_Name, whereClause, trxName)
|
||||
.setParameters(AD_Org_ID,TimeUtil.getDay(dateAcct),C_Currency_ID)
|
||||
.first()
|
||||
;
|
||||
|
||||
|
@ -108,12 +108,12 @@ public class MCash extends X_C_Cash implements DocAction
|
|||
public static MCash get (Properties ctx, int C_CashBook_ID,
|
||||
Timestamp dateAcct, String trxName)
|
||||
{
|
||||
String whereClause ="C_CashBook_ID=?" // #1
|
||||
final String whereClause ="C_CashBook_ID=?" // #1
|
||||
+ " AND TRUNC(StatementDate)=?" // #2
|
||||
+ " AND Processed='N'";
|
||||
|
||||
MCash retValue = new Query(ctx, MCash.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{C_CashBook_ID, TimeUtil.getDay(dateAcct)})
|
||||
.setParameters(C_CashBook_ID, TimeUtil.getDay(dateAcct))
|
||||
.first()
|
||||
;
|
||||
|
||||
|
@ -217,10 +217,10 @@ public class MCash extends X_C_Cash implements DocAction
|
|||
return m_lines;
|
||||
}
|
||||
|
||||
String whereClause =MCashLine.COLUMNNAME_C_Cash_ID+"=?";
|
||||
List<MCashLine> list = new Query(getCtx(),MCashLine.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{getC_Cash_ID()})
|
||||
.setOrderBy(MCashLine.COLUMNNAME_Line)
|
||||
final String whereClause =MCashLine.COLUMNNAME_C_Cash_ID+"=?";
|
||||
List<MCashLine> list = new Query(getCtx(),I_C_CashLine.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(getC_Cash_ID())
|
||||
.setOrderBy(I_C_CashLine.COLUMNNAME_Line)
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
|
||||
|
|
|
@ -80,9 +80,9 @@ public class MCommission extends X_C_Commission
|
|||
{
|
||||
//[ 1867477 ]
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
String whereClause = "IsActive='Y' AND C_Commission_ID=?";
|
||||
List<MCommissionLine> list = new Query(getCtx(), MCommissionLine.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{getC_Commission_ID()})
|
||||
final String whereClause = "IsActive='Y' AND C_Commission_ID=?";
|
||||
List<MCommissionLine> list = new Query(getCtx(), I_C_CommissionLine.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(getC_Commission_ID())
|
||||
.setOrderBy("Line")
|
||||
.list();
|
||||
// Convert
|
||||
|
|
|
@ -46,9 +46,9 @@ public class MContainer extends X_CM_Container
|
|||
public static MContainer get(Properties ctx, String relURL, int CM_WebProject_Id, String trxName) {
|
||||
MContainer thisContainer = null;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, MContainer.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{relURL, relURL+"/",CM_WebProject_Id})
|
||||
final String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(relURL, relURL+"/",CM_WebProject_Id)
|
||||
.first();
|
||||
|
||||
return thisContainer;
|
||||
|
@ -66,9 +66,9 @@ public class MContainer extends X_CM_Container
|
|||
public static MContainer get(Properties ctx, int CM_Container_ID, int CM_WebProject_Id, String trxName) {
|
||||
MContainer thisContainer = null;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, MContainer.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{CM_Container_ID, CM_WebProject_Id})
|
||||
final String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?";
|
||||
thisContainer = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(CM_Container_ID, CM_WebProject_Id)
|
||||
.first();
|
||||
//
|
||||
return thisContainer;
|
||||
|
@ -112,9 +112,9 @@ public class MContainer extends X_CM_Container
|
|||
{
|
||||
MContainer cc = null;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
String whereClause = "CM_Container_ID=?";
|
||||
cc = new Query(ctx, MContainer.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{CM_Container_ID})
|
||||
final String whereClause = "CM_Container_ID=?";
|
||||
cc = new Query(ctx, I_CM_Container.Table_Name, whereClause, trxName)
|
||||
.setParameters(CM_Container_ID)
|
||||
.first();
|
||||
//
|
||||
return cc;
|
||||
|
@ -130,9 +130,9 @@ public class MContainer extends X_CM_Container
|
|||
public static MContainer[] getContainers (MWebProject project)
|
||||
{
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||
String whereClause = "CM_WebProject_ID=?";
|
||||
List<MContainer> list = new Query(project.getCtx(), MContainer.Table_Name, whereClause, project.get_TrxName())
|
||||
.setParameters(new Object[]{project.getCM_WebProject_ID ()})
|
||||
final String whereClause = "CM_WebProject_ID=?";
|
||||
List<MContainer> list = new Query(project.getCtx(), I_CM_Container.Table_Name, whereClause, project.get_TrxName())
|
||||
.setParameters(project.getCM_WebProject_ID ())
|
||||
.setOrderBy("CM_Container_ID")
|
||||
.list();
|
||||
//
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.sql.Timestamp;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -156,12 +157,10 @@ public class MConversionRate extends X_C_Conversion_Rate
|
|||
spotCal.set(Calendar.SECOND, 0);
|
||||
spotCal.set(Calendar.MILLISECOND, 0);
|
||||
startTs = new java.sql.Timestamp(spotCal.getTimeInMillis());
|
||||
|
||||
final String whereClause = "C_Currency_ID=? and C_Currency_ID_To=? and ValidFrom>=? and ValidTo<=? and C_ConversionType_ID=?";
|
||||
MConversionRate rate, updateRate = null;
|
||||
java.util.List<MConversionRate> rates = new Query(ctx, MConversionRate.Table_Name,
|
||||
"C_Currency_ID=? and C_Currency_ID_To=? and ValidFrom>=? and ValidTo<=? and C_ConversionType_ID=?",
|
||||
trxName)
|
||||
.setParameters(new Object[]{curFrom.get_ID(), curTo.get_ID(), startTs, startTs, MConversionType.TYPE_SPOT})
|
||||
List<MConversionRate> rates = new Query(ctx, I_C_Conversion_Rate.Table_Name, whereClause,trxName)
|
||||
.setParameters(curFrom.get_ID(), curTo.get_ID(), startTs, startTs, MConversionType.TYPE_SPOT)
|
||||
.list();
|
||||
|
||||
if (rates.size()>0) {
|
||||
|
|
|
@ -1289,20 +1289,19 @@ public class MCost extends X_M_Cost
|
|||
{
|
||||
MCost cost = null;
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
String whereClause = "AD_Client_ID=? AND AD_Org_ID=?"
|
||||
final String whereClause = "AD_Client_ID=? AND AD_Org_ID=?"
|
||||
+ " AND M_Product_ID=?"
|
||||
+ " AND M_AttributeSetInstance_ID=?"
|
||||
+ " AND M_CostType_ID=? AND C_AcctSchema_ID=?"
|
||||
+ " AND M_CostElement_ID=?";
|
||||
cost = new Query(product.getCtx(), MCost.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{
|
||||
product.getAD_Client_ID(),
|
||||
cost = new Query(product.getCtx(), I_M_Cost.Table_Name, whereClause, trxName)
|
||||
.setParameters( product.getAD_Client_ID(),
|
||||
AD_Org_ID,
|
||||
product.getM_Product_ID(),
|
||||
M_AttributeSetInstance_ID,
|
||||
as.getM_CostType_ID(),
|
||||
as.getC_AcctSchema_ID(),
|
||||
M_CostElement_ID})
|
||||
M_CostElement_ID)
|
||||
.firstOnly();
|
||||
//FR: [ 2214883 ] - end -
|
||||
// New
|
||||
|
|
|
@ -105,8 +105,8 @@ public class MCurrency extends X_C_Currency
|
|||
return retValue;
|
||||
|
||||
// Try database
|
||||
Query query = new Query(ctx, MCurrency.Table_Name, "iso_code=?", null);
|
||||
query.setParameters(new Object[]{ISOcode});
|
||||
Query query = new Query(ctx, I_C_Currency.Table_Name, "iso_code=?", null);
|
||||
query.setParameters(ISOcode);
|
||||
retValue = (MCurrency)query.firstOnly();
|
||||
|
||||
// Save
|
||||
|
|
|
@ -61,9 +61,9 @@ public class MDocType extends X_C_DocType
|
|||
*/
|
||||
static public MDocType[] getOfDocBaseType (Properties ctx, String DocBaseType)
|
||||
{
|
||||
String whereClause = "AD_Client_ID=? AND DocBaseType=?";
|
||||
final String whereClause = "AD_Client_ID=? AND DocBaseType=?";
|
||||
List<MDocType> list = new Query(ctx, Table_Name, whereClause, null)
|
||||
.setParameters(new Object[]{Env.getAD_Client_ID(ctx), DocBaseType})
|
||||
.setParameters(Env.getAD_Client_ID(ctx), DocBaseType)
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy("IsDefault DESC, C_DocType_ID")
|
||||
.list();
|
||||
|
|
|
@ -435,8 +435,8 @@ public class MDDOrder extends X_DD_Order implements DocAction
|
|||
if (!Util.isEmpty(whereClause, true))
|
||||
whereClauseFinal.append("AND (").append(whereClause).append(")");
|
||||
//
|
||||
List<MDDOrderLine> list = new Query(getCtx(), MDDOrderLine.Table_Name, whereClauseFinal.toString(), get_TrxName())
|
||||
.setParameters(new Object[]{getDD_Order_ID()})
|
||||
List<MDDOrderLine> list = new Query(getCtx(), I_DD_OrderLine.Table_Name, whereClauseFinal.toString(), get_TrxName())
|
||||
.setParameters(getDD_Order_ID())
|
||||
.setOrderBy(orderClause)
|
||||
.list();
|
||||
return list.toArray(new MDDOrderLine[list.size()]);
|
||||
|
|
Loading…
Reference in New Issue