From ea092b56ffbedc749fc58e39543edc3d63cde3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Mon, 28 Nov 2022 08:06:29 +0100 Subject: [PATCH] IDEMPIERE-5302 - Drill Assistant Feature fixes in initialisation logic (#1581) * IDEMPIERE-5302 - Drill Assistant Feature fixes in initialisation logic * IDEMPIERE-5302 - removing scripts commited by mistake * IDEMPIERE-5302 - pr1581 patch --- .../adempiere/webui/apps/WDrillReport.java | 43 +++++-------------- .../org/compiere/print/DrillReportCtl.java | 10 +++-- 2 files changed, 17 insertions(+), 36 deletions(-) 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 55ea7109f4..7b9886992f 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 @@ -327,19 +327,19 @@ public class WDrillReport extends Window implements EventListener { a.appendChild(new Text("..")); header.appendChild(a); - KeyNamePair[] drillPrintFormats = drillPrintFormatMap != null ? drillPrintFormatMap.get(drillTable.getKey()) : new KeyNamePair[]{findTablePrintFormat(drillTable)}; - for (int j = 0; j < drillPrintFormats.length; j++) + KeyNamePair[] drillRules = drillPrintFormatMap != null ? drillPrintFormatMap.get(drillTable.getKey()) : new KeyNamePair[]{findTablePrintFormat(drillTable)}; + for (int j = 0; j < drillRules.length; j++) { - KeyNamePair drillPrintFormat = drillPrintFormats[j]; + KeyNamePair drillRule = drillRules[j]; - KeyNamePair[] printFormats = isDrillProcessRule ? drillReportCtl.getDrillProcessRulesPrintFormatMap(drillPrintFormat.getKey()) : new KeyNamePair[] {drillPrintFormat} ; + KeyNamePair[] printFormats = isDrillProcessRule ? drillReportCtl.getDrillProcessRulesPrintFormatMap(drillRule.getKey()) : new KeyNamePair[] {drillRule} ; // create new Print Format if ((printFormats.length <= 0) && isDrillProcessRule) { KeyNamePair[] pfArray = {null}; MPrintFormat pf = null; - MProcessDrillRule dr = MProcessDrillRule.get(Env.getCtx(), drillPrintFormat.getKey()); + MProcessDrillRule dr = MProcessDrillRule.get(Env.getCtx(), drillRule.getKey()); if(dr != null) { int AD_ReportView_ID = dr.getAD_ReportView_ID(); if (AD_ReportView_ID == 0) @@ -360,7 +360,7 @@ public class WDrillReport extends Window implements EventListener { printFormats = pfArray; } if (printFormats.length <= 0) { - int AD_Table_ID = new Query(Env.getCtx(), MTable.Table_Name, " Name = ? ", null).setParameters(drillPrintFormat.getName()).firstId(); + int AD_Table_ID = new Query(Env.getCtx(), MTable.Table_Name, " Name = ? ", null).setParameters(drillRule.getName()).firstId(); pf = MPrintFormat.createFromTable(Env.getCtx(), AD_Table_ID); pfArray[0] = new KeyNamePair(pf.getAD_PrintFormat_ID(), pf.getName()); printFormats = pfArray; @@ -370,13 +370,7 @@ public class WDrillReport extends Window implements EventListener { String hdr = printFormat.getName(); if (hdr != null && hdr.length() > 0) { - // field - if ((printFormat.getKey() <= 0) && isDrillProcessRule) { - table.appendChild(getPrintFormatHeader(printFormat, drillPrintFormat)); - - } else { - table.appendChild(getPrintFormatBox(printFormat, tabIndex, j, tabIndex, null, printFormats.length == 1)); - } + table.appendChild(getPrintFormatBox(printFormat, tabIndex, j, tabIndex, isDrillProcessRule ? drillTable : null, drillRule, printFormats.length == 1)); } } } @@ -444,22 +438,7 @@ public class WDrillReport extends Window implements EventListener { return table; } - private Tr getPrintFormatHeader(KeyNamePair drillPrintFormat, KeyNamePair drillProcessRule) { - Tr tr = new Tr(); - tr.setWidgetAttribute("class", "drill-window-field-header"); - - Td td = new Td(); - td.setStyle("width: 100%; border-bottom: 1px solid gray;"); - td.setColspan(3); - tr.appendChild(td); - H4 h4 = new H4(); - h4.appendChild(new Text(drillProcessRule != null ? drillProcessRule.getName(): drillPrintFormat.getName())); - - td.appendChild(h4); - return tr; - } - - private Tr getPrintFormatBox(KeyNamePair drillPrintFormat, int reportIndex, int formatIndex, int groupIndex, KeyNamePair drillTable, boolean isSinglePrintFormat) + private Tr getPrintFormatBox(KeyNamePair drillPrintFormat, int reportIndex, int formatIndex, int groupIndex, KeyNamePair drillTable, KeyNamePair drillRule, boolean isSinglePrintFormat) { Tr tr = new Tr(); @@ -496,14 +475,14 @@ public class WDrillReport extends Window implements EventListener { a.setAttribute(DRILL_REPORT_PRINTFORMAT_ID_NAME, drillPrintFormat.getKey()); a.setAttribute(DRILL_REPORT_TABLE_NAME, drillPrintFormat.getName()); if(drillTable != null) { - a.setAttribute(DRILL_PROCESS_RULE_ID_NAME, drillTable.getKey()); + a.setAttribute(DRILL_PROCESS_RULE_ID_NAME, drillRule.getKey()); } td.appendChild(a); String description = ""; if(drillTable != null && isSinglePrintFormat) { - MProcessDrillRule dr = MProcessDrillRule.get(Env.getCtx(), drillTable.getKey()); + MProcessDrillRule dr = MProcessDrillRule.get(Env.getCtx(), drillRule.getKey()); if(dr != null) { if (!Util.isEmpty(dr.getDescription())) description = dr.getDescription(); @@ -536,9 +515,9 @@ public class WDrillReport extends Window implements EventListener { } if(event.getTarget().getAttribute(DRILL_REPORT_PRINTFORMAT_ID_NAME) != null) { if(event.getTarget().getAttribute(DRILL_PROCESS_RULE_ID_NAME) != null) { - ProcessInfo pi = drillReportCtl.getDrillProcessProcessInfo((int) event.getTarget().getAttribute(DRILL_PROCESS_RULE_ID_NAME), (int) event.getTarget().getAttribute(DRILL_REPORT_PRINTFORMAT_ID_NAME)); Integer processDrillRuleID = (Integer) event.getTarget().getAttribute(DRILL_PROCESS_RULE_ID_NAME); MProcessDrillRule drillRule = new MProcessDrillRule(Env.getCtx(), processDrillRuleID, null); + ProcessInfo pi = drillReportCtl.getDrillProcessProcessInfo(processDrillRuleID, (int) event.getTarget().getAttribute(DRILL_REPORT_PRINTFORMAT_ID_NAME)); String showHelp = !Util.isEmpty(showHelp = drillRule.getShowHelp()) ? showHelp : MProcess.SHOWHELP_RunSilently_TakeDefaults; pi.setShowHelp(showHelp); ProcessModalDialog processModalDialog = new ProcessModalDialog(this, windowNo, false, pi); diff --git a/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java b/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java index 2d874fa1fa..7ee38fcc83 100644 --- a/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java +++ b/org.adempiere.ui/src/org/compiere/print/DrillReportCtl.java @@ -393,8 +393,10 @@ public class DrillReportCtl { /** - * Launch Report Process - * @param pf print format + * + * @param AD_Process_DrillRule_ID + * @param AD_PrintFormat_ID + * @return * @throws Exception */ public ProcessInfo getDrillProcessProcessInfo (int AD_Process_DrillRule_ID, int AD_PrintFormat_ID) throws Exception @@ -479,8 +481,8 @@ public class DrillReportCtl { MProcessDrillRulePara sPara = sParams[p]; if(processPara. getColumnName().equals(m_ColumnName)) { - iPara.setParameter(DisplayType.isID(sPara.getDisplayType()) ? Integer.valueOf((String) m_Value) : (String) m_Value); - iPara.setInfo(!Util.isEmpty(m_DisplayValue) ? m_DisplayValue : (String) m_Value); + iPara.setParameter(DisplayType.isID(sPara.getDisplayType()) ? new BigDecimal(String.valueOf(m_Value)) : String.valueOf(m_Value)); + iPara.setInfo(!Util.isEmpty(m_DisplayValue) ? m_DisplayValue : String.valueOf(m_Value)); isKeyParameterSet = true; iParams.add(iPara); continue;