* [ 1795685 ] Don't populate readonly lookup

This commit is contained in:
Heng Sin Low 2007-09-16 08:45:50 +00:00
parent 01275897b7
commit 8db5615d78
1 changed files with 21 additions and 11 deletions

View File

@ -65,10 +65,10 @@ public final class MLookup extends Lookup implements Serializable
return; // required when parent needs to be selected (e.g. price from product) return; // required when parent needs to be selected (e.g. price from product)
} }
// //
m_loader = new MLoader(); //m_loader = new MLoader();
// if (TabNo != 0) // if (TabNo != 0)
// m_loader.setPriority(Thread.NORM_PRIORITY - 1); // m_loader.setPriority(Thread.NORM_PRIORITY - 1);
m_loader.start(); //m_loader.start();
//m_loader.run(); // test sync call //m_loader.run(); // test sync call
} // MLookup } // MLookup
@ -154,12 +154,16 @@ public final class MLookup extends Lookup implements Serializable
if (key == null || MINUS_ONE.equals(key)) // indicator for null if (key == null || MINUS_ONE.equals(key)) // indicator for null
return null; return null;
if (m_info.IsParent && m_nextRead < System.currentTimeMillis()) //auto refresh parent lookup
if (m_info.IsParent )
{
if (m_nextRead > 0 && m_nextRead < System.currentTimeMillis())
{ {
m_lookup.clear(); m_lookup.clear();
if (m_lookupDirect != null) if (m_lookupDirect != null)
m_lookupDirect.clear(); m_lookupDirect.clear();
m_nextRead = System.currentTimeMillis() + 500; // 1/2 sec }
m_nextRead = System.currentTimeMillis() + 5000; // 5 sec
} }
// try cache // try cache
@ -179,6 +183,7 @@ public final class MLookup extends Lookup implements Serializable
} }
// Always check for parents - not if we SQL was validated and completely loaded // Always check for parents - not if we SQL was validated and completely loaded
/*
if (!m_info.IsParent && m_info.IsValidated && m_allLoaded) if (!m_info.IsParent && m_info.IsValidated && m_allLoaded)
{ {
log.finer(m_info.KeyColumn + ": <NULL> - " + key // + "(" + key.getClass() log.finer(m_info.KeyColumn + ": <NULL> - " + key // + "(" + key.getClass()
@ -186,12 +191,13 @@ public final class MLookup extends Lookup implements Serializable
// log.finest( m_lookup.keySet().toString(), "ContainsKey = " + m_lookup.containsKey(key)); // log.finest( m_lookup.keySet().toString(), "ContainsKey = " + m_lookup.containsKey(key));
// also for new values and inactive ones // also for new values and inactive ones
return getDirect(key, false, true); // cache locally return getDirect(key, false, true); // cache locally
} }*/
log.finest (m_info.KeyColumn + ": " + key log.finest (m_info.KeyColumn + ": " + key
+ "; Size=" + m_lookup.size() + "; Validated=" + m_info.IsValidated + "; Size=" + m_lookup.size() + "; Validated=" + m_info.IsValidated
+ "; All Loaded=" + m_allLoaded + "; HasInactive=" + m_hasInactive); + "; All Loaded=" + m_allLoaded + "; HasInactive=" + m_hasInactive);
// never loaded // never loaded
/*
if (!m_allLoaded if (!m_allLoaded
&& m_lookup.size() == 0 && m_lookup.size() == 0
&& !m_info.IsCreadedUpdatedBy && !m_info.IsCreadedUpdatedBy
@ -203,7 +209,7 @@ public final class MLookup extends Lookup implements Serializable
retValue = (NamePair)m_lookup.get(key); retValue = (NamePair)m_lookup.get(key);
if (retValue != null) if (retValue != null)
return retValue; return retValue;
} }*/
// Try to get it directly // Try to get it directly
boolean cacheLocal = m_info.IsValidated ; boolean cacheLocal = m_info.IsValidated ;
return getDirect(key, false, cacheLocal); // do NOT cache return getDirect(key, false, cacheLocal); // do NOT cache
@ -558,7 +564,11 @@ public final class MLookup extends Lookup implements Serializable
// Don't load Search or CreatedBy/UpdatedBy // Don't load Search or CreatedBy/UpdatedBy
if (m_info.DisplayType == DisplayType.Search if (m_info.DisplayType == DisplayType.Search
|| m_info.IsCreadedUpdatedBy) || m_info.IsCreadedUpdatedBy)
{
//clear direct cache
removeAllElements();
return 0; return 0;
}
m_refreshing = true; m_refreshing = true;
//force refresh //force refresh