* [ 1644505 ] MRole.getAccessSQL not working

This commit is contained in:
Heng Sin Low 2007-01-25 16:04:25 +00:00
parent 95bc31403e
commit a088410825
1 changed files with 22 additions and 6 deletions

View File

@ -533,6 +533,8 @@ public final class MRole extends X_AD_Role
private HashMap<String,Integer> m_tableName = null; private HashMap<String,Integer> m_tableName = null;
/** View Name */ /** View Name */
private Set<String> m_viewName = null; private Set<String> m_viewName = null;
/** ID Column Name **/
private HashMap<String,String> m_tableIdName = null;
/** Window Access */ /** Window Access */
private HashMap<Integer,Boolean> m_windowAccess = null; private HashMap<Integer,Boolean> m_windowAccess = null;
@ -804,9 +806,11 @@ public final class MRole extends X_AD_Role
return; return;
m_tableAccessLevel = new HashMap<Integer,String>(300); m_tableAccessLevel = new HashMap<Integer,String>(300);
m_tableName = new HashMap<String,Integer>(300); m_tableName = new HashMap<String,Integer>(300);
m_viewName = new HashSet<String>(300); m_viewName = new HashSet<String>(300);
m_tableIdName = new HashMap<String,String>(300);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String sql = "SELECT AD_Table_ID, AccessLevel, TableName, IsView " String sql = "SELECT AD_Table_ID, AccessLevel, TableName, IsView, "
+ "(SELECT ColumnName FROM AD_COLUMN WHERE AD_COLUMN.AD_TABLE_ID = AD_TABLE.AD_TABLE_ID AND ISKEY='Y' AND COLUMNNAME LIKE '%ID') "
+ "FROM AD_Table WHERE IsActive='Y'"; + "FROM AD_Table WHERE IsActive='Y'";
try try
{ {
@ -821,7 +825,12 @@ public final class MRole extends X_AD_Role
String isView = rs.getString(4); String isView = rs.getString(4);
if ("Y".equals(isView)) if ("Y".equals(isView))
{ {
m_viewName.add(tableName); m_viewName.add(tableName.toUpperCase());
}
String idColumn = rs.getString(5);
if (idColumn != null && idColumn.trim().length() > 0)
{
m_tableIdName.put(tableName.toUpperCase(), idColumn);
} }
} }
rs.close(); rs.close();
@ -852,7 +861,12 @@ public final class MRole extends X_AD_Role
*/ */
private boolean isView(String tableName) private boolean isView(String tableName)
{ {
return m_viewName.contains(tableName); return m_viewName.contains(tableName.toUpperCase());
}
private String getIdColumnName(String tableName)
{
return m_tableIdName.get(tableName.toUpperCase());
} }
/** /**
@ -1706,9 +1720,11 @@ public final class MRole extends X_AD_Role
keyColumnName = TableName; keyColumnName = TableName;
keyColumnName += "."; keyColumnName += ".";
} }
keyColumnName += TableName + "_ID"; // derived from table //keyColumnName += TableName + "_ID"; // derived from table
if (getIdColumnName(TableName) == null) continue;
keyColumnName += getIdColumnName(TableName);
// log.fine("addAccessSQL - " + TableName + "(" + AD_Table_ID + ") " + keyColumnName); //log.fine("addAccessSQL - " + TableName + "(" + AD_Table_ID + ") " + keyColumnName);
String recordWhere = getRecordWhere (AD_Table_ID, keyColumnName, rw); String recordWhere = getRecordWhere (AD_Table_ID, keyColumnName, rw);
if (recordWhere.length() > 0) if (recordWhere.length() > 0)
{ {