IDEMPIERE-6013 Implement a way to filter dinamically records on MRole.addAccessSQL (#2471)
- fix queries with alias (like InfoWindow) - fix InfoWindow issue when the table has no alias
This commit is contained in:
parent
62c86f82c3
commit
f60f599619
|
@ -2157,7 +2157,7 @@ public final class MRole extends X_AD_Role implements ImmutablePOSupport
|
|||
keyColumnName += getIdColumnName(TableName);
|
||||
|
||||
//log.fine("addAccessSQL - " + TableName + "(" + AD_Table_ID + ") " + keyColumnName);
|
||||
String recordWhere = getRecordWhere (AD_Table_ID, keyColumnName, rw);
|
||||
String recordWhere = getRecordWhere (AD_Table_ID, keyColumnName, rw, TableName, ti[i].getSynonym());
|
||||
if (recordWhere.length() > 0)
|
||||
{
|
||||
retSQL.append(" AND ").append(recordWhere);
|
||||
|
@ -2492,9 +2492,11 @@ public final class MRole extends X_AD_Role implements ImmutablePOSupport
|
|||
* @param AD_Table_ID table
|
||||
* @param keyColumnName (fully qualified) key column name
|
||||
* @param rw true if read write
|
||||
* @param tableName
|
||||
* @param alias
|
||||
* @return where clause or ""
|
||||
*/
|
||||
private String getRecordWhere (int AD_Table_ID, String keyColumnName, boolean rw)
|
||||
private String getRecordWhere (int AD_Table_ID, String keyColumnName, boolean rw, String tableName, String alias)
|
||||
{
|
||||
loadRecordAccess(false);
|
||||
//
|
||||
|
@ -2556,6 +2558,8 @@ public final class MRole extends X_AD_Role implements ImmutablePOSupport
|
|||
if (sb.length() > 0)
|
||||
sb.append(" AND ");
|
||||
String wherevr = Env.parseContext(p_ctx, 0, tvr.getCode(), false);
|
||||
if (! Util.isEmpty(alias) && ! alias.equals(tableName))
|
||||
wherevr = wherevr.replaceAll("\\b" + tableName + "\\b", alias);
|
||||
sb.append(" (").append(wherevr).append(") ");
|
||||
}
|
||||
|
||||
|
|
|
@ -1221,7 +1221,10 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
|||
if (p_whereClause != null && p_whereClause.trim().length() > 0) {
|
||||
builder.append(" AND ");
|
||||
}
|
||||
builder.append(tableInfos[0].getSynonym()).append(".IsActive='Y'");
|
||||
String qualifiedTable = tableInfos[0].getSynonym();
|
||||
if (Util.isEmpty(qualifiedTable))
|
||||
qualifiedTable = tableInfos[0].getTableName();
|
||||
builder.append(qualifiedTable).append(".IsActive='Y'");
|
||||
}
|
||||
int count = 0;
|
||||
int idx = 0;
|
||||
|
|
Loading…
Reference in New Issue