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
042083872b
commit
b690a934d3
|
@ -23,6 +23,7 @@ import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.compiere.model.I_C_InvoiceLine;
|
||||||
import org.compiere.model.MInOut;
|
import org.compiere.model.MInOut;
|
||||||
import org.compiere.model.MInOutLine;
|
import org.compiere.model.MInOutLine;
|
||||||
import org.compiere.model.MInvoiceLine;
|
import org.compiere.model.MInvoiceLine;
|
||||||
|
@ -204,10 +205,10 @@ public class InOutGenerateRMA extends SvrProcess
|
||||||
//
|
//
|
||||||
// Link to corresponding Invoice Line (if any) - teo_sarca [ 2818523 ]
|
// Link to corresponding Invoice Line (if any) - teo_sarca [ 2818523 ]
|
||||||
// The MMatchInv records will be automatically generated on MInOut.completeIt()
|
// The MMatchInv records will be automatically generated on MInOut.completeIt()
|
||||||
final MInvoiceLine invoiceLine = new Query(shipment.getCtx(), MInvoiceLine.Table_Name,
|
final MInvoiceLine invoiceLine = new Query(shipment.getCtx(), I_C_InvoiceLine.Table_Name,
|
||||||
MInvoiceLine.COLUMNNAME_M_RMALine_ID+"=?",
|
I_C_InvoiceLine.COLUMNNAME_M_RMALine_ID+"=?",
|
||||||
shipment.get_TrxName())
|
shipment.get_TrxName())
|
||||||
.setParameters(new Object[]{rmaLine.getM_RMALine_ID()})
|
.setParameters(rmaLine.getM_RMALine_ID())
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
if (invoiceLine != null)
|
if (invoiceLine != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,9 +242,9 @@ public class MAccount extends X_C_ValidCombination
|
||||||
*/
|
*/
|
||||||
public static MAccount get (Properties ctx, int C_AcctSchema_ID, String alias)
|
public static MAccount get (Properties ctx, int C_AcctSchema_ID, String alias)
|
||||||
{
|
{
|
||||||
String whereClause = "C_AcctSchema_ID=? AND Alias=?";
|
final String whereClause = "C_AcctSchema_ID=? AND Alias=?";
|
||||||
MAccount retValue = new Query(ctx,MAccount.Table_Name,whereClause.toString(),null)
|
MAccount retValue = new Query(ctx,I_C_ValidCombination.Table_Name,whereClause.toString(),null)
|
||||||
.setParameters(new Object[]{C_AcctSchema_ID,alias})
|
.setParameters(C_AcctSchema_ID,alias)
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get
|
} // get
|
||||||
|
|
|
@ -139,8 +139,8 @@ public final class MAccountLookup extends Lookup implements Serializable
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
String whereClause = "C_ValidCombination_ID=?";
|
String whereClause = "C_ValidCombination_ID=?";
|
||||||
MAccount account = new Query(Env.getCtx(),MAccount.Table_Name,whereClause,null)
|
MAccount account = new Query(Env.getCtx(),I_C_ValidCombination.Table_Name,whereClause,null)
|
||||||
.setParameters(new Object[]{ID})
|
.setParameters(ID)
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
|
|
||||||
if(account == null)
|
if(account == null)
|
||||||
|
@ -178,12 +178,12 @@ public final class MAccountLookup extends Lookup implements Serializable
|
||||||
list.add(new KeyNamePair (-1, ""));
|
list.add(new KeyNamePair (-1, ""));
|
||||||
//
|
//
|
||||||
ArrayList<Object> params = new ArrayList<Object>();
|
ArrayList<Object> params = new ArrayList<Object>();
|
||||||
String whereClause = "AD_Client_ID=?";
|
final String whereClause = "AD_Client_ID=?";
|
||||||
params.add(Env.getAD_Client_ID(m_ctx));
|
params.add(Env.getAD_Client_ID(m_ctx));
|
||||||
|
|
||||||
List<MAccount> accounts = new Query(Env.getCtx(),I_C_ValidCombination.Table_Name,whereClause,null)
|
List<MAccount> accounts = new Query(Env.getCtx(),I_C_ValidCombination.Table_Name,whereClause,null)
|
||||||
.setParameters(params)
|
.setParameters(params)
|
||||||
.setOrderBy(MAccount.COLUMNNAME_Combination)
|
.setOrderBy(I_C_ValidCombination.COLUMNNAME_Combination)
|
||||||
.setOnlyActiveRecords(onlyActive)
|
.setOnlyActiveRecords(onlyActive)
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class MAlert extends X_AD_Alert
|
||||||
if (m_rules != null && !reload)
|
if (m_rules != null && !reload)
|
||||||
return m_rules;
|
return m_rules;
|
||||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||||
String whereClause = "AD_Alert_ID=?";
|
final String whereClause = "AD_Alert_ID=?";
|
||||||
List <MAlertRule> list = new Query(getCtx(), MAlertRule.Table_Name, whereClause, null)
|
List <MAlertRule> list = new Query(getCtx(), MAlertRule.Table_Name, whereClause, null)
|
||||||
.setParameters(new Object[]{getAD_Alert_ID()})
|
.setParameters(new Object[]{getAD_Alert_ID()})
|
||||||
.setOrderBy("Name, AD_AlertRule_ID")
|
.setOrderBy("Name, AD_AlertRule_ID")
|
||||||
|
@ -115,7 +115,7 @@ public class MAlert extends X_AD_Alert
|
||||||
if (m_recipients != null && !reload)
|
if (m_recipients != null && !reload)
|
||||||
return m_recipients;
|
return m_recipients;
|
||||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||||
String whereClause = "AD_Alert_ID=?";
|
final String whereClause = "AD_Alert_ID=?";
|
||||||
List <MAlertRecipient> list = new Query(getCtx(), MAlertRecipient.Table_Name, whereClause, null)
|
List <MAlertRecipient> list = new Query(getCtx(), MAlertRecipient.Table_Name, whereClause, null)
|
||||||
.setParameters(new Object[]{getAD_Alert_ID()})
|
.setParameters(new Object[]{getAD_Alert_ID()})
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
|
|
|
@ -144,13 +144,13 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
|
||||||
*/
|
*/
|
||||||
public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName)
|
public static MAllocationHdr[] getOfCash (Properties ctx, int C_Cash_ID, String trxName)
|
||||||
{
|
{
|
||||||
String whereClause = "IsActive='Y'"
|
final String whereClause = "IsActive='Y'"
|
||||||
+ " AND EXISTS (SELECT 1 FROM C_CashLine cl, C_AllocationLine al "
|
+ " AND EXISTS (SELECT 1 FROM C_CashLine cl, C_AllocationLine al "
|
||||||
+ "where cl.C_Cash_ID=? and al.C_CashLine_ID=cl.C_CashLine_ID "
|
+ "where cl.C_Cash_ID=? and al.C_CashLine_ID=cl.C_CashLine_ID "
|
||||||
+ "and C_AllocationHdr.C_AllocationHdr_ID=al.C_AllocationHdr_ID)";
|
+ "and C_AllocationHdr.C_AllocationHdr_ID=al.C_AllocationHdr_ID)";
|
||||||
Query query = MTable.get(ctx, MAllocationHdr.Table_ID)
|
Query query = MTable.get(ctx, I_C_AllocationHdr.Table_ID)
|
||||||
.createQuery(whereClause, trxName);
|
.createQuery(whereClause, trxName);
|
||||||
query.setParameters(new Object[]{C_Cash_ID});
|
query.setParameters(C_Cash_ID);
|
||||||
List<MAllocationHdr> list = query.list();
|
List<MAllocationHdr> list = query.list();
|
||||||
MAllocationHdr[] retValue = new MAllocationHdr[list.size()];
|
MAllocationHdr[] retValue = new MAllocationHdr[list.size()];
|
||||||
list.toArray(retValue);
|
list.toArray(retValue);
|
||||||
|
|
|
@ -220,9 +220,9 @@ public class InvoiceNGL extends SvrProcess
|
||||||
private String createGLJournal()
|
private String createGLJournal()
|
||||||
{
|
{
|
||||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||||
String whereClause = "AD_PInstance_ID=?";
|
final String whereClause = "AD_PInstance_ID=?";
|
||||||
List <X_T_InvoiceGL> list = new Query(getCtx(), X_T_InvoiceGL.Table_Name, whereClause, get_TrxName())
|
List <X_T_InvoiceGL> list = new Query(getCtx(), X_T_InvoiceGL.Table_Name, whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{getAD_PInstance_ID()})
|
.setParameters(getAD_PInstance_ID())
|
||||||
.setOrderBy("AD_Org_ID")
|
.setOrderBy("AD_Org_ID")
|
||||||
.list();
|
.list();
|
||||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class M_Production_Run extends SvrProcess {
|
||||||
|
|
||||||
String whereClause = "M_Production_ID=? ";
|
String whereClause = "M_Production_ID=? ";
|
||||||
List<X_M_ProductionPlan> lines = new Query(getCtx(), X_M_ProductionPlan.Table_Name , whereClause, get_TrxName())
|
List<X_M_ProductionPlan> lines = new Query(getCtx(), X_M_ProductionPlan.Table_Name , whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{p_Record_ID })
|
.setParameters(p_Record_ID)
|
||||||
.setOrderBy("Line, M_Product_ID")
|
.setOrderBy("Line, M_Product_ID")
|
||||||
.list();
|
.list();
|
||||||
for (X_M_ProductionPlan pp :lines)
|
for (X_M_ProductionPlan pp :lines)
|
||||||
|
@ -125,7 +125,7 @@ public class M_Production_Run extends SvrProcess {
|
||||||
{
|
{
|
||||||
whereClause = "M_ProductionPlan_ID= ? ";
|
whereClause = "M_ProductionPlan_ID= ? ";
|
||||||
List<X_M_ProductionLine> production_lines = new Query(getCtx(), X_M_ProductionLine.Table_Name , whereClause, get_TrxName())
|
List<X_M_ProductionLine> production_lines = new Query(getCtx(), X_M_ProductionLine.Table_Name , whereClause, get_TrxName())
|
||||||
.setParameters(new Object[]{pp.getM_ProductionPlan_ID()})
|
.setParameters(pp.getM_ProductionPlan_ID())
|
||||||
.setOrderBy("Line")
|
.setOrderBy("Line")
|
||||||
.list();
|
.list();
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,10 @@ import java.sql.Timestamp;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.compiere.model.I_C_BPartner;
|
||||||
|
import org.compiere.model.I_M_Product;
|
||||||
|
import org.compiere.model.I_M_Product_Category;
|
||||||
|
import org.compiere.model.I_M_Warehouse;
|
||||||
import org.compiere.model.MBPGroup;
|
import org.compiere.model.MBPGroup;
|
||||||
import org.compiere.model.MBPartner;
|
import org.compiere.model.MBPartner;
|
||||||
import org.compiere.model.MBPartnerLocation;
|
import org.compiere.model.MBPartnerLocation;
|
||||||
|
@ -56,8 +60,8 @@ public final class InventoryUtil
|
||||||
public static MProduct getCreateProduct(String value, String MMPolicy)
|
public static MProduct getCreateProduct(String value, String MMPolicy)
|
||||||
{
|
{
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
MProduct product = new Query(ctx, MProduct.Table_Name, "Value=?", null)
|
MProduct product = new Query(ctx, I_M_Product.Table_Name, "Value=?", null)
|
||||||
.setParameters(new Object[]{value})
|
.setParameters(value)
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setClient_ID()
|
.setClient_ID()
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
|
@ -104,9 +108,9 @@ public final class InventoryUtil
|
||||||
if (MMPolicy == null)
|
if (MMPolicy == null)
|
||||||
MMPolicy = MProductCategory.MMPOLICY_FiFo;
|
MMPolicy = MProductCategory.MMPOLICY_FiFo;
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
String whereClause = MProductCategory.COLUMNNAME_Value+"=?";
|
final String whereClause = I_M_Product_Category.COLUMNNAME_Value+"=?";
|
||||||
MProductCategory pc = new Query(ctx, MProductCategory.Table_Name, whereClause, null)
|
MProductCategory pc = new Query(ctx, I_M_Product_Category.Table_Name, whereClause, null)
|
||||||
.setParameters(new Object[]{value})
|
.setParameters(value)
|
||||||
.setOnlyActiveRecords(true)
|
.setOnlyActiveRecords(true)
|
||||||
.setClient_ID()
|
.setClient_ID()
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
|
@ -136,9 +140,9 @@ public final class InventoryUtil
|
||||||
public static MBPartner getCreatePartner(String value)
|
public static MBPartner getCreatePartner(String value)
|
||||||
{
|
{
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
String whereClause = MBPartner.COLUMNNAME_Value+"=?";
|
final String whereClause = MBPartner.COLUMNNAME_Value+"=?";
|
||||||
MBPartner bp = new Query(ctx, MBPartner.Table_Name, whereClause, null)
|
MBPartner bp = new Query(ctx, I_C_BPartner.Table_Name, whereClause, null)
|
||||||
.setParameters(new Object[]{value})
|
.setParameters(value)
|
||||||
.setClient_ID()
|
.setClient_ID()
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
if (bp == null)
|
if (bp == null)
|
||||||
|
@ -339,9 +343,9 @@ public final class InventoryUtil
|
||||||
if (AD_Org_ID <= 0)
|
if (AD_Org_ID <= 0)
|
||||||
AD_Org_ID = getFirst_Org_ID();
|
AD_Org_ID = getFirst_Org_ID();
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
String whereClause = "AD_Org_ID=? AND Value=?";
|
final String whereClause = "AD_Org_ID=? AND Value=?";
|
||||||
MWarehouse wh = new Query(ctx, MWarehouse.Table_Name, whereClause, null)
|
MWarehouse wh = new Query(ctx, I_M_Warehouse.Table_Name, whereClause, null)
|
||||||
.setParameters(new Object[]{AD_Org_ID, value})
|
.setParameters(AD_Org_ID, value)
|
||||||
.setClient_ID()
|
.setClient_ID()
|
||||||
.firstOnly();
|
.firstOnly();
|
||||||
if (wh != null)
|
if (wh != null)
|
||||||
|
|
Loading…
Reference in New Issue