1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.sql.*; 18 19 import org.compiere.util.*; 20 21 27 public class MLot extends X_M_Lot 28 { 29 30 private static Logger s_log = Logger.getCLogger(MLot.class); 31 32 38 public static MLot[] getProductLots (Properties ctx, int M_Product_ID) 39 { 40 String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=?"; 41 ArrayList list = new ArrayList(); 42 PreparedStatement pstmt = null; 43 try 44 { 45 pstmt = DB.prepareStatement (sql); 46 pstmt.setInt (1, M_Product_ID); 47 ResultSet rs = pstmt.executeQuery (); 48 while (rs.next ()) 49 list.add (new MLot (ctx, rs)); 50 rs.close (); 51 pstmt.close (); 52 pstmt = null; 53 } 54 catch (SQLException ex) 55 { 56 s_log.error ("getProductLots (MLot)", ex); 57 } 58 try 59 { 60 if (pstmt != null) 61 pstmt.close (); 62 } 63 catch (SQLException ex1) 64 { 65 } 66 pstmt = null; 67 MLot[] retValue = new MLot[list.size()]; 69 list.toArray(retValue); 70 return retValue; 71 } 73 78 public static KeyNamePair[] getProductLots (int M_Product_ID) 79 { 80 String sql = "SELECT M_Lot_ID, Name FROM M_Lot WHERE M_Product_ID=?"; 81 ArrayList list = new ArrayList(); 82 PreparedStatement pstmt = null; 83 try 84 { 85 pstmt = DB.prepareStatement (sql); 86 pstmt.setInt (1, M_Product_ID); 87 ResultSet rs = pstmt.executeQuery (); 88 while (rs.next ()) 89 list.add (new KeyNamePair (rs.getInt(1), rs.getString(2))); 90 rs.close (); 91 pstmt.close (); 92 pstmt = null; 93 } 94 catch (SQLException ex) 95 { 96 s_log.error ("getProductLots (KeyNamePair)", ex); 97 } 98 try 99 { 100 if (pstmt != null) 101 pstmt.close (); 102 } 103 catch (SQLException ex1) 104 { 105 } 106 pstmt = null; 107 KeyNamePair[] retValue = new KeyNamePair[list.size()]; 109 list.toArray(retValue); 110 return retValue; 111 } 113 114 115 120 public MLot (Properties ctx, int M_Lot_ID) 121 { 122 super (ctx, M_Lot_ID); 123 130 } 132 137 public MLot (Properties ctx, ResultSet rs) 138 { 139 super (ctx, rs); 140 } 142 148 public MLot (Properties ctx, int M_Product_ID, String Name) 149 { 150 this (ctx, 0); 151 setM_Product_ID (M_Product_ID); 152 setName (Name); 153 } 155 159 public String toString() 160 { 161 return getName(); 162 } 164 } | Popular Tags |