peer review for 11554

- incompatible objects in MMovement
- other refactorings
FR: [ 2214883 ] Remove SQL code and Replace for Query
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
Carlos Ruiz 2010-03-03 23:38:19 +00:00
parent 1a06e21024
commit 08e0deb5cd
8 changed files with 20 additions and 21 deletions

View File

@ -102,7 +102,7 @@ public class MMovement extends X_M_Movement implements DocAction
} }
// //
final String whereClause = "M_Movement_ID=?"; final String whereClause = "M_Movement_ID=?";
List<MMovement> list = new Query(getCtx(), I_M_MovementLine.Table_Name, whereClause, get_TrxName()) List<MMovementLine> list = new Query(getCtx(), I_M_MovementLine.Table_Name, whereClause, get_TrxName())
.setParameters(getM_Movement_ID()) .setParameters(getM_Movement_ID())
.setOrderBy(MMovementLine.COLUMNNAME_Line) .setOrderBy(MMovementLine.COLUMNNAME_Line)
.list(); .list();

View File

@ -639,7 +639,7 @@ public class MOrder extends X_C_Order implements DocAction
public MOrderLine[] getLines (String whereClause, String orderClause) public MOrderLine[] getLines (String whereClause, String orderClause)
{ {
//red1 - using new Query class from Teo / Victor's MDDOrder.java implementation //red1 - using new Query class from Teo / Victor's MDDOrder.java implementation
StringBuffer whereClauseFinal = new StringBuffer(MOrderLine.COLUMNNAME_C_Order_ID+"=?"); StringBuffer whereClauseFinal = new StringBuffer(MOrderLine.COLUMNNAME_C_Order_ID+"=? ");
if (!Util.isEmpty(whereClause, true)) if (!Util.isEmpty(whereClause, true))
whereClauseFinal.append(whereClause); whereClauseFinal.append(whereClause);
if (orderClause.length() == 0) if (orderClause.length() == 0)

View File

@ -44,9 +44,9 @@ public class MPaymentAllocate extends X_C_PaymentAllocate
*/ */
public static MPaymentAllocate[] get (MPayment parent) public static MPaymentAllocate[] get (MPayment parent)
{ {
final String whereClause = "C_Payment_ID=? AND IsActive=?"; final String whereClause = "C_Payment_ID=?";
Query query = MTable.get(parent.getCtx(), Table_ID).createQuery(whereClause, parent.get_TrxName()); Query query = MTable.get(parent.getCtx(), Table_ID).createQuery(whereClause, parent.get_TrxName());
query.setParameters(parent.getC_Payment_ID(), "Y"); query.setParameters(parent.getC_Payment_ID()).setOnlyActiveRecords(true);
List<MPaymentAllocate> list = query.list(); List<MPaymentAllocate> list = query.list();
return list.toArray(new MPaymentAllocate[list.size()]); return list.toArray(new MPaymentAllocate[list.size()]);
} // get } // get

View File

@ -51,12 +51,10 @@ import org.compiere.util.TimeUtil;
*/ */
public class MPeriod extends X_C_Period public class MPeriod extends X_C_Period
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = -4342181292848531751L; private static final long serialVersionUID = 6498973218391994963L;
/** /**
* Get Period from Cache * Get Period from Cache

View File

@ -38,8 +38,7 @@ public class MPriceList extends X_M_PriceList
/** /**
* *
*/ */
private static final long serialVersionUID = 221716795566010352L; private static final long serialVersionUID = -5096935348390226068L;
/** /**
* Get Price List (cached) * Get Price List (cached)
@ -87,6 +86,7 @@ public class MPriceList extends X_M_PriceList
final String whereClause = "AD_Client_ID=? AND IsDefault=? AND IsSOPriceList=?"; final String whereClause = "AD_Client_ID=? AND IsDefault=? AND IsSOPriceList=?";
retValue = new Query(ctx, Table_Name, whereClause, null) retValue = new Query(ctx, Table_Name, whereClause, null)
.setParameters(AD_Client_ID, "Y", IsSOPriceList ? "Y" : "N") .setParameters(AD_Client_ID, "Y", IsSOPriceList ? "Y" : "N")
.setOnlyActiveRecords(true)
.setOrderBy("M_PriceList_ID") .setOrderBy("M_PriceList_ID")
.first(); .first();
@ -133,7 +133,8 @@ public class MPriceList extends X_M_PriceList
// Get from DB // Get from DB
final String whereClause = "AD_Client_ID=? AND IsDefault=? AND IsSOPriceList=? AND C_Currency_ID=?"; final String whereClause = "AD_Client_ID=? AND IsDefault=? AND IsSOPriceList=? AND C_Currency_ID=?";
retValue = new Query(ctx, Table_Name, whereClause, null) retValue = new Query(ctx, Table_Name, whereClause, null)
.setParameters(AD_Client_ID, "Y", IsSOPriceList ? "Y" : "N", Integer.valueOf(M_Currency_ID)) .setParameters(AD_Client_ID, "Y", IsSOPriceList ? "Y" : "N", M_Currency_ID)
.setOnlyActiveRecords(true)
.setOrderBy("M_PriceList_ID") .setOrderBy("M_PriceList_ID")
.first(); .first();
@ -242,9 +243,10 @@ public class MPriceList extends X_M_PriceList
if (m_plv != null && m_plv.getValidFrom().before(valid)) if (m_plv != null && m_plv.getValidFrom().before(valid))
return m_plv; return m_plv;
final String whereClause = "M_PriceList_ID=? AND TRUNC(ValidFrom)<=? AND IsActive=?"; final String whereClause = "M_PriceList_ID=? AND TRUNC(ValidFrom)<=?";
m_plv = new Query(getCtx(), I_M_PriceList_Version.Table_Name, whereClause, get_TrxName()) m_plv = new Query(getCtx(), I_M_PriceList_Version.Table_Name, whereClause, get_TrxName())
.setParameters(getM_PriceList_ID(), valid, "Y") .setParameters(getM_PriceList_ID(), valid)
.setOnlyActiveRecords(true)
.setOrderBy("ValidFrom DESC") .setOrderBy("ValidFrom DESC")
.first(); .first();
if (m_plv == null) if (m_plv == null)

View File

@ -86,9 +86,8 @@ public class MProduct extends X_M_Product
*/ */
public static MProduct[] get (Properties ctx, String whereClause, String trxName) public static MProduct[] get (Properties ctx, String whereClause, String trxName)
{ {
int AD_Client_ID = Env.getAD_Client_ID(ctx); List<MProduct> list = new Query(ctx, Table_Name, whereClause, trxName)
List<MProduct> list = new Query(ctx, Table_Name, "AD_Client_ID=? AND "+whereClause, trxName) .setClient_ID()
.setParameters(AD_Client_ID)
.list(); .list();
return list.toArray(new MProduct[list.size()]); return list.toArray(new MProduct[list.size()]);
} // get } // get
@ -102,9 +101,9 @@ public class MProduct extends X_M_Product
*/ */
public static List<MProduct> getByUPC(Properties ctx, String upc, String trxName) public static List<MProduct> getByUPC(Properties ctx, String upc, String trxName)
{ {
final String whereClause = "AD_Client_ID=? AND UPC=?"; final String whereClause = "UPC=?";
Query q = new Query(ctx, Table_Name, whereClause, trxName); Query q = new Query(ctx, Table_Name, whereClause, trxName);
q.setParameters(Env.getAD_Client_ID(ctx), upc); q.setParameters(upc).setClient_ID();
return(q.list()); return(q.list());
} }

View File

@ -34,8 +34,7 @@ public class MProductCosting extends X_M_Product_Costing
/** /**
* *
*/ */
private static final long serialVersionUID = -7980130899951986948L; private static final long serialVersionUID = 5563448335633481151L;
/** /**
* Get Costing Of Product * Get Costing Of Product

View File

@ -43,9 +43,10 @@ public class MProductPO extends X_M_Product_PO
*/ */
public static MProductPO[] getOfProduct (Properties ctx, int M_Product_ID, String trxName) public static MProductPO[] getOfProduct (Properties ctx, int M_Product_ID, String trxName)
{ {
final String whereClause = "M_Product_ID=? AND IsActive=?"; final String whereClause = "M_Product_ID=?";
List<MProductPO> list = new Query(ctx, Table_Name, whereClause, trxName) List<MProductPO> list = new Query(ctx, Table_Name, whereClause, trxName)
.setParameters(M_Product_ID, "Y") .setParameters(M_Product_ID)
.setOnlyActiveRecords(true)
.setOrderBy("IsCurrentVendor DESC") .setOrderBy("IsCurrentVendor DESC")
.list(); .list();
return list.toArray(new MProductPO[list.size()]); return list.toArray(new MProductPO[list.size()]);