From a96c6e482d152c0f475a235006741588594e138a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Fri, 7 Oct 2022 08:01:12 +0200 Subject: [PATCH] IDEMPIERE-5432 - Performance Measure Calculation - Improve SQL Definition (#1500) * IDEMPIERE-5432 - Performance Measure Calculation - Improve SQL Definition * IDEMPIERE-5432 - IDEMPIERE-5432_PR1 patch --- .../oracle/202209261211_IDEMPIERE-5432.sql | 25 +++++++++++++++++++ .../202209261211_IDEMPIERE-5432.sql | 22 ++++++++++++++++ .../src/org/compiere/model/MMeasureCalc.java | 15 +++++++++-- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 migration/iD10/oracle/202209261211_IDEMPIERE-5432.sql create mode 100644 migration/iD10/postgresql/202209261211_IDEMPIERE-5432.sql diff --git a/migration/iD10/oracle/202209261211_IDEMPIERE-5432.sql b/migration/iD10/oracle/202209261211_IDEMPIERE-5432.sql new file mode 100644 index 0000000000..fe22685907 --- /dev/null +++ b/migration/iD10/oracle/202209261211_IDEMPIERE-5432.sql @@ -0,0 +1,25 @@ +-- IDEMPIERE-5432 +SELECT register_migration_script('202209261211_IDEMPIERE-5432.sql') FROM dual; + +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Sep 30, 2022, 5:04:55 PM CEST +UPDATE AD_Window SET Help='The Performance Measure Calculation defines how performance measures will be calculated. +The sql needs to return a single value. Please check examples.
+The date restriction is defined in the Goal. +Any restrictions for Organizations, Business Partners, Products, etc. are as Performance Goal Restrictions.',Updated=TO_TIMESTAMP('2022-09-30 17:04:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Window_ID=213 +; + +-- Sep 30, 2022, 5:04:55 PM CEST +UPDATE AD_WF_Node SET Name='Performance Measure Calculation', Description='Define how you calculate your performance measures', Help='The Performance Measure Calculation defines how performance measures will be calculated. +The sql needs to return a single value. Please check examples.
+The date restriction is defined in the Goal. +Any restrictions for Organizations, Business Partners, Products, etc. are as Performance Goal Restrictions.',Updated=TO_TIMESTAMP('2022-09-30 17:04:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_WF_Node_ID=148 +; + +-- Sep 30, 2022, 5:05:48 PM CEST +UPDATE AD_Tab SET Help='The Performance Measure Calculation defines how performance measures will be calculated. See examples.
+The SELECT definition must contain the SELECT and FROM keywords in upper case. The WHERE clause can only contain values of the main table (e.g. when selecting from Header and lines, only header variables can be used in the where clause) and be fully qualified if there is more then one table.',Updated=TO_TIMESTAMP('2022-09-30 17:05:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=369 +; + diff --git a/migration/iD10/postgresql/202209261211_IDEMPIERE-5432.sql b/migration/iD10/postgresql/202209261211_IDEMPIERE-5432.sql new file mode 100644 index 0000000000..4795baed02 --- /dev/null +++ b/migration/iD10/postgresql/202209261211_IDEMPIERE-5432.sql @@ -0,0 +1,22 @@ +-- IDEMPIERE-5432 +SELECT register_migration_script('202209261211_IDEMPIERE-5432.sql') FROM dual; + +-- Sep 30, 2022, 5:04:55 PM CEST +UPDATE AD_Window SET Help='The Performance Measure Calculation defines how performance measures will be calculated. +The sql needs to return a single value. Please check examples.
+The date restriction is defined in the Goal. +Any restrictions for Organizations, Business Partners, Products, etc. are as Performance Goal Restrictions.',Updated=TO_TIMESTAMP('2022-09-30 17:04:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Window_ID=213 +; + +-- Sep 30, 2022, 5:04:55 PM CEST +UPDATE AD_WF_Node SET Name='Performance Measure Calculation', Description='Define how you calculate your performance measures', Help='The Performance Measure Calculation defines how performance measures will be calculated. +The sql needs to return a single value. Please check examples.
+The date restriction is defined in the Goal. +Any restrictions for Organizations, Business Partners, Products, etc. are as Performance Goal Restrictions.',Updated=TO_TIMESTAMP('2022-09-30 17:04:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_WF_Node_ID=148 +; + +-- Sep 30, 2022, 5:05:48 PM CEST +UPDATE AD_Tab SET Help='The Performance Measure Calculation defines how performance measures will be calculated. See examples.
+The SELECT definition must contain the SELECT and FROM keywords in upper case. The WHERE clause can only contain values of the main table (e.g. when selecting from Header and lines, only header variables can be used in the where clause) and be fully qualified if there is more then one table.',Updated=TO_TIMESTAMP('2022-09-30 17:05:48','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=369 +; + diff --git a/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java b/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java index aaa4ce64c0..7e0accf17e 100644 --- a/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java +++ b/org.adempiere.base/src/org/compiere/model/MMeasureCalc.java @@ -39,7 +39,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc implements ImmutablePOSupport /** * */ - private static final long serialVersionUID = 3143013490477454559L; + private static final long serialVersionUID = -1334100963468705584L; /** * Get MMeasureCalc from Cache (immutable) @@ -482,7 +482,7 @@ public class MMeasureCalc extends X_PA_MeasureCalc implements ImmutablePOSupport return finalSQL; if (role == null) role = MRole.getDefault(); - String retValue = role.addAccessSQL(finalSQL, tableName, true, false); + String retValue = role.addAccessSQL(finalSQL, null, true, false); return retValue; } // addRestrictions @@ -515,4 +515,15 @@ public class MMeasureCalc extends X_PA_MeasureCalc implements ImmutablePOSupport return this; } + /** + * Get the Where clause adding the WHERE keyword when needed + */ + @Override + public String getWhereClause() { + String whereClause = super.getWhereClause(); + if (! whereClause.toLowerCase().startsWith("where ")) + whereClause = "WHERE " + whereClause; + return whereClause; + } + } // MMeasureCalc