From 8ede4bd04875dcf7bcfa78573c5edf08ed0d61f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:35:25 +0100 Subject: [PATCH] IDEMPIERE-5593 - Drill Rule: Do not render Drill Rules for the same Report (#1692) * IDEMPIERE-5593 - Drill Rule: Do not render Drill Rules for the same Report * IDEMPIERE-5593 - fixes --- .../src/org/adempiere/webui/apps/AEnv.java | 26 ++++++++++----- .../adempiere/webui/apps/WDrillReport.java | 16 ++++++++-- .../webui/window/ZkReportViewer.java | 32 ++++++++++--------- .../org/compiere/print/DrillReportCtl.java | 12 ++++--- 4 files changed, 56 insertions(+), 30 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index 160959ba6d..b9c4a6799e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -453,17 +453,27 @@ public final class AEnv /** * Opens the Drill Assistant * @param data query - * @param component + * @param windowNo */ public static void actionDrill(DrillData data, int windowNo) { - int AD_Table_ID = MTable.getTable_ID(data.getQuery().getTableName()); - if (!MRole.getDefault().isCanReport(AD_Table_ID)) - { - Dialog.error(windowNo, "AccessCannotReport", data.getQuery().getTableName()); - return; - } + actionDrill(data, windowNo, 0); + } + + /** + * Opens the Drill Assistant + * @param data query + * @param windowNo + * @param processID Source Report + */ + public static void actionDrill(DrillData data, int windowNo, int processID) { + int AD_Table_ID = MTable.getTable_ID(data.getQuery().getTableName()); if (AD_Table_ID > 0) { - WDrillReport drillReport = new WDrillReport(data, windowNo); + if (!MRole.getDefault().isCanReport(AD_Table_ID)) + { + Dialog.error(windowNo, "AccessCannotReport", data.getQuery().getTableName()); + return; + } + WDrillReport drillReport = new WDrillReport(data, windowNo, processID); Object window = SessionManager.getAppDesktop().findWindow(windowNo); if (window != null && window instanceof Component && window instanceof ISupportMask){ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WDrillReport.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WDrillReport.java index d2078d6b09..17f2fca17a 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WDrillReport.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/WDrillReport.java @@ -105,10 +105,20 @@ public class WDrillReport extends Window implements EventListener { * @param data * @param WindowNo */ - public WDrillReport(DrillData data, int WindowNo) { + public WDrillReport(DrillData data, int windowNo) { + this(data, windowNo, 0); + } + + /** + * + * @param data + * @param WindowNo + * @param processID + */ + public WDrillReport(DrillData data, int windowNo, int processID) { super(); - this.windowNo = WindowNo; - drillReportCtl = new DrillReportCtl(data.getQuery().getTableName(), data.getQuery(), data.getColumnName(), data.getValue(), data.getDisplayValue(), WindowNo); + this.windowNo = windowNo; + drillReportCtl = new DrillReportCtl(data.getQuery().getTableName(), data.getQuery(), data.getColumnName(), data.getValue(), data.getDisplayValue(), windowNo, processID); this.setTitle(Msg.getMsg(Env.getCtx(), "DrillAssistant")); this.setClosable(true); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 3df546cc17..c1d24e7ebd 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -172,12 +172,14 @@ public class ZkReportViewer extends Window implements EventListener, ITab private boolean m_setting = false; /** Report Engine */ protected ReportEngine m_reportEngine; - /** Table ID */ - private int m_AD_Table_ID = 0; - private boolean m_isCanExport; - - private MQuery m_ddQ = null; - private MQuery m_daQ = null; + /** Table ID */ + private int m_AD_Table_ID = 0; + private boolean m_isCanExport; + /** Process ID */ + private int m_AD_Process_ID = 0; + + private MQuery m_ddQ = null; + private MQuery m_daQ = null; private Menuitem m_ddM = null; private Menuitem m_daM = null; @@ -784,14 +786,14 @@ public class ZkReportViewer extends Window implements EventListener, ITab linkDiv.appendChild(reportLink); south.appendChild(linkDiv); //m_WindowNo - int AD_Window_ID = Env.getContextAsInt(Env.getCtx(), m_reportEngine.getWindowNo(), "_WinInfo_AD_Window_ID", true); - if (AD_Window_ID == 0) - AD_Window_ID = Env.getZoomWindowID(m_reportEngine.getQuery()); - int AD_Process_ID = m_reportEngine.getPrintInfo() != null ? m_reportEngine.getPrintInfo().getAD_Process_ID() : 0; - updateToolbarAccess(AD_Window_ID, AD_Process_ID); - - this.setBorder("normal"); - + int AD_Window_ID = Env.getContextAsInt(Env.getCtx(), m_reportEngine.getWindowNo(), "_WinInfo_AD_Window_ID", true); + if (AD_Window_ID == 0) + AD_Window_ID = Env.getZoomWindowID(m_reportEngine.getQuery()); + m_AD_Process_ID = m_reportEngine.getPrintInfo() != null ? m_reportEngine.getPrintInfo().getAD_Process_ID() : 0; + updateToolbarAccess(AD_Window_ID, m_AD_Process_ID); + + this.setBorder("normal"); + this.addEventListener("onZoom", new EventListener() { public void onEvent(Event event) throws Exception { @@ -814,7 +816,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab DrillEvent de = (DrillEvent) event; if (de.getData() != null && de.getData() instanceof DrillData) { DrillData data = (DrillData) de.getData(); - AEnv.actionDrill(data, m_WindowNo); + AEnv.actionDrill(data, m_WindowNo, m_AD_Process_ID); } } diff --git a/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java b/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java index d0994f7986..f1eba32c84 100644 --- a/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java +++ b/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java @@ -81,6 +81,9 @@ public class DrillReportCtl { private String m_DisplayValue; + /** Process ID of the source Report */ + private int m_AD_Process_ID; + /** Drill Tables Map */ private KeyNamePair[] drillTables; @@ -95,20 +98,21 @@ public class DrillReportCtl { /** * - * @param ctx * @param TableName * @param query * @param ColumnName * @param Value * @param displayValue * @param WindowNo + * @param processID */ - public DrillReportCtl(String TableName, MQuery query, String ColumnName, Object Value, String displayValue, int WindowNo) { + public DrillReportCtl(String TableName, MQuery query, String ColumnName, Object Value, String displayValue, int WindowNo, int processID) { this.m_TableName = TableName; this.m_ColumnName = ColumnName; this.m_Value = Value; this.m_WindowNo = WindowNo; this.m_DisplayValue = displayValue; + this.m_AD_Process_ID = processID; m_Query = query; @@ -179,9 +183,9 @@ public class DrillReportCtl { if(!Util.isEmpty(m_ColumnName)) { MProcessDrillRule[] processDrillRules = MProcessDrillRule.getByColumnName(Env.getCtx(), m_ColumnName, null); for( MProcessDrillRule drillProcesRule: processDrillRules) { - MProcess process = MProcess.get(drillProcesRule.getAD_Process_ID()); - if(process == null) + if (drillProcesRule.getAD_Process_ID() == 0 || drillProcesRule.getAD_Process_ID() == m_AD_Process_ID) continue; + MProcess process = MProcess.get(drillProcesRule.getAD_Process_ID()); drillProcessMap.put(drillProcesRule.getAD_Process_ID(), process.get_Translation(MProcess.COLUMNNAME_Name));