Peer review revisions 11587, 11588, 11589, 11591, 11592, 11601, 11602, 11603, 11604, 11605, 11606, 11607 - just applying some best practices

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-08 22:10:23 +00:00
parent ec9937f54e
commit 0392c5a175
6 changed files with 22 additions and 30 deletions

View File

@ -24,7 +24,6 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Properties; import java.util.Properties;
@ -45,7 +44,6 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.MimeType; import org.compiere.util.MimeType;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -72,7 +70,7 @@ public class MAttachment extends X_AD_Attachment
/** /**
* Get Attachment * Get Attachment (if there are more than one attachment it gets the first in no specific order)
* @param ctx context * @param ctx context
* @param AD_Table_ID table * @param AD_Table_ID table
* @param Record_ID record * @param Record_ID record

View File

@ -30,16 +30,13 @@ import org.compiere.util.CLogger;
*/ */
public class MBPBankAccount extends X_C_BP_BankAccount public class MBPBankAccount extends X_C_BP_BankAccount
{ {
/** /**
* *
*/ */
private static final long serialVersionUID = 2580706419593695062L; private static final long serialVersionUID = 2580706419593695062L;
/** /**
* Get Accounst Of BPartner * Get Accounts Of BPartner
* @param ctx context * @param ctx context
* @param C_BPartner_ID bpartner * @param C_BPartner_ID bpartner
* @return * @return
@ -47,7 +44,7 @@ public class MBPBankAccount extends X_C_BP_BankAccount
public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID) public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID)
{ {
final String whereClause = MBPBankAccount.COLUMNNAME_C_BPartner_ID+"=?"; final String whereClause = MBPBankAccount.COLUMNNAME_C_BPartner_ID+"=?";
List<MBPBankAccount>list = new Query(ctx,MBPBankAccount.Table_Name,whereClause,null) List<MBPBankAccount>list = new Query(ctx,I_C_BP_BankAccount.Table_Name,whereClause,null)
.setParameters(C_BPartner_ID) .setParameters(C_BPartner_ID)
.setOnlyActiveRecords(true) .setOnlyActiveRecords(true)
.list(); .list();

View File

@ -18,13 +18,10 @@ package org.compiere.model;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.process.DocAction; import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine; import org.compiere.process.DocumentEngine;

View File

@ -29,11 +29,13 @@ import org.compiere.util.CLogger;
*/ */
public class MContainerElement extends X_CM_Container_Element public class MContainerElement extends X_CM_Container_Element
{ {
/** serialVersionUID */ /**
private static final long serialVersionUID = 7230036377422361941L; *
*/
private static final long serialVersionUID = 8487403111353473486L;
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MContainer.class); private static CLogger s_log = CLogger.getCLogger (MContainerElement.class);
/** /**
* get Container Element by ID * get Container Element by ID
@ -43,11 +45,7 @@ public class MContainerElement extends X_CM_Container_Element
* @return ContainerElement * @return ContainerElement
*/ */
public static MContainerElement get(Properties ctx, int CM_ContainerElement_ID, String trxName) { public static MContainerElement get(Properties ctx, int CM_ContainerElement_ID, String trxName) {
final String whereClause = I_CM_Container_Element.COLUMNNAME_CM_Container_Element_ID+"=?"; return new MContainerElement(ctx, CM_ContainerElement_ID, trxName);
MContainerElement thisContainerElement = new Query(ctx,I_CM_Container_Element.Table_Name,whereClause, trxName)
.setParameters(CM_ContainerElement_ID)
.firstOnly();
return thisContainerElement;
} }
/*************************************************************************** /***************************************************************************

View File

@ -26,6 +26,7 @@ import org.compiere.process.ProcessInfo;
import org.compiere.util.CCache; import org.compiere.util.CCache;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Trx; import org.compiere.util.Trx;
import org.compiere.wf.MWFNode;
/** /**
* Process Model * Process Model
@ -372,7 +373,7 @@ public class MProcess extends X_AD_Process
menues[i].setDescription(getDescription()); menues[i].setDescription(getDescription());
menues[i].saveEx(); menues[i].saveEx();
} }
X_AD_WF_Node[] nodes = MWindow.getWFNodes(getCtx(), "AD_Process_ID=" + getAD_Process_ID(), get_TrxName()); MWFNode[] nodes = MWindow.getWFNodes(getCtx(), "AD_Process_ID=" + getAD_Process_ID(), get_TrxName());
for (int i = 0; i < nodes.length; i++) for (int i = 0; i < nodes.length; i++)
{ {
boolean changed = false; boolean changed = false;

View File

@ -26,6 +26,7 @@ import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.wf.MWFNode;
/** /**
* Window Model * Window Model
@ -38,7 +39,7 @@ public class MWindow extends X_AD_Window
/** /**
* *
*/ */
private static final long serialVersionUID = 6783399136841920556L; private static final long serialVersionUID = -7604318488890368565L;
/** Static Logger */ /** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MWindow.class); private static CLogger s_log = CLogger.getCLogger (MWindow.class);
@ -139,7 +140,7 @@ public class MWindow extends X_AD_Window
menues[i].save(); menues[i].save();
} }
// //
X_AD_WF_Node[] nodes = getWFNodes(getCtx(), "AD_Window_ID=" + getAD_Window_ID(), get_TrxName()); MWFNode[] nodes = getWFNodes(getCtx(), "AD_Window_ID=" + getAD_Window_ID(), get_TrxName());
for (int i = 0; i < nodes.length; i++) for (int i = 0; i < nodes.length; i++)
{ {
boolean changed = false; boolean changed = false;
@ -171,11 +172,11 @@ public class MWindow extends X_AD_Window
* @param trxName transaction * @param trxName transaction
* @return nodes * @return nodes
*/ */
public static X_AD_WF_Node[] getWFNodes (Properties ctx, String whereClause, String trxName) public static MWFNode[] getWFNodes (Properties ctx, String whereClause, String trxName)
{ {
List<X_AD_WF_Node> list = new Query(ctx,I_AD_WF_Node.Table_Name,whereClause,trxName) List<MWFNode> list = new Query(ctx,I_AD_WF_Node.Table_Name,whereClause,trxName)
.list(); .list();
X_AD_WF_Node[] retValue = new X_AD_WF_Node[list.size()]; MWFNode[] retValue = new MWFNode[list.size()];
list.toArray (retValue); list.toArray (retValue);
return retValue; return retValue;
} // getWFNode } // getWFNode