parent
ed095deea5
commit
0544b26115
|
@ -16,12 +16,19 @@
|
|||
//package org.compiere.mfg.model;
|
||||
package org.eevolution.model;
|
||||
|
||||
import java.util.*;
|
||||
import java.sql.*;
|
||||
import java.util.logging.*;
|
||||
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 org.compiere.util.*;
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.PO;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Order Model.
|
||||
|
@ -36,7 +43,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
{
|
||||
|
||||
|
||||
private static CLogger log = CLogger.getCLogger(MPPProductBOM.class);
|
||||
private static CLogger log = CLogger.getCLogger(MPPProductBOM.class);
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
|
@ -150,42 +157,42 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* BUG #104
|
||||
* @param lines
|
||||
*/
|
||||
/**
|
||||
* BUG #104
|
||||
* @param lines
|
||||
*/
|
||||
|
||||
List lines = null;
|
||||
|
||||
public void setLines(List lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
public void setLines(List lines) {
|
||||
this.lines = lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* BUG #? - Does not persist objects!
|
||||
* @param ctx
|
||||
* @param from
|
||||
* @param copyLines
|
||||
* @return
|
||||
*/
|
||||
public static MPPProductBOM copyFrom(Properties ctx, MPPProductBOM from, boolean copyLines) {
|
||||
MPPProductBOM newBom = new MPPProductBOM(ctx, 0,null);
|
||||
PO.copyValues(from, newBom, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
|
||||
newBom.setDocumentNo(null);
|
||||
* BUG #? - Does not persist objects!
|
||||
* @param ctx
|
||||
* @param from
|
||||
* @param copyLines
|
||||
* @return
|
||||
*/
|
||||
public static MPPProductBOM copyFrom(Properties ctx, MPPProductBOM from, boolean copyLines) {
|
||||
MPPProductBOM newBom = new MPPProductBOM(ctx, 0,null);
|
||||
PO.copyValues(from, newBom, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
|
||||
newBom.setDocumentNo(null);
|
||||
|
||||
if (copyLines) {
|
||||
List newLines = new ArrayList();
|
||||
MPPProductBOMLine[] fromLines = from.getLines();
|
||||
for (int i = 0; i < fromLines.length; i++) {
|
||||
MPPProductBOMLine line = new MPPProductBOMLine(ctx, 0,null);
|
||||
PO.copyValues(fromLines[i], line, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
|
||||
newLines.add(line);
|
||||
}
|
||||
newBom.setLines(newLines);
|
||||
}
|
||||
if (copyLines) {
|
||||
List newLines = new ArrayList();
|
||||
MPPProductBOMLine[] fromLines = from.getLines();
|
||||
for (int i = 0; i < fromLines.length; i++) {
|
||||
MPPProductBOMLine line = new MPPProductBOMLine(ctx, 0,null);
|
||||
PO.copyValues(fromLines[i], line, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
|
||||
newLines.add(line);
|
||||
}
|
||||
newBom.setLines(newLines);
|
||||
}
|
||||
|
||||
return newBom;
|
||||
}
|
||||
return newBom;
|
||||
}
|
||||
|
||||
/**
|
||||
* String Representation
|
||||
|
@ -194,8 +201,8 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
public String toString ()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("MPP_ProductBOM[")
|
||||
.append(get_ID()).append("-").append(getDocumentNo())
|
||||
.append ("]");
|
||||
.append(get_ID()).append("-").append(getDocumentNo())
|
||||
.append ("]");
|
||||
return sb.toString ();
|
||||
} // toString
|
||||
|
||||
|
@ -327,56 +334,56 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
public MPPProductBOMLine[] getLines (int pp_product_bom_id , Timestamp valid)
|
||||
{
|
||||
|
||||
ArrayList<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine> ();
|
||||
StringBuffer sql = new StringBuffer("SELECT * FROM PP_Product_BOMLine WHERE PP_Product_BOM_ID=? ");
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||
pstmt.setInt(1, pp_product_bom_id);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
MPPProductBOMLine bl = new MPPProductBOMLine(getCtx(), rs, get_TrxName());
|
||||
boolean ValidFromBOMLine = true;
|
||||
boolean ValidToBOMLine = true;
|
||||
if (bl.getValidFrom() != null)
|
||||
{
|
||||
ValidFromBOMLine = valid.compareTo(bl.getValidFrom()) >= 0 ? true : false;
|
||||
}
|
||||
ArrayList<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine> ();
|
||||
StringBuffer sql = new StringBuffer("SELECT * FROM PP_Product_BOMLine WHERE PP_Product_BOM_ID=? ");
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||
pstmt.setInt(1, pp_product_bom_id);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
MPPProductBOMLine bl = new MPPProductBOMLine(getCtx(), rs, get_TrxName());
|
||||
boolean ValidFromBOMLine = true;
|
||||
boolean ValidToBOMLine = true;
|
||||
if (bl.getValidFrom() != null)
|
||||
{
|
||||
ValidFromBOMLine = valid.compareTo(bl.getValidFrom()) >= 0 ? true : false;
|
||||
}
|
||||
|
||||
if (bl.getValidTo() != null )
|
||||
{
|
||||
ValidToBOMLine = valid.compareTo(bl.getValidTo()) <= 0 ? true : false;
|
||||
}
|
||||
if(ValidFromBOMLine && ValidToBOMLine)
|
||||
{
|
||||
list.add(bl);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
pstmt = null;
|
||||
}
|
||||
//
|
||||
MPPProductBOMLine[] lines = new MPPProductBOMLine[list.size ()];
|
||||
list.toArray (lines);
|
||||
return lines;
|
||||
if (bl.getValidTo() != null )
|
||||
{
|
||||
ValidToBOMLine = valid.compareTo(bl.getValidTo()) <= 0 ? true : false;
|
||||
}
|
||||
if(ValidFromBOMLine && ValidToBOMLine)
|
||||
{
|
||||
list.add(bl);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
pstmt = null;
|
||||
}
|
||||
//
|
||||
MPPProductBOMLine[] lines = new MPPProductBOMLine[list.size ()];
|
||||
list.toArray (lines);
|
||||
return lines;
|
||||
|
||||
} // getLines
|
||||
|
||||
|
@ -385,47 +392,47 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
* @param pp_product_bom_id BOM ID
|
||||
* @return BOM Lines
|
||||
*/
|
||||
public MPPProductBOMLine[] getLines (int PP_Product_BOM_ID)
|
||||
{
|
||||
public MPPProductBOMLine[] getLines (int PP_Product_BOM_ID)
|
||||
{
|
||||
|
||||
ArrayList<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine> ();
|
||||
StringBuffer sql = new StringBuffer("SELECT * FROM PP_Product_BOMLine WHERE PP_Product_BOM_ID=? ");
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||
pstmt.setInt(1, PP_Product_BOM_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
MPPProductBOMLine bl = new MPPProductBOMLine(getCtx(), rs, get_TrxName());
|
||||
list.add(bl);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
pstmt = null;
|
||||
}
|
||||
ArrayList<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine> ();
|
||||
StringBuffer sql = new StringBuffer("SELECT * FROM PP_Product_BOMLine WHERE PP_Product_BOM_ID=? ");
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
|
||||
pstmt.setInt(1, PP_Product_BOM_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
MPPProductBOMLine bl = new MPPProductBOMLine(getCtx(), rs, get_TrxName());
|
||||
list.add(bl);
|
||||
}
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
pstmt = null;
|
||||
}
|
||||
|
||||
MPPProductBOMLine[] lines = new MPPProductBOMLine[list.size ()];
|
||||
list.toArray (lines);
|
||||
return lines;
|
||||
MPPProductBOMLine[] lines = new MPPProductBOMLine[list.size ()];
|
||||
list.toArray (lines);
|
||||
return lines;
|
||||
|
||||
} // getLines
|
||||
} // getLines
|
||||
|
||||
|
||||
|
||||
|
@ -483,18 +490,18 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
return to;
|
||||
} // copyFrom
|
||||
|
||||
public static int getBOMSearchKey(int M_Product_ID)
|
||||
{
|
||||
public static int getBOMSearchKey(int M_Product_ID)
|
||||
{
|
||||
|
||||
int PP_Product_BOM_ID = 0;
|
||||
int AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
|
||||
int PP_Product_BOM_ID = 0;
|
||||
int AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
|
||||
|
||||
MProduct product = new MProduct(Env.getCtx(), M_Product_ID, "M_Product");
|
||||
String sql = "SELECT pb.PP_Product_BOM_ID FROM PP_Product_BOM pb WHERE pb.Value = ? AND pb.AD_Client_ID = ?";
|
||||
MProduct product = new MProduct(Env.getCtx(), M_Product_ID, "M_Product");
|
||||
String sql = "SELECT pb.PP_Product_BOM_ID FROM PP_Product_BOM pb WHERE pb.Value = ? AND pb.AD_Client_ID = ?";
|
||||
|
||||
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql);
|
||||
|
@ -526,7 +533,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
pstmt = null;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // MPP_ProductBOM
|
||||
|
|
Loading…
Reference in New Issue