BF1874419 JDBC Statement not close in a finally block
+ Fix indentation and format
This commit is contained in:
parent
d6dbceefbe
commit
70d98a06ef
|
|
@ -16,15 +16,16 @@
|
|||
|
||||
package org.eevolution.process;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.logging.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
import org.compiere.model.*;
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.model.MWarehouse;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.eevolution.model.MPPProductPlanning;
|
||||
|
||||
/**
|
||||
|
|
@ -59,51 +60,38 @@ public class CreateProductPlanning extends SvrProcess
|
|||
private int m_AD_Org_ID = 0;
|
||||
private int m_AD_Client_ID = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prepare - e.g., get Parameters.
|
||||
*/
|
||||
protected void prepare()
|
||||
{
|
||||
m_AD_Client_ID = Env.getAD_Client_ID(getCtx());
|
||||
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
else if (name.equals("M_Product_Category_ID"))
|
||||
{
|
||||
p_M_Product_Category_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("M_Warehouse_ID"))
|
||||
{
|
||||
p_M_Warehouse_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("S_Resource_ID"))
|
||||
{
|
||||
p_S_Resource_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("IsCreatePlan"))
|
||||
{
|
||||
p_CreatePlan = "Y".equals((String)para[i].getParameter());
|
||||
|
||||
}
|
||||
else if (name.equals("IsMPS"))
|
||||
{
|
||||
p_MPS = "Y".equals((String)para[i].getParameter());
|
||||
|
||||
}
|
||||
else if (name.equals("DD_NetworkDistribution_ID"))
|
||||
{
|
||||
|
|
@ -112,13 +100,11 @@ public class CreateProductPlanning extends SvrProcess
|
|||
else if (name.equals("AD_Workflow_ID"))
|
||||
{
|
||||
p_AD_Workflow_ID = ((BigDecimal)para[i].getParameter()).intValue();
|
||||
|
||||
}
|
||||
else if (name.equals("TimeFence"))
|
||||
{
|
||||
p_TimeFence = ((BigDecimal)para[i].getParameter());
|
||||
}
|
||||
|
||||
else if (name.equals("TransfertTime"))
|
||||
{
|
||||
p_TransferTime = ((BigDecimal)para[i].getParameter());
|
||||
|
|
@ -171,23 +157,22 @@ public class CreateProductPlanning extends SvrProcess
|
|||
else
|
||||
log.log(Level.SEVERE,"prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
|
||||
if(p_M_Warehouse_ID > 0 )
|
||||
{
|
||||
MWarehouse w = MWarehouse.get(getCtx(), p_M_Warehouse_ID);
|
||||
m_AD_Org_ID = w.getAD_Org_ID();
|
||||
}
|
||||
|
||||
} // prepare
|
||||
|
||||
|
||||
/**********************
|
||||
/***************************************************************************
|
||||
* Create Data Planning record
|
||||
*/
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
String sql = null;
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
if (p_M_Product_Category_ID > 0 )
|
||||
sql = "SELECT p.M_Product_ID FROM M_Product p WHERE p.AD_Client_ID= ? AND p.M_Product_Category_ID = ? ";
|
||||
|
|
@ -201,13 +186,10 @@ public class CreateProductPlanning extends SvrProcess
|
|||
pstmt.setInt(1, m_AD_Client_ID);
|
||||
pstmt.setInt(2, p_M_Product_Category_ID);
|
||||
}
|
||||
else
|
||||
pstmt.setInt(1, m_AD_Client_ID);
|
||||
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
else pstmt.setInt(1, m_AD_Client_ID);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next())
|
||||
{
|
||||
|
||||
int M_Product_ID = rs.getInt(1);
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(),m_AD_Client_ID , m_AD_Org_ID , p_M_Warehouse_ID, p_S_Resource_ID,M_Product_ID, get_TrxName());
|
||||
// Create Product Data Planning
|
||||
|
|
@ -264,16 +246,17 @@ public class CreateProductPlanning extends SvrProcess
|
|||
pp.save();
|
||||
}
|
||||
}
|
||||
DB.close(rs);
|
||||
DB.close(pstmt);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE,"doIt - " + sql, e);
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null;
|
||||
pstmt = null;
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue