FR: [ 2214883 ] Remove SQL code and Replace for Query
-- JUnit tests in next commit (no failures) Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
parent
c36b480e68
commit
aa0454f847
|
@ -17,21 +17,19 @@
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.apache.commons.net.ftp.FTPClient;
|
import org.apache.commons.net.ftp.FTPClient;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Media Server Model
|
* Media Server Model
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MMediaServer.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
|
* @version $Id: MMediaServer.java,v 1.3 2006/07/30 00:51:05 jjanke Exp $
|
||||||
|
* @author red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||||
*/
|
*/
|
||||||
public class MMediaServer extends X_CM_Media_Server
|
public class MMediaServer extends X_CM_Media_Server
|
||||||
{
|
{
|
||||||
|
@ -48,36 +46,11 @@ public class MMediaServer extends X_CM_Media_Server
|
||||||
*/
|
*/
|
||||||
public static MMediaServer[] getMediaServer (MWebProject project)
|
public static MMediaServer[] getMediaServer (MWebProject project)
|
||||||
{
|
{
|
||||||
ArrayList<MMediaServer> list = new ArrayList<MMediaServer>();
|
final String whereClause = I_CM_Media_Server.COLUMNNAME_CM_WebProject_ID+"=?";
|
||||||
PreparedStatement pstmt = null;
|
List<MMediaServer> list = new Query(project.getCtx(),MMediaServer.Table_Name,whereClause,project.get_TrxName())
|
||||||
String sql = "SELECT * FROM CM_Media_Server WHERE CM_WebProject_ID=? ORDER BY CM_Media_Server_ID";
|
.setParameters(project.getCM_WebProject_ID())
|
||||||
try
|
.setOrderBy(I_CM_Media_Server.COLUMNNAME_CM_Media_Server_ID)
|
||||||
{
|
.list();
|
||||||
pstmt = DB.prepareStatement (sql, project.get_TrxName());
|
|
||||||
pstmt.setInt (1, project.getCM_WebProject_ID());
|
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
|
||||||
while (rs.next ())
|
|
||||||
{
|
|
||||||
list.add (new MMediaServer (project.getCtx(), rs, project.get_TrxName()));
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
MMediaServer[] retValue = new MMediaServer[list.size ()];
|
MMediaServer[] retValue = new MMediaServer[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
|
@ -19,10 +19,9 @@ package org.compiere.model;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
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;
|
||||||
|
|
||||||
|
@ -32,6 +31,7 @@ import org.compiere.util.DB;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @author victor.perez@e-evolution.com
|
* @author victor.perez@e-evolution.com
|
||||||
* @see FR [ 1966326 ] Is necessary create method to get ID menu use menu Name http://sourceforge.net/tracker/index.php?func=detail&aid=1966326&group_id=176962&atid=879335
|
* @see FR [ 1966326 ] Is necessary create method to get ID menu use menu Name http://sourceforge.net/tracker/index.php?func=detail&aid=1966326&group_id=176962&atid=879335
|
||||||
|
* @author red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||||
* @version $Id: MMenu.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $
|
* @version $Id: MMenu.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class MMenu extends X_AD_Menu
|
public class MMenu extends X_AD_Menu
|
||||||
|
@ -61,29 +61,11 @@ public class MMenu extends X_AD_Menu
|
||||||
* @param trxName transaction
|
* @param trxName transaction
|
||||||
* @return MMenu
|
* @return MMenu
|
||||||
*/
|
*/
|
||||||
public static MMenu[] get (Properties ctx, String whereClause, String trxName)
|
public static MMenu[] get (Properties ctx, final String whereClause, String trxName)
|
||||||
{
|
{
|
||||||
String sql = "SELECT * FROM AD_Menu";
|
List<MMenu> list = new Query(ctx,I_AD_Menu.Table_Name,whereClause,trxName)
|
||||||
if (whereClause != null && whereClause.length() > 0)
|
.list();
|
||||||
sql += " WHERE " + whereClause;
|
|
||||||
ArrayList<MMenu> list = new ArrayList<MMenu>();
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
ResultSet rs = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pstmt = DB.prepareStatement (sql, trxName);
|
|
||||||
rs = pstmt.executeQuery ();
|
|
||||||
while (rs.next ())
|
|
||||||
list.add (new MMenu (ctx, rs, trxName));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
s_log.log(Level.SEVERE, sql, e);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
DB.close(rs, pstmt);
|
|
||||||
rs = null; pstmt = null;
|
|
||||||
}
|
|
||||||
MMenu[] retValue = new MMenu[list.size()];
|
MMenu[] retValue = new MMenu[list.size()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
Loading…
Reference in New Issue