IDEMPIERE-5845 - Adds Window Access validation for Drill Assistent (#1995)

* IDEMPIERE-5845 - Adds Window Access validation for Drill Assistent

* IDEMPIERE-5845 - Adds validation for Included Roles on Drill Assistent

* IDEMPIERE-5845 - Implements DISTINCT instead of GROUP BY and fix missing bracket for Drill Assistent SQL
This commit is contained in:
Marcos Gabriel de Oliveira Favaretto 2023-09-21 00:30:54 -03:00 committed by GitHub
parent 6a7c7d7101
commit db72625888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -217,27 +217,38 @@ public class DrillReportCtl {
*/
public void initDrillTableMap() {
MRole defaultRole = MRole.getDefault();
StringBuilder rolesId = new StringBuilder();
rolesId.append(defaultRole.get_ID());
defaultRole.getIncludedRoles(true).forEach(role -> rolesId.append(",").append(role.get_ID()));
ArrayList<KeyNamePair> drillTableList = new ArrayList<>();
String sql = "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) "
String sql = "SELECT DISTINCT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) "
+ "FROM AD_Column c "
+ " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)"
+ " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID AND t.IsShowInDrillOptions='Y')"
+ " INNER JOIN AD_Tab tab ON (t.AD_Table_ID = tab.AD_Table_ID AND tab.isActive = 'Y') "
+ " INNER JOIN AD_Window_Access w ON (tab.AD_Window_ID = w.AD_Window_ID AND w.isActive = 'Y') "
+ " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')"
+ " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) "
+ "WHERE c.AD_Table_ID=? AND c.IsKey='Y' "
+ "WHERE c.AD_Table_ID=? AND w.AD_Role_ID IN (" + rolesId.toString() + ") AND c.IsKey='Y' "
+ "ORDER BY 3 ";
boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element");
if (trl)
sql = "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) "
sql = "SELECT DISTINCT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) "
+ "FROM AD_Column c"
+ " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)"
+ " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID AND t.IsShowInDrillOptions='Y')"
+ " INNER JOIN AD_Tab tab ON (t.AD_Table_ID = tab.AD_Table_ID AND tab.isActive = 'Y') "
+ " INNER JOIN AD_Window_Access w ON (tab.AD_Window_ID = w.AD_Window_ID AND w.isActive = 'Y') "
+ " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')"
+ " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)"
+ " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) "
+ "WHERE c.AD_Table_ID=? AND c.IsKey='Y'"
+ "WHERE c.AD_Table_ID=? AND w.AD_Role_ID IN (" + rolesId.toString() + ") AND c.IsKey='Y' "
+ " AND et.AD_Language=? "
+ "ORDER BY 3 ";
PreparedStatement pstmt = null;
ResultSet rs = null;
try