FR: [ 2214883 ] Remove SQL code and Replace for Query
-- JUnit test pending Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
parent
f95f2f2f6d
commit
14046997c8
|
@ -16,14 +16,11 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* BP Bank Account Model
|
||||
|
@ -47,34 +44,11 @@ public class MBPBankAccount extends X_C_BP_BankAccount
|
|||
*/
|
||||
public static MBPBankAccount[] getOfBPartner (Properties ctx, int C_BPartner_ID)
|
||||
{
|
||||
String sql = "SELECT * FROM C_BP_BankAccount WHERE C_BPartner_ID=? AND IsActive='Y'";
|
||||
ArrayList<MBPBankAccount> list = new ArrayList<MBPBankAccount>();
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, C_BPartner_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
list.add(new MBPBankAccount(ctx, rs, null));
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
try {
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
} catch (Exception e) {
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
final String whereClause = MBPBankAccount.COLUMNNAME_C_BPartner_ID+"=?";
|
||||
List<MBPBankAccount>list = new Query(ctx,MBPBankAccount.COLUMNNAME_C_BPartner_ID,whereClause,null)
|
||||
.setParameters(C_BPartner_ID)
|
||||
.setOnlyActiveRecords(true)
|
||||
.list();
|
||||
|
||||
MBPBankAccount[] retValue = new MBPBankAccount[list.size()];
|
||||
list.toArray(retValue);
|
||||
|
|
|
@ -97,34 +97,10 @@ public class MTable extends X_AD_Table
|
|||
}
|
||||
}
|
||||
//
|
||||
MTable retValue = null;
|
||||
String sql = "SELECT * FROM AD_Table WHERE UPPER(TableName)=?";
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setString(1, tableName.toUpperCase());
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
retValue = new MTable (ctx, rs, null);
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
}
|
||||
final String whereClause = I_AD_Table.COLUMNNAME_AD_Table_ID.toUpperCase()+"=?";
|
||||
MTable retValue = new Query(ctx,I_AD_Table.Table_Name,whereClause,null)
|
||||
.setParameters(tableName.toUpperCase())
|
||||
.first();
|
||||
|
||||
if (retValue != null)
|
||||
{
|
||||
|
|
|
@ -16,14 +16,11 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* User Roles Model
|
||||
|
@ -47,34 +44,10 @@ public class MUserRoles extends X_AD_User_Roles
|
|||
*/
|
||||
public static MUserRoles[] getOfRole (Properties ctx, int AD_Role_ID)
|
||||
{
|
||||
String sql = "SELECT * FROM AD_User_Roles WHERE AD_Role_ID=?";
|
||||
ArrayList<MUserRoles> list = new ArrayList<MUserRoles>();
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, AD_Role_ID);
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
list.add (new MUserRoles (ctx, rs, null));
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, "getOfRole", e);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
}
|
||||
final String whereClause = I_AD_User_Roles.COLUMNNAME_AD_Role_ID+"=?";
|
||||
List<MUserRoles> list = new Query(ctx,I_AD_User_Roles.Table_Name,whereClause,null)
|
||||
.setParameters(AD_Role_ID)
|
||||
.list();
|
||||
MUserRoles[] retValue = new MUserRoles[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
|
@ -88,34 +61,10 @@ public class MUserRoles extends X_AD_User_Roles
|
|||
*/
|
||||
public static MUserRoles[] getOfUser (Properties ctx, int AD_User_ID)
|
||||
{
|
||||
String sql = "SELECT * FROM AD_User_Roles WHERE AD_User_ID=?";
|
||||
ArrayList<MUserRoles> list = new ArrayList<MUserRoles>();
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, AD_User_ID);
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
list.add (new MUserRoles (ctx, rs, null));
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log(Level.SEVERE, "getOfUser", e);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
}
|
||||
final String whereClause = I_AD_User_Roles.COLUMNNAME_AD_User_ID+"=?";
|
||||
List<MUserRoles> list = new Query(ctx,I_AD_User_Roles.Table_Name,whereClause,null)
|
||||
.setParameters(AD_User_ID)
|
||||
.list();
|
||||
MUserRoles[] retValue = new MUserRoles[list.size ()];
|
||||
list.toArray (retValue);
|
||||
return retValue;
|
||||
|
|
Loading…
Reference in New Issue