FR: [ 2214883 ] Remove SQL code and Replace for Query
thanks TRIFON
This commit is contained in:
parent
baa598c901
commit
d28e629e75
|
@ -26,6 +26,7 @@ import org.compiere.util.*;
|
||||||
*
|
*
|
||||||
* @author Yves Sandfort
|
* @author Yves Sandfort
|
||||||
* @version $Id: MContainer.java,v 1.20 2006/09/05 23:22:53 comdivision Exp $
|
* @version $Id: MContainer.java,v 1.20 2006/09/05 23:22:53 comdivision Exp $
|
||||||
|
* FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||||
*/
|
*/
|
||||||
public class MContainer extends X_CM_Container
|
public class MContainer extends X_CM_Container
|
||||||
{
|
{
|
||||||
|
@ -42,35 +43,12 @@ public class MContainer extends X_CM_Container
|
||||||
*/
|
*/
|
||||||
public static MContainer get(Properties ctx, String relURL, int CM_WebProject_Id, String trxName) {
|
public static MContainer get(Properties ctx, String relURL, int CM_WebProject_Id, String trxName) {
|
||||||
MContainer thisContainer = null;
|
MContainer thisContainer = null;
|
||||||
String sql = "SELECT * FROM CM_Container WHERE (RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||||
PreparedStatement pstmt = null;
|
String whereClause = "(RelativeURL LIKE ? OR RelativeURL LIKE ?) AND CM_WebProject_ID=?";
|
||||||
try
|
thisContainer = new Query(ctx, MContainer.Table_Name, whereClause, trxName)
|
||||||
{
|
.setParameters(new Object[]{relURL, relURL+"/",CM_WebProject_Id})
|
||||||
pstmt = DB.prepareStatement(sql, trxName);
|
.first();
|
||||||
pstmt.setString (1,relURL);
|
|
||||||
pstmt.setString (2,relURL+"/");
|
|
||||||
pstmt.setInt(3, CM_WebProject_Id);
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
if (rs.next())
|
|
||||||
thisContainer = (new MContainer(ctx, rs, 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;
|
|
||||||
}
|
|
||||||
return thisContainer;
|
return thisContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,34 +63,12 @@ public class MContainer extends X_CM_Container
|
||||||
*/
|
*/
|
||||||
public static MContainer get(Properties ctx, int CM_Container_ID, int CM_WebProject_Id, String trxName) {
|
public static MContainer get(Properties ctx, int CM_Container_ID, int CM_WebProject_Id, String trxName) {
|
||||||
MContainer thisContainer = null;
|
MContainer thisContainer = null;
|
||||||
String sql = "SELECT * FROM CM_Container WHERE CM_Container_ID=? AND CM_WebProject_ID=?";
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||||
PreparedStatement pstmt = null;
|
String whereClause = "CM_Container_ID=? AND CM_WebProject_ID=?";
|
||||||
try
|
thisContainer = new Query(ctx, MContainer.Table_Name, whereClause, trxName)
|
||||||
{
|
.setParameters(new Object[]{CM_Container_ID, CM_WebProject_Id})
|
||||||
pstmt = DB.prepareStatement(sql, trxName);
|
.first();
|
||||||
pstmt.setInt(1, CM_Container_ID);
|
//
|
||||||
pstmt.setInt(2, CM_WebProject_Id);
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
if (rs.next())
|
|
||||||
thisContainer = (new MContainer(ctx, rs, 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;
|
|
||||||
}
|
|
||||||
return thisContainer;
|
return thisContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,33 +109,12 @@ public class MContainer extends X_CM_Container
|
||||||
String trxName)
|
String trxName)
|
||||||
{
|
{
|
||||||
MContainer cc = null;
|
MContainer cc = null;
|
||||||
PreparedStatement pstmt = null;
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||||
String sql = "SELECT * FROM CM_Container WHERE CM_Container_ID=?";
|
String whereClause = "CM_Container_ID=?";
|
||||||
try
|
cc = new Query(ctx, MContainer.Table_Name, whereClause, trxName)
|
||||||
{
|
.setParameters(new Object[]{CM_Container_ID})
|
||||||
pstmt = DB.prepareStatement (sql, null);
|
.first();
|
||||||
pstmt.setInt (1, CM_Container_ID);
|
//
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
|
||||||
if (rs.next ())
|
|
||||||
cc = new MContainer (ctx, rs, 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;
|
|
||||||
}
|
|
||||||
return cc;
|
return cc;
|
||||||
} // getDirect
|
} // getDirect
|
||||||
|
|
||||||
|
@ -192,37 +127,12 @@ public class MContainer extends X_CM_Container
|
||||||
*/
|
*/
|
||||||
public static MContainer[] getContainers (MWebProject project)
|
public static MContainer[] getContainers (MWebProject project)
|
||||||
{
|
{
|
||||||
ArrayList<MContainer> list = new ArrayList<MContainer> ();
|
//FR: [ 2214883 ] Remove SQL code and Replace for Query - red1/trifon
|
||||||
PreparedStatement pstmt = null;
|
String whereClause = "CM_WebProject_ID=?";
|
||||||
String sql = "SELECT * FROM CM_Container WHERE CM_WebProject_ID=? ORDER BY CM_Container_ID";
|
List<MContainer> list = new Query(project.getCtx(), MContainer.Table_Name, whereClause, project.get_TrxName())
|
||||||
try
|
.setParameters(new Object[]{project.getCM_WebProject_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 MContainer (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;
|
|
||||||
}
|
|
||||||
MContainer[] retValue = new MContainer[list.size ()];
|
MContainer[] retValue = new MContainer[list.size ()];
|
||||||
list.toArray (retValue);
|
list.toArray (retValue);
|
||||||
return retValue;
|
return retValue;
|
||||||
|
|
Loading…
Reference in New Issue