FR: [ 2214883 ] Remove SQL code and Replace for Query
-- hi, i am starting to slowly go thru the codes to do the above. any comments or advice?
This commit is contained in:
parent
c19a5a7915
commit
30616a0000
|
@ -18,6 +18,7 @@ package org.compiere.model;
|
|||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -31,6 +32,7 @@ import org.compiere.util.Msg;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: M_Element.java,v 1.3 2006/07/30 00:58:37 jjanke Exp $
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
*/
|
||||
public class M_Element extends X_AD_Element
|
||||
{
|
||||
|
@ -59,36 +61,16 @@ public class M_Element extends X_AD_Element
|
|||
{
|
||||
if (columnName == null || columnName.length() == 0)
|
||||
return columnName;
|
||||
String retValue = columnName;
|
||||
String sql = "SELECT ColumnName FROM AD_Element WHERE UPPER(ColumnName)=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, trxName);
|
||||
pstmt.setString (1, columnName.toUpperCase());
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
{
|
||||
retValue = rs.getString(1);
|
||||
if (rs.next())
|
||||
s_log.warning("Not unique: " + columnName
|
||||
+ " -> " + retValue + " - " + rs.getString(1));
|
||||
}
|
||||
else
|
||||
s_log.warning("No found: " + columnName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, columnName, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
String whereClause = "UPPER(ColumnName)=?";
|
||||
List <M_Element> list = new Query(null, M_Element.Table_Name, whereClause, trxName)
|
||||
.setParameters(new Object[]{columnName.toUpperCase()})
|
||||
.list(); //to detect > 1 condition
|
||||
if (list.size() > 1)
|
||||
s_log.warning("Not unique: " + columnName + " -> " + list.size() + " of same columnName");
|
||||
M_Element retValue = list.get(0); //red1 - now getting the first only occurrence
|
||||
return retValue.toString();
|
||||
|
||||
return retValue;
|
||||
} // getColumnName
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,11 +19,13 @@ package org.compiere.process;
|
|||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -34,6 +36,7 @@ import org.compiere.util.Msg;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: BPartnerValidate.java,v 1.2 2006/07/30 00:51:02 jjanke Exp $
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
*/
|
||||
public class BPartnerValidate extends SvrProcess
|
||||
{
|
||||
|
@ -83,29 +86,13 @@ public class BPartnerValidate extends SvrProcess
|
|||
}
|
||||
else
|
||||
{
|
||||
String sql = "SELECT * FROM C_BPartner WHERE C_BP_Group_ID=? AND IsActive='Y'";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||
pstmt.setInt (1, p_C_BP_Group_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
MBPartner bp = new MBPartner (getCtx(), rs, get_TrxName());
|
||||
checkBP (bp);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
String whereClause = "C_BP_Group_ID=?";
|
||||
List <MBPartner> list = new Query(getCtx(), MBPartner.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{p_C_BP_Group_ID})
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
}
|
||||
//
|
||||
return "OK";
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MAccount;
|
||||
|
@ -34,6 +35,7 @@ import org.compiere.model.MJournal;
|
|||
import org.compiere.model.MJournalBatch;
|
||||
import org.compiere.model.MJournalLine;
|
||||
import org.compiere.model.MOrg;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_T_InvoiceGL;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.DB;
|
||||
|
@ -45,6 +47,7 @@ import org.compiere.util.Msg;
|
|||
* The actual data shown is T_InvoiceGL_v
|
||||
* @author Jorg Janke
|
||||
* @version $Id: InvoiceNGL.java,v 1.3 2006/08/04 03:53:59 jjanke Exp $
|
||||
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1
|
||||
*/
|
||||
public class InvoiceNGL extends SvrProcess
|
||||
{
|
||||
|
@ -216,37 +219,14 @@ public class InvoiceNGL extends SvrProcess
|
|||
*/
|
||||
private String createGLJournal()
|
||||
{
|
||||
ArrayList<X_T_InvoiceGL> list = new ArrayList<X_T_InvoiceGL>();
|
||||
String sql = "SELECT * FROM T_InvoiceGL "
|
||||
+ "WHERE AD_PInstance_ID=" + getAD_PInstance_ID()
|
||||
+ " ORDER BY AD_Org_ID";
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, get_TrxName());
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
list.add (new X_T_InvoiceGL (getCtx(), rs, get_TrxName()));
|
||||
}
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
}
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
String whereClause = "AD_PInstance_ID=?";
|
||||
List <X_T_InvoiceGL> list = new Query(getCtx(), X_T_InvoiceGL.Table_Name, whereClause, get_TrxName())
|
||||
.setParameters(new Object[]{getAD_PInstance_ID()})
|
||||
.setOrderBy("AD_Org_ID")
|
||||
.list();
|
||||
//FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
|
||||
if (list.size() == 0)
|
||||
return " - No Records found";
|
||||
|
||||
|
|
Loading…
Reference in New Issue