* [ 1659623 ] MLookups & ValidationCode are not working
* Added lookupinfo cache for lookup type of tabledir
This commit is contained in:
parent
17cc72634e
commit
cf40117547
|
@ -341,10 +341,13 @@ public final class MLookup extends Lookup implements Serializable
|
|||
refresh (loadParent);
|
||||
|
||||
// already validation included
|
||||
if (m_info.IsValidated)
|
||||
//if (m_info.IsValidated)
|
||||
boolean validated = this.isValidated(m_info);
|
||||
if (validated)
|
||||
return new ArrayList<Object>(m_lookup.values());
|
||||
|
||||
if (!m_info.IsValidated && onlyValidated)
|
||||
//if (!m_info.IsValidated && onlyValidated)
|
||||
if (!validated && onlyValidated)
|
||||
{
|
||||
refresh (loadParent);
|
||||
log.fine(m_info.KeyColumn + ": Validated - #" + m_lookup.size());
|
||||
|
@ -576,6 +579,15 @@ public final class MLookup extends Lookup implements Serializable
|
|||
m_lookupDirect.clear();
|
||||
} // removeAllElements
|
||||
|
||||
private boolean isValidated(MLookupInfo info)
|
||||
{
|
||||
if (info.IsValidated) return true;
|
||||
if (info.ValidationCode.length() == 0) return true;
|
||||
String validation = Env.parseContext(m_info.ctx, m_info.WindowNo, m_info.ValidationCode, false);
|
||||
if (validation.equals(info.parsedValidationCode)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* MLookup Loader
|
||||
*/
|
||||
|
@ -613,6 +625,7 @@ public final class MLookup extends Lookup implements Serializable
|
|||
}
|
||||
else
|
||||
{
|
||||
m_info.parsedValidationCode = validation;
|
||||
log.fine(m_info.KeyColumn + ": Loader Validated: " + validation);
|
||||
int posFrom = sql.lastIndexOf(" FROM ");
|
||||
boolean hasWhere = sql.indexOf(" WHERE ", posFrom) != -1;
|
||||
|
|
|
@ -216,18 +216,22 @@ public class MLookupFactory
|
|||
+ (hasWhere ? " AND " : " WHERE ") + info.KeyColumn + "=?";
|
||||
|
||||
// Validation
|
||||
String local_validationCode = "";
|
||||
//String local_validationCode = "";
|
||||
if (info.ValidationCode.length() == 0)
|
||||
info.IsValidated = true;
|
||||
|
||||
else
|
||||
{
|
||||
/*
|
||||
local_validationCode = Env.parseContext (ctx, WindowNo, info.ValidationCode, true);
|
||||
if (local_validationCode.length() == 0) // returns "" if not all variables were parsed
|
||||
info.IsValidated = false;
|
||||
else
|
||||
info.IsValidated = true;
|
||||
*/
|
||||
info.IsValidated = false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Add Local Validation
|
||||
if (local_validationCode.length() != 0)
|
||||
{
|
||||
|
@ -239,7 +243,7 @@ public class MLookupFactory
|
|||
else
|
||||
info.Query = info.Query
|
||||
+ (hasWhere ? " AND " : " WHERE ") + local_validationCode;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Add Security
|
||||
if (needToAddSecurity)
|
||||
|
@ -554,10 +558,16 @@ public class MLookupFactory
|
|||
ColumnName = "AD_Org_ID";
|
||||
|
||||
String TableName = ColumnName.substring(0,ColumnName.length()-3);
|
||||
String KeyColumn = ColumnName;
|
||||
boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
||||
int ZoomWindow = 0;
|
||||
int ZoomWindowPO = 0;
|
||||
|
||||
//try cache
|
||||
String cacheKey = TableName + "." + KeyColumn;
|
||||
if (s_cacheRefTable.containsKey(cacheKey))
|
||||
return s_cacheRefTable.get(cacheKey).cloneIt();
|
||||
|
||||
// get display column names
|
||||
String sql0 = "SELECT c.ColumnName,c.IsTranslated,c.AD_Reference_ID,"
|
||||
+ "c.AD_Reference_Value_ID,t.AD_Window_ID,t.PO_Window_ID "
|
||||
|
@ -567,8 +577,6 @@ public class MLookupFactory
|
|||
+ " AND c.IsIdentifier='Y' "
|
||||
+ "ORDER BY c.SeqNo";
|
||||
//
|
||||
String KeyColumn = ColumnName;
|
||||
//
|
||||
ArrayList<LookupDisplayColumn> list = new ArrayList<LookupDisplayColumn>();
|
||||
boolean isTranslated = false;
|
||||
//
|
||||
|
@ -674,6 +682,7 @@ public class MLookupFactory
|
|||
s_log.fine("ColumnName=" + ColumnName + " - " + realSQL);
|
||||
MLookupInfo lInfo = new MLookupInfo(realSQL.toString(), TableName,
|
||||
TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery);
|
||||
s_cacheRefTable.put(cacheKey, lInfo.cloneIt());
|
||||
return lInfo;
|
||||
} // getLookup_TableDir
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ public class MLookupInfo implements Serializable, Cloneable
|
|||
/** CreadedBy?updatedBy */
|
||||
public boolean IsCreadedUpdatedBy = false;
|
||||
|
||||
public String parsedValidationCode = "";
|
||||
|
||||
/**
|
||||
* String representation
|
||||
|
|
Loading…
Reference in New Issue