From f8cf23f2cb73c53a65bd6bda24dc5900505e9110 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 20 Oct 2017 19:41:57 +0200 Subject: [PATCH] IDEMPIERE-3521 InfoWindow problem on other SQL when make a register count / peer review and integrate patch from Orlando --- .../oracle/201710201214_IDEMPIERE-3521.sql | 15 +++++++ .../201710201214_IDEMPIERE-3521.sql | 12 +++++ .../src/org/compiere/model/MInfoWindow.java | 3 +- .../org/adempiere/webui/info/InfoWindow.java | 45 +++++++++++-------- .../org/adempiere/webui/panel/InfoPanel.java | 4 -- 5 files changed, 56 insertions(+), 23 deletions(-) create mode 100644 migration/i4.1/oracle/201710201214_IDEMPIERE-3521.sql create mode 100644 migration/i4.1/postgresql/201710201214_IDEMPIERE-3521.sql diff --git a/migration/i4.1/oracle/201710201214_IDEMPIERE-3521.sql b/migration/i4.1/oracle/201710201214_IDEMPIERE-3521.sql new file mode 100644 index 0000000000..11fdf2e7b0 --- /dev/null +++ b/migration/i4.1/oracle/201710201214_IDEMPIERE-3521.sql @@ -0,0 +1,15 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3521 InfoWindow problem on other SQL when make a register count +-- Oct 20, 2017 12:13:41 PM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-10-20 12:13:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201634 +; + +-- Oct 20, 2017 12:13:43 PM CEST +UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2017-10-20 12:13:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13579 +; + +SELECT register_migration_script('201710201214_IDEMPIERE-3521.sql') FROM dual +; + diff --git a/migration/i4.1/postgresql/201710201214_IDEMPIERE-3521.sql b/migration/i4.1/postgresql/201710201214_IDEMPIERE-3521.sql new file mode 100644 index 0000000000..fd659b051f --- /dev/null +++ b/migration/i4.1/postgresql/201710201214_IDEMPIERE-3521.sql @@ -0,0 +1,12 @@ +-- IDEMPIERE-3521 InfoWindow problem on other SQL when make a register count +-- Oct 20, 2017 12:13:41 PM CEST +UPDATE AD_Field SET SeqNo=130, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-10-20 12:13:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=201634 +; + +-- Oct 20, 2017 12:13:43 PM CEST +UPDATE AD_Field SET SeqNo=120, AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2017-10-20 12:13:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=13579 +; + +SELECT register_migration_script('201710201214_IDEMPIERE-3521.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/model/MInfoWindow.java b/org.adempiere.base/src/org/compiere/model/MInfoWindow.java index f3436c14f4..04b00c79e3 100644 --- a/org.adempiere.base/src/org/compiere/model/MInfoWindow.java +++ b/org.adempiere.base/src/org/compiere/model/MInfoWindow.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.adempiere.model.MInfoProcess; import org.adempiere.model.MInfoRelated; import org.compiere.model.AccessSqlParser.TableInfo; @@ -446,7 +447,7 @@ public class MInfoWindow extends X_AD_InfoWindow pstmt.executeQuery(); }catch (Exception ex){ log.log(Level.WARNING, ex.getMessage()); - return; + throw new AdempiereException(ex); } finally { DB.close(pstmt); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java index 6dacc83d87..4b050e6f60 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/info/InfoWindow.java @@ -106,11 +106,11 @@ import org.zkoss.zul.Vbox; * @contributor xolali IDEMPIERE-1045 Sub-Info Tabs (reviewed by red1) */ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventListener { - /** * */ - private static final long serialVersionUID = 8358292103127594383L; + private static final long serialVersionUID = 1672005382454423850L; + protected Grid parameterGrid; private Borderlayout layout; private Vbox southBody; @@ -1474,16 +1474,8 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL dataSql = MRole.getDefault().addAccessSQL(dataSql, getTableName(), MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - if (infoWindow.getOtherClause() != null && infoWindow.getOtherClause().trim().length() > 0) { - String otherClause = infoWindow.getOtherClause(); - if (otherClause.indexOf("@") >= 0) { - String s = Env.parseContext(infoContext, p_WindowNo, otherClause, true, false); - if (s.length() == 0) { - log.severe("Failed to parse other clause. " + otherClause); - } else { - otherClause = s; - } - } + String otherClause = getOtherClauseParsed(); + if (otherClause.length() > 0) { dataSql = dataSql + " " + otherClause; } @@ -1498,8 +1490,24 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL } return dataSql; } - - @Override + + private String getOtherClauseParsed() { + String otherClause = ""; + if (infoWindow != null && infoWindow.getOtherClause() != null && infoWindow.getOtherClause().trim().length() > 0) { + otherClause = infoWindow.getOtherClause(); + if (otherClause.indexOf("@") >= 0) { + String s = Env.parseContext(infoContext, p_WindowNo, otherClause, true, false); + if (s.length() == 0) { + log.severe("Failed to parse other clause. " + otherClause); + } else { + otherClause = s; + } + } + } + return otherClause; + } + + @Override protected void executeQuery() { prepareTable(); super.executeQuery(); @@ -1705,10 +1713,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL } countSql = MRole.getDefault().addAccessSQL (countSql, getTableName(), MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); - // Fix GroupBy On InfoWindow - String otherClause = infoWindow.getOtherClause(); - if (otherClause !=null) - countSql = countSql+" "+otherClause; + // IDEMPIERE-3521 + String otherClause = getOtherClauseParsed(); + if (otherClause.length() > 0) { + countSql = countSql + " " + otherClause; + } countSql = "SELECT COUNT(*) FROM ( " + countSql + " ) a"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 376011e0d4..6ceedc67f7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -1065,10 +1065,6 @@ public abstract class InfoPanel extends Window implements EventListener, countSql = countSql.trim(); countSql = countSql.substring(0, countSql.length() - 5); } - String otherClause = infoWindow.getOtherClause(); // Fix otherClause on count - if (otherClause != null) - countSql = countSql+" "+otherClause; - countSql = MRole.getDefault().addAccessSQL (countSql, getTableName(), MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); if (log.isLoggable(Level.FINER))