* [ 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);
|
refresh (loadParent);
|
||||||
|
|
||||||
// already validation included
|
// 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());
|
return new ArrayList<Object>(m_lookup.values());
|
||||||
|
|
||||||
if (!m_info.IsValidated && onlyValidated)
|
//if (!m_info.IsValidated && onlyValidated)
|
||||||
|
if (!validated && onlyValidated)
|
||||||
{
|
{
|
||||||
refresh (loadParent);
|
refresh (loadParent);
|
||||||
log.fine(m_info.KeyColumn + ": Validated - #" + m_lookup.size());
|
log.fine(m_info.KeyColumn + ": Validated - #" + m_lookup.size());
|
||||||
|
@ -576,6 +579,15 @@ public final class MLookup extends Lookup implements Serializable
|
||||||
m_lookupDirect.clear();
|
m_lookupDirect.clear();
|
||||||
} // removeAllElements
|
} // 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
|
* MLookup Loader
|
||||||
*/
|
*/
|
||||||
|
@ -613,6 +625,7 @@ public final class MLookup extends Lookup implements Serializable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_info.parsedValidationCode = validation;
|
||||||
log.fine(m_info.KeyColumn + ": Loader Validated: " + validation);
|
log.fine(m_info.KeyColumn + ": Loader Validated: " + validation);
|
||||||
int posFrom = sql.lastIndexOf(" FROM ");
|
int posFrom = sql.lastIndexOf(" FROM ");
|
||||||
boolean hasWhere = sql.indexOf(" WHERE ", posFrom) != -1;
|
boolean hasWhere = sql.indexOf(" WHERE ", posFrom) != -1;
|
||||||
|
@ -642,7 +655,7 @@ public final class MLookup extends Lookup implements Serializable
|
||||||
Env.setContext(m_info.ctx, Env.WINDOW_MLOOKUP, m_info.Column_ID, m_info.KeyColumn, sql);
|
Env.setContext(m_info.ctx, Env.WINDOW_MLOOKUP, m_info.Column_ID, m_info.KeyColumn, sql);
|
||||||
if (CLogMgt.isLevelFinest())
|
if (CLogMgt.isLevelFinest())
|
||||||
log.fine(m_info.KeyColumn + ": " + sql);
|
log.fine(m_info.KeyColumn + ": " + sql);
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
m_lookup.clear();
|
m_lookup.clear();
|
||||||
boolean isNumber = m_info.KeyColumn.endsWith("_ID");
|
boolean isNumber = m_info.KeyColumn.endsWith("_ID");
|
||||||
|
|
|
@ -216,18 +216,22 @@ public class MLookupFactory
|
||||||
+ (hasWhere ? " AND " : " WHERE ") + info.KeyColumn + "=?";
|
+ (hasWhere ? " AND " : " WHERE ") + info.KeyColumn + "=?";
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
String local_validationCode = "";
|
//String local_validationCode = "";
|
||||||
if (info.ValidationCode.length() == 0)
|
if (info.ValidationCode.length() == 0)
|
||||||
info.IsValidated = true;
|
info.IsValidated = true;
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
local_validationCode = Env.parseContext (ctx, WindowNo, info.ValidationCode, true);
|
local_validationCode = Env.parseContext (ctx, WindowNo, info.ValidationCode, true);
|
||||||
if (local_validationCode.length() == 0) // returns "" if not all variables were parsed
|
if (local_validationCode.length() == 0) // returns "" if not all variables were parsed
|
||||||
info.IsValidated = false;
|
info.IsValidated = false;
|
||||||
else
|
else
|
||||||
info.IsValidated = true;
|
info.IsValidated = true;
|
||||||
|
*/
|
||||||
|
info.IsValidated = false;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
// Add Local Validation
|
// Add Local Validation
|
||||||
if (local_validationCode.length() != 0)
|
if (local_validationCode.length() != 0)
|
||||||
{
|
{
|
||||||
|
@ -239,7 +243,7 @@ public class MLookupFactory
|
||||||
else
|
else
|
||||||
info.Query = info.Query
|
info.Query = info.Query
|
||||||
+ (hasWhere ? " AND " : " WHERE ") + local_validationCode;
|
+ (hasWhere ? " AND " : " WHERE ") + local_validationCode;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Add Security
|
// Add Security
|
||||||
if (needToAddSecurity)
|
if (needToAddSecurity)
|
||||||
|
@ -554,9 +558,15 @@ public class MLookupFactory
|
||||||
ColumnName = "AD_Org_ID";
|
ColumnName = "AD_Org_ID";
|
||||||
|
|
||||||
String TableName = ColumnName.substring(0,ColumnName.length()-3);
|
String TableName = ColumnName.substring(0,ColumnName.length()-3);
|
||||||
|
String KeyColumn = ColumnName;
|
||||||
boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
||||||
int ZoomWindow = 0;
|
int ZoomWindow = 0;
|
||||||
int ZoomWindowPO = 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
|
// get display column names
|
||||||
String sql0 = "SELECT c.ColumnName,c.IsTranslated,c.AD_Reference_ID,"
|
String sql0 = "SELECT c.ColumnName,c.IsTranslated,c.AD_Reference_ID,"
|
||||||
|
@ -567,8 +577,6 @@ public class MLookupFactory
|
||||||
+ " AND c.IsIdentifier='Y' "
|
+ " AND c.IsIdentifier='Y' "
|
||||||
+ "ORDER BY c.SeqNo";
|
+ "ORDER BY c.SeqNo";
|
||||||
//
|
//
|
||||||
String KeyColumn = ColumnName;
|
|
||||||
//
|
|
||||||
ArrayList<LookupDisplayColumn> list = new ArrayList<LookupDisplayColumn>();
|
ArrayList<LookupDisplayColumn> list = new ArrayList<LookupDisplayColumn>();
|
||||||
boolean isTranslated = false;
|
boolean isTranslated = false;
|
||||||
//
|
//
|
||||||
|
@ -674,6 +682,7 @@ public class MLookupFactory
|
||||||
s_log.fine("ColumnName=" + ColumnName + " - " + realSQL);
|
s_log.fine("ColumnName=" + ColumnName + " - " + realSQL);
|
||||||
MLookupInfo lInfo = new MLookupInfo(realSQL.toString(), TableName,
|
MLookupInfo lInfo = new MLookupInfo(realSQL.toString(), TableName,
|
||||||
TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery);
|
TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery);
|
||||||
|
s_cacheRefTable.put(cacheKey, lInfo.cloneIt());
|
||||||
return lInfo;
|
return lInfo;
|
||||||
} // getLookup_TableDir
|
} // getLookup_TableDir
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class MLookupInfo implements Serializable, Cloneable
|
||||||
/** CreadedBy?updatedBy */
|
/** CreadedBy?updatedBy */
|
||||||
public boolean IsCreadedUpdatedBy = false;
|
public boolean IsCreadedUpdatedBy = false;
|
||||||
|
|
||||||
|
public String parsedValidationCode = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
|
|
Loading…
Reference in New Issue