MRefList:

* getListDescription should be static
* javadoc fix
* imporve error logging
This commit is contained in:
teo_sarca 2008-12-05 14:01:20 +00:00
parent 592ee1be0a
commit e2bbd1f0cf
1 changed files with 28 additions and 30 deletions

View File

@ -39,6 +39,9 @@ import org.compiere.util.ValueNamePair;
*/
public class MRefList extends X_AD_Ref_List
{
private static final long serialVersionUID = 1L;
/**
* Get Reference List
* @param ctx context
@ -59,7 +62,7 @@ public class MRefList extends X_AD_Ref_List
* @param ctx context
* @param AD_Reference_ID reference
* @param Value value
* @return List or null
* @return List or ""
*/
public static String getListName (Properties ctx, int AD_Reference_ID, String Value)
{
@ -91,9 +94,10 @@ public class MRefList extends X_AD_Ref_List
}
catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql + " - " + key, ex);
s_log.log(Level.SEVERE, sql + " -- " + key, ex);
}
finally {
finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
@ -102,7 +106,7 @@ public class MRefList extends X_AD_Ref_List
if (retValue == null)
{
retValue = "";
s_log.warning("getListName - Not found " + key);
s_log.warning("Not found " + key);
}
s_cache.put(key, retValue);
//
@ -116,7 +120,7 @@ public class MRefList extends X_AD_Ref_List
* @param Value value
* @return List or null
*/
public String getListDescription (Properties ctx, String ListName, String Value)
public static String getListDescription (Properties ctx, String ListName, String Value)
{
String AD_Language = Env.getAD_Language(ctx);
String key = AD_Language + "_" + ListName + "_" + Value;
@ -133,16 +137,14 @@ public class MRefList extends X_AD_Ref_List
+ " INNER JOIN AD_Ref_List r ON (r.AD_Ref_List_ID=t.AD_Ref_List_ID) "
+ " WHERE b.Name=? AND a.Value=?"
+ " AND a.AD_Reference_ID = b.AD_Reference_ID AND t.AD_Language=?";
log.info (sql);
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql,null);
pstmt.setString (1, ListName);
pstmt.setString(2, Value);
ResultSet rs = pstmt.executeQuery ();
rs = pstmt.executeQuery ();
if (rs.next ())
retValue = rs.getString(1);
rs.close ();
@ -151,23 +153,19 @@ public class MRefList extends X_AD_Ref_List
}
catch (SQLException ex)
{
log.info("getListDescription - " + sql + " - " + key+ ex);
s_log.log(Level.SEVERE, sql + " -- " + key, ex);
}
try
finally
{
if (pstmt != null)
pstmt.close ();
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
catch (SQLException ex1)
{
}
pstmt = null;
// Save into Cache
if (retValue == null)
{
retValue = "";
log.info("getListDescription - Not found " + key);
s_log.info("getListDescription - Not found " + key);
}
s_cache.put(key, retValue);
//
@ -229,7 +227,7 @@ public class MRefList extends X_AD_Ref_List
/** Logger */
private static CLogger s_log = CLogger.getCLogger (MRefList.class);
/** Value Cache */
private static CCache<String,String> s_cache = new CCache<String,String>("AD_Ref_List", 20);
private static CCache<String,String> s_cache = new CCache<String,String>(Table_Name, 20);
/**************************************************************************