Applying Teo Sarca's [FR 1981760 ] Improve query Class

Set in MOrder.java and resolve dependencies.
Tested by creating a new POS Sales Order, complete it, reactivate it, set to Std Order, complete it;
Generate Shipments (manual) - OK
Generate Invoices (manaul) - OK

detected same dependency in eevolution.process.MovementGenerate.java
This commit is contained in:
Redhuan D. Oon 2008-09-03 07:18:45 +00:00
parent ae89db1d1e
commit ca1549c465
3 changed files with 3767 additions and 3785 deletions

View File

@ -22,6 +22,7 @@ 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 java.util.regex.Pattern;
@ -32,6 +33,8 @@ import org.compiere.process.DocumentEngine;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.eevolution.model.MDDOrderLine;
import org.eevolution.model.MPPProductBOMLine;
import org.eevolution.model.MPPProductBOM;
@ -605,39 +608,18 @@ public class MOrder extends X_C_Order implements DocAction
*/
public MOrderLine[] getLines (String whereClause, String orderClause)
{
ArrayList<MOrderLine> list = new ArrayList<MOrderLine> ();
StringBuffer sql = new StringBuffer("SELECT * FROM C_OrderLine WHERE C_Order_ID=? ");
if (whereClause != null)
sql.append(whereClause);
if (orderClause != null)
sql.append(" ").append(orderClause);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
pstmt.setInt(1, getC_Order_ID());
rs = pstmt.executeQuery();
while (rs.next())
{
MOrderLine ol = new MOrderLine(getCtx(), rs, get_TrxName());
ol.setHeaderInfo (this);
list.add(ol);
}
}
catch (Exception e)
{
log.log(Level.SEVERE, sql.toString(), e);
}
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
//red1 - using new Query class from Teo / Victor's MDDOrder.java implementation
StringBuffer whereClauseFinal = new StringBuffer("C_Order_ID =?");
if (!Util.isEmpty(whereClause, true))
whereClauseFinal.append(whereClause);
if (orderClause.length() == 0)
orderClause = "Line";
//
MOrderLine[] lines = new MOrderLine[list.size ()];
list.toArray (lines);
return lines;
List<MOrderLine> list = new Query(getCtx(), MOrderLine.Table_Name, whereClauseFinal.toString(), get_TrxName())
.setParameters(new Object[]{getC_Order_ID()})
.setOrderBy(orderClause)
.list();
return list.toArray(new MOrderLine[list.size()]);
} // getLines
/**
@ -653,7 +635,7 @@ public class MOrder extends X_C_Order implements DocAction
return m_lines;
}
//
String orderClause = "ORDER BY ";
String orderClause = "";
if (orderBy != null && orderBy.length() > 0)
orderClause += orderBy;
else
@ -1338,7 +1320,7 @@ public class MOrder extends X_C_Order implements DocAction
renumberLines (1000); // max 999 bom items
// Order Lines with non-stocked BOMs
MOrderLine[] lines = getLines (where, "ORDER BY Line");
MOrderLine[] lines = getLines (where, " Line");
for (int i = 0; i < lines.length; i++)
{
MOrderLine line = lines[i];

View File

@ -230,7 +230,7 @@ public class InOutGenerate extends SvrProcess
+ " INNER JOIN M_InOut io ON (iol.M_InOut_ID=io.M_InOut_ID) "
+ "WHERE iol.C_OrderLine_ID=C_OrderLine.C_OrderLine_ID AND io.DocStatus IN ('IP','WC'))";
// Deadlock Prevention - Order by M_Product_ID
MOrderLine[] lines = order.getLines (where, "ORDER BY C_BPartner_Location_ID, M_Product_ID");
MOrderLine[] lines = order.getLines (where, "C_BPartner_Location_ID, M_Product_ID");
for (int i = 0; i < lines.length; i++)
{
MOrderLine line = lines[i];

View File

@ -233,7 +233,7 @@ public class MovementGenerate extends SvrProcess
+ " INNER JOIN M_Movement io ON (iol.M_Movement_ID=io.M_Movement_ID) "
+ "WHERE iol.DD_OrderLine_ID=DD_OrderLine.DD_OrderLine_ID AND io.DocStatus IN ('IP','WC'))";
// Deadlock Prevention - Order by M_Product_ID
MDDOrderLine[] lines = order.getLines (where, "ORDER BY M_Product_ID");
MDDOrderLine[] lines = order.getLines (where, "M_Product_ID");
for (int i = 0; i < lines.length; i++)
{
MDDOrderLine line = lines[i];