PP: refactoring PP_Cost_Collector

This commit is contained in:
teo_sarca 2008-09-16 17:37:30 +00:00
parent b40fb724d6
commit 10e16923ac
3 changed files with 431 additions and 731 deletions

File diff suppressed because it is too large Load Diff

View File

@ -12,24 +12,31 @@
* For the text or an alternative of this public license, you may reach us * * For the text or an alternative of this public license, you may reach us *
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. * * Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
* Contributor(s): Victor Perez www.e-evolution.com * * Contributor(s): Victor Perez www.e-evolution.com *
* Teo Sarca, http://www.arhipac.ro *
*****************************************************************************/ *****************************************************************************/
package org.eevolution.model; package org.eevolution.model;
import java.math.*; import java.math.BigDecimal;
import java.sql.*; import java.sql.ResultSet;
import java.util.*; import java.util.List;
import java.util.logging.*; import java.util.Properties;
import org.compiere.util.*;
import org.compiere.model.*; import org.compiere.model.Query;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
/** /**
* Shipment Material Allocation * Shipment Material Allocation
* *
* @author Victor Perez www.e-evolution.com * @author Victor Perez www.e-evolution.com
* @version $Id: MPPOrderBOMLineMA.java,v 1.1 2005/04/01 05:59:48 vpj-cd Exp $ * @version $Id: MPPOrderBOMLineMA.java,v 1.1 2005/04/01 05:59:48 vpj-cd Exp $
*
* @author Teo Sarca, http://www.arhipac.ro
*/ */
public class MPPOrderBOMLineMA extends X_PP_Order_BOMLineMA public class MPPOrderBOMLineMA extends X_PP_Order_BOMLineMA
{ {
private static final long serialVersionUID = 1L;
/** /**
* Get Material Allocations for Line * Get Material Allocations for Line
* @param ctx context * @param ctx context
@ -39,59 +46,32 @@ public class MPPOrderBOMLineMA extends X_PP_Order_BOMLineMA
*/ */
public static MPPOrderBOMLineMA[] get (Properties ctx, int PP_Order_BOMLine_ID, String trxName) public static MPPOrderBOMLineMA[] get (Properties ctx, int PP_Order_BOMLine_ID, String trxName)
{ {
ArrayList list = new ArrayList (); final String whereClause = COLUMNNAME_PP_Order_BOMLine_ID+"=?";
String sql = "SELECT * FROM PP_Order_BOMLineMA WHERE PP_Order_BOMLine_ID=?"; List<MPPOrderBOMLineMA> list = new Query(ctx, Table_Name, whereClause, trxName)
PreparedStatement pstmt = null; .setParameters(new Object[]{PP_Order_BOMLine_ID})
try .setOrderBy(COLUMNNAME_PP_Order_BOMLineMA_ID)
{ .list();
pstmt = DB.prepareStatement (sql, trxName); return list.toArray(new MPPOrderBOMLineMA[list.size()]);
pstmt.setInt (1, PP_Order_BOMLine_ID);
ResultSet rs = pstmt.executeQuery ();
while (rs.next ())
{
list.add (new MPPOrderBOMLineMA (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;
}
MPPOrderBOMLineMA[] retValue = new MPPOrderBOMLineMA[list.size ()];
list.toArray (retValue);
return retValue;
} // get
/** /**
* Delete all Material Allocation for InOut * Delete all Material Allocation for PP order component
* @param M_InOut_ID shipment * @param PP_Order_BOMLine_ID PP order component line
* @return number of rows deleted or -1 for error * @return number of rows deleted
*/ */
public static int deleteOrderBOMLineMA (int PP_Order_BOMLine_ID, String trxName) public static int deleteOrderBOMLineMA (int PP_Order_BOMLine_ID, String trxName)
{ {
String sql = "DELETE FROM PP_Order_BOMLineMA ma WHERE EXISTS " final String sql = "DELETE FROM "+Table_Name+" WHERE "+COLUMNNAME_PP_Order_BOMLine_ID+"=?";
+ "(SELECT * FROM PP_Order_BOMLine l WHERE l.PP_Order_BOMLine_ID=ma.PP_Order_BOMLine_ID" int no = DB.executeUpdateEx(sql, new Object[]{PP_Order_BOMLine_ID}, trxName);
+ " AND PP_Order_BOMLine_ID=" + PP_Order_BOMLine_ID + ")";
return DB.executeUpdate(sql, trxName); s_log.config("Delete old #" + no);
} // deleteInOutMA return no;
}
/** Logger */ /** Logger */
private static CLogger s_log = CLogger.getCLogger (MPPOrderBOMLineMA.class); private static CLogger s_log = CLogger.getCLogger (MPPOrderBOMLineMA.class);
/************************************************************************** /**
* Standard Constructor * Standard Constructor
* @param ctx context * @param ctx context
* @param M_InOutLineMA_ID ignored * @param M_InOutLineMA_ID ignored

View File

@ -434,7 +434,7 @@ public class MPPOrderNode extends X_PP_Order_Node
* User String Representation * User String Representation
* @return info * @return info
*/ */
public String toStringX () public String toStringX()
{ {
StringBuffer sb = new StringBuffer ("MPPOrderNode["); StringBuffer sb = new StringBuffer ("MPPOrderNode[");
sb.append(getName()) sb.append(getName())
@ -443,11 +443,6 @@ public class MPPOrderNode extends X_PP_Order_Node
return sb.toString (); return sb.toString ();
} // toStringX } // toStringX
/**
* Before Save
* @param newRecord new
* @return true if can be saved
*/
@Override @Override
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
@ -537,4 +532,16 @@ public class MPPOrderNode extends X_PP_Order_Node
return true; return true;
} // beforeSave } // beforeSave
/**
* @return true if this is last node
*/
public static boolean isLastNode(Properties ctx, int PP_Order_Node_ID, String trxName)
{
String whereClause = MPPOrderNodeNext.COLUMNNAME_PP_Order_Node_ID+"=?";
return false == new Query(ctx, MPPOrderNodeNext.Table_Name, whereClause, trxName)
.setOnlyActiveRecords(true)
.setParameters(new Object[]{PP_Order_Node_ID})
.match();
}
} // M_WFNext } // M_WFNext