MRPUpdate: simplified code - don't need to use Trx class
This commit is contained in:
parent
bfa9f334b2
commit
539e4035fd
|
@ -18,7 +18,6 @@
|
||||||
package org.eevolution.process;
|
package org.eevolution.process;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -37,7 +36,6 @@ import org.compiere.process.SvrProcess;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.Trx;
|
|
||||||
import org.eevolution.model.MForecastLine;
|
import org.eevolution.model.MForecastLine;
|
||||||
import org.eevolution.model.MPPMRP;
|
import org.eevolution.model.MPPMRP;
|
||||||
import org.eevolution.model.MPPOrder;
|
import org.eevolution.model.MPPOrder;
|
||||||
|
@ -303,55 +301,38 @@ public class MRPUpdate extends SvrProcess
|
||||||
|
|
||||||
private void executeUpdate(String sql, List<Object> params)
|
private void executeUpdate(String sql, List<Object> params)
|
||||||
{
|
{
|
||||||
Trx trx = Trx.get(Trx.createTrxName("Update MRP"), true);
|
|
||||||
Object[] pa = null;
|
Object[] pa = null;
|
||||||
if (params != null)
|
if (params != null)
|
||||||
pa = params.toArray(new Object[params.size()]);
|
|
||||||
else
|
|
||||||
pa = new Object[]{};
|
|
||||||
|
|
||||||
boolean success = false;
|
|
||||||
|
|
||||||
if ( DB.executeUpdateEx(sql, pa, trx.getTrxName()) < 0 )
|
|
||||||
{
|
{
|
||||||
|
pa = params.toArray(new Object[params.size()]);
|
||||||
success = false;
|
}
|
||||||
trx.rollback();
|
else
|
||||||
|
{
|
||||||
|
pa = new Object[]{};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success)
|
int no = DB.executeUpdateEx(sql, pa, get_TrxName());
|
||||||
trx.commit();
|
commit();
|
||||||
else
|
log.fine("#"+no+" -- "+sql);
|
||||||
trx.rollback();
|
|
||||||
|
|
||||||
trx.close();
|
|
||||||
trx = null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void deletePO(String tableName, String whereClause, List<Object> params)
|
private void deletePO(String tableName, String whereClause, List<Object> params)
|
||||||
{
|
{
|
||||||
// TODO: refactor this method and move it to org.compiere.model.Query class
|
// TODO: refactor this method and move it to org.compiere.model.Query class
|
||||||
|
|
||||||
POResultSet<PO> rs = new Query(getCtx(), tableName, whereClause, get_TrxName())
|
POResultSet<PO> rs = new Query(getCtx(), tableName, whereClause, get_TrxName())
|
||||||
.setParameters(params)
|
.setParameters(params)
|
||||||
.scroll();
|
.scroll();
|
||||||
try {
|
try
|
||||||
while(rs.hasNext()) {
|
{
|
||||||
Trx trx = Trx.get(Trx.createTrxName("Delete MRP"), true);
|
while(rs.hasNext())
|
||||||
if(rs.next().delete(true))
|
{
|
||||||
trx.commit();
|
rs.next().deleteEx(true);
|
||||||
else
|
commit();
|
||||||
trx.rollback();
|
|
||||||
|
|
||||||
trx.close();
|
|
||||||
trx = null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
finally
|
||||||
|
{
|
||||||
rs.close();
|
rs.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue