FR: [ 2214883 ] Remove SQL code and Replace for Query
-- JUnit test in next commit (no failures) Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2214883
This commit is contained in:
parent
afc5065246
commit
af0d7d9cc4
|
@ -20,9 +20,8 @@ import java.math.BigDecimal;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
@ -37,6 +36,7 @@ import org.compiere.util.TimeUtil;
|
|||
*
|
||||
* @author Jorg Janke
|
||||
* @version $Id: MAsset.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
||||
* @author red1 - FR: [ 2214883 ] Remove SQL code and Replace for Query
|
||||
*/
|
||||
public class MAsset extends X_A_Asset
|
||||
{
|
||||
|
@ -55,27 +55,10 @@ public class MAsset extends X_A_Asset
|
|||
*/
|
||||
public static MAsset getFromShipment (Properties ctx, int M_InOutLine_ID, String trxName)
|
||||
{
|
||||
MAsset retValue = null;
|
||||
String sql = "SELECT * FROM A_Asset WHERE M_InOutLine_ID=?";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, trxName);
|
||||
pstmt.setInt (1, M_InOutLine_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
retValue = new MAsset (ctx, rs, trxName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
final String whereClause = I_A_Asset.COLUMNNAME_M_InOutLine_ID+"=?";
|
||||
MAsset retValue = new Query(ctx,I_A_Asset.Table_Name,whereClause,trxName)
|
||||
.setParameters(M_InOutLine_ID)
|
||||
.first();
|
||||
return retValue;
|
||||
} // getFromShipment
|
||||
|
||||
|
@ -264,28 +247,11 @@ public class MAsset extends X_A_Asset
|
|||
*/
|
||||
public MAssetDelivery[] getDeliveries()
|
||||
{
|
||||
ArrayList<MAssetDelivery> list = new ArrayList<MAssetDelivery>();
|
||||
|
||||
String sql = "SELECT * FROM A_Asset_Delivery WHERE A_Asset_ID=? ORDER BY Created DESC";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||
pstmt.setInt(1, getA_Asset_ID());
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
list.add(new MAssetDelivery(getCtx(), rs, get_TrxName()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
final String whereClause = I_A_Asset_Delivery.COLUMNNAME_A_Asset_ID+"=?";
|
||||
List<MAssetDelivery> list = new Query(getCtx(),I_A_Asset_Delivery.Table_Name,whereClause,get_TrxName())
|
||||
.setParameters(getA_Asset_ID())
|
||||
.setOrderBy("Created DESC")
|
||||
.list();
|
||||
//
|
||||
MAssetDelivery[] retValue = new MAssetDelivery[list.size()];
|
||||
list.toArray(retValue);
|
||||
|
|
Loading…
Reference in New Issue