use of org.eevolution.model.X_T_BOMLine in project adempiere by adempiere.
the class PrintBOM method loadBOM.
/**
* Action: Fill Tree with all nodes
*/
private void loadBOM() throws Exception {
int count = 0;
if (p_M_Product_ID == 0)
raiseError("Error: ", "Product ID not found");
X_T_BOMLine tboml = new X_T_BOMLine(ctx, 0, null);
tboml.setPP_Product_BOM_ID(0);
tboml.setPP_Product_BOMLine_ID(0);
tboml.setM_Product_ID(p_M_Product_ID);
tboml.setSel_Product_ID(p_M_Product_ID);
tboml.setImplosion(p_implosion);
tboml.setLevelNo(0);
tboml.setLevels("0");
tboml.setSeqNo(0);
tboml.setAD_PInstance_ID(AD_PInstance_ID);
tboml.save();
if (p_implosion) {
PreparedStatement stmt = null;
ResultSet rs = null;
String sql = "SELECT PP_Product_BOMLine_ID FROM PP_Product_BOMLine " + "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
try {
stmt = DB.prepareStatement(sql, get_TrxName());
stmt.setInt(1, p_M_Product_ID);
rs = stmt.executeQuery();
while (rs.next()) {
parentImplotion(rs.getInt(1));
++count;
}
if (count == 0)
raiseError("Error: ", "Product is not a component");
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
throw new Exception("SQLException: " + e.getLocalizedMessage());
} finally {
DB.close(rs, stmt);
rs = null;
stmt = null;
}
} else {
PreparedStatement stmt = null;
ResultSet rs = null;
String sql = "SELECT PP_Product_BOM_ID FROM PP_Product_BOM " + "WHERE IsActive = 'Y' AND M_Product_ID = ? ";
try {
stmt = DB.prepareStatement(sql, get_TrxName());
stmt.setInt(1, p_M_Product_ID);
rs = stmt.executeQuery();
while (rs.next()) {
parentExplotion(rs.getInt(1));
++count;
}
if (count == 0)
raiseError("Error: ", "Product is not a BOM");
} catch (SQLException e) {
log.log(Level.SEVERE, e.getLocalizedMessage() + sql, e);
throw new Exception("SQLException: " + e.getLocalizedMessage());
} finally {
DB.close(rs, stmt);
rs = null;
stmt = null;
}
}
}
Aggregations