Organize imports, some parameterizing and remove unused stuff

VICTOR PLEASE REVIEW
This commit is contained in:
Redhuan D. Oon 2008-11-20 09:05:17 +00:00
parent 0e62216b5a
commit e18e3c3c7c
1 changed files with 11 additions and 21 deletions

View File

@ -51,14 +51,14 @@ public class QueryDB {
public static Object newInstance(String classname, int id, String trxName ) public static Object newInstance(String classname, int id, String trxName )
{ {
Object result = null; Object result = null;
Class args; Class<?> args;
int begin = classname.indexOf("X_") + 2 ; int begin = classname.indexOf("X_") + 2 ;
String table = classname.substring(begin); String table = classname.substring(begin);
Class[] intArgsClass = new Class[] {Properties.class , int.class, String.class}; Class<?>[] intArgsClass = new Class[] {Properties.class , int.class, String.class};
//Integer height = new Integer(12); //Integer height = new Integer(12);
Integer ID = new Integer(id); Integer ID = new Integer(id);
Object[] intArgs = new Object[] {Env.getCtx(), ID,table}; Object[] intArgs = new Object[] {Env.getCtx(), ID,table};
Constructor intArgsConstructor; Constructor<?> intArgsConstructor;
try try
{ {
@ -81,10 +81,11 @@ public class QueryDB {
} }
} }
public static Object createObject(Constructor constructor, public static Object createObject(Constructor<?> constructor,
Object[] arguments) { Object[] arguments) {
//System.out.println ("Constructor: " + constructor.toString()); log.fine("Constructor: " + constructor.toString());
Object object = null; Object object = null;
try { try {
@ -104,9 +105,8 @@ public class QueryDB {
} }
public List<Object> execute(String filter) { public List<Object> execute(String filter) {
log.fine((new Integer(classname.indexOf("X_"))).toString());
//String tablename = POClass.getName();
//System.out.print(classname.indexOf("X_"));
int begin = classname.indexOf("X_") + 2 ; int begin = classname.indexOf("X_") + 2 ;
String table = classname.substring(begin); String table = classname.substring(begin);
StringBuffer sql = new StringBuffer("SELECT ").append(table).append("_ID FROM " + table); StringBuffer sql = new StringBuffer("SELECT ").append(table).append("_ID FROM " + table);
@ -115,14 +115,13 @@ public class QueryDB {
else else
sql.append(" WHERE ").append(filter); sql.append(" WHERE ").append(filter);
//System.out.println("Query " + sql.toString()); log.fine("Query =" + sql.toString());
List<Object> results = new ArrayList<Object>(); List<Object> results = new ArrayList<Object>();
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
//pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
@ -144,24 +143,15 @@ public class QueryDB {
public List<Object> execute() { public List<Object> execute() {
//String tablename = POClass.getName();
//System.out.print(classname.indexOf("X_"));
int begin = classname.indexOf("X_") + 2 ; int begin = classname.indexOf("X_") + 2 ;
String table = classname.substring(begin); String table = classname.substring(begin);
StringBuffer sql = new StringBuffer("SELECT ").append(table).append("_ID FROM " + table); StringBuffer sql = new StringBuffer("SELECT ").append(table).append("_ID FROM " + table);
//if (filter.equals(""))
//System.out.println("not exist filter");
//else
//sql.append(" WHERE ").append(filter);
//System.out.println("Query " + sql.toString());
List<Object> results = new ArrayList<Object>(); List<Object> results = new ArrayList<Object>();
try try
{ {
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
//pstmt.setInt(1, C_BPartner_ID);
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {