1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.sql.*; 18 import java.io.Serializable ; 19 20 import org.compiere.util.*; 21 22 28 public final class MLookupInfo implements Serializable  29 { 30 39 public MLookupInfo (String sqlQuery, String tableName, String keyColumn, int zoomWindow, int zoomWindowPO, 40 MQuery zoomQuery) 41 { 42 if (sqlQuery == null) 43 throw new IllegalArgumentException ("MLookupInfo - sqlQuery is null"); 44 Query = sqlQuery; 45 if (keyColumn == null) 46 throw new IllegalArgumentException ("MLookupInfo - keyColumn is null"); 47 TableName = tableName; 48 KeyColumn = keyColumn; 49 ZoomWindow = zoomWindow; 50 ZoomWindowPO = zoomWindowPO; 51 ZoomQuery = zoomQuery; 52 } 54 55 public String Query = null; 56 57 public String TableName = ""; 58 59 public String KeyColumn = ""; 60 61 public int ZoomWindow; 62 63 public int ZoomWindowPO; 64 65 public MQuery ZoomQuery = null; 66 67 68 public String QueryDirect = ""; 69 70 public boolean IsParent = false; 71 72 public String ValidationCode = ""; 73 74 public boolean IsValidated = true; 75 76 public Properties ctx = null; 77 public int WindowNo; 78 79 80 public int Column_ID; 81 82 public int DisplayType; 83 84 public int AD_Reference_Value_ID; 85 86 90 public String toString() 91 { 92 StringBuffer sb = new StringBuffer ("MLookupInfo[") 93 .append(KeyColumn).append(" - Direct=").append(QueryDirect) 94 .append("]"); 95 return sb.toString(); 96 } 98 99 100 107 public static int getAD_Reference_ID (String referenceName) 108 { 109 int retValue = 0; 110 String sql = "SELECT AD_Reference_ID,Name,ValidationType,IsActive " 111 + "FROM AD_Reference WHERE Name LIKE ?"; 112 try 113 { 114 PreparedStatement pstmt = DB.prepareStatement(sql); 115 pstmt.setString(1, referenceName); 116 ResultSet rs = pstmt.executeQuery(); 117 int i = 0; 119 int id = 0; 120 String refName = ""; 121 String validationType = ""; 122 boolean isActive = false; 123 while (rs.next()) 124 { 125 id = rs.getInt(1); 126 if (i == 0) 127 retValue = id; 128 refName = rs.getString(2); 129 validationType = rs.getString(3); 130 isActive = rs.getString(4).equals("Y"); 131 Log.trace(Log.l3_Util, "AD_Reference Name=" + refName + ", ID=" + id + ", Type=" + validationType + ", Active=" + isActive); 132 } 133 rs.close(); 134 pstmt.close(); 135 } 136 catch (SQLException e) 137 { 138 Log.error("MLookupInfo.getAD_Reference_ID", e); 139 } 140 return retValue; 141 } 143 150 public static int getAD_Column_ID (String columnName) 151 { 152 int retValue = 0; 153 String sql = "SELECT c.AD_Column_ID,c.ColumnName,t.TableName " 154 + "FROM AD_Column c, AD_Table t " 155 + "WHERE c.ColumnName LIKE ? AND c.AD_Table_ID=t.AD_Table_ID"; 156 try 157 { 158 PreparedStatement pstmt = DB.prepareStatement(sql); 159 pstmt.setString(1, columnName); 160 ResultSet rs = pstmt.executeQuery(); 161 int i = 0; 163 int id = 0; 164 String colName = ""; 165 String tabName = ""; 166 while (rs.next()) 167 { 168 id = rs.getInt(1); 169 if (i == 0) 170 retValue = id; 171 colName = rs.getString(2); 172 tabName = rs.getString(3); 173 Log.trace(Log.l3_Util, "AD_Column Name=" + colName + ", ID=" + id + ", Table=" + tabName); 174 } 175 rs.close(); 176 pstmt.close(); 177 } 178 catch (SQLException e) 179 { 180 Log.error("MLookupInfo.getAD_Column_ID", e); 181 } 182 return retValue; 183 } 185 } | Popular Tags |