From 8c3af7914e3e9edcb6661a2c2f3642121974253f Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 4 Dec 2019 20:54:13 +0100 Subject: [PATCH] IDEMPIERE-4087 Virtual search columns / enable the usage of @SQLFIND= columns in reports / update field Description --- .../i7.1/oracle/201912042002_IDEMPIERE-4087.sql | 15 +++++++++++++++ .../postgresql/201912042002_IDEMPIERE-4087.sql | 12 ++++++++++++ .../src/org/compiere/print/DataEngine.java | 4 +++- .../src/org/compiere/print/MPrintFormat.java | 4 ++-- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 migration/i7.1/oracle/201912042002_IDEMPIERE-4087.sql create mode 100644 migration/i7.1/postgresql/201912042002_IDEMPIERE-4087.sql diff --git a/migration/i7.1/oracle/201912042002_IDEMPIERE-4087.sql b/migration/i7.1/oracle/201912042002_IDEMPIERE-4087.sql new file mode 100644 index 0000000000..4109de3f12 --- /dev/null +++ b/migration/i7.1/oracle/201912042002_IDEMPIERE-4087.sql @@ -0,0 +1,15 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-4087 Copy the link to this issue virtual search columns +-- Dec 4, 2019, 8:01:25 PM CET +UPDATE AD_Field SET Help='You can define virtual columns (not stored in the database). If defined, the Column name is the synonym of the SQL expression defined here. The SQL expression must be valid.
+Example: "Updated-Created" would list the age of the entry in days.
+It is not recommended to add complex queries in virtual columns as the impact on the database performance can be too expensive.
+However, you can use the prefix @SQLFIND= for virtual columns that can be used for queries and reports, they have less impact on the database, but as a field they don''t show values.
+Additionally, the prefix @SQL= allows to define a virtual UI column, this is calculated on the fly and can use context variables in the query, virtual UI columns are shown in grid just on the current row, they are not searchable, and not shown in reports.', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_DATE('2019-12-04 20:46:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11264 +; + +SELECT register_migration_script('201912042002_IDEMPIERE-4087.sql') FROM dual +; + diff --git a/migration/i7.1/postgresql/201912042002_IDEMPIERE-4087.sql b/migration/i7.1/postgresql/201912042002_IDEMPIERE-4087.sql new file mode 100644 index 0000000000..ebd6aeeb10 --- /dev/null +++ b/migration/i7.1/postgresql/201912042002_IDEMPIERE-4087.sql @@ -0,0 +1,12 @@ +-- IDEMPIERE-4087 Copy the link to this issue virtual search columns +-- Dec 4, 2019, 8:01:25 PM CET +UPDATE AD_Field SET Help='You can define virtual columns (not stored in the database). If defined, the Column name is the synonym of the SQL expression defined here. The SQL expression must be valid.
+Example: "Updated-Created" would list the age of the entry in days.
+It is not recommended to add complex queries in virtual columns as the impact on the database performance can be too expensive.
+However, you can use the prefix @SQLFIND= for virtual columns that can be used for queries and reports, they have less impact on the database, but as a field they don''t show values.
+Additionally, the prefix @SQL= allows to define a virtual UI column, this is calculated on the fly and can use context variables in the query, virtual UI columns are shown in grid just on the current row, they are not searchable, and not shown in reports.', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2019-12-04 20:46:15','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11264 +; + +SELECT register_migration_script('201912042002_IDEMPIERE-4087.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/print/DataEngine.java b/org.adempiere.base/src/org/compiere/print/DataEngine.java index 0b5058e15a..83a89d3021 100644 --- a/org.adempiere.base/src/org/compiere/print/DataEngine.java +++ b/org.adempiere.base/src/org/compiere/print/DataEngine.java @@ -310,7 +310,9 @@ public class DataEngine int AD_Column_ID = rs.getInt(1); String ColumnName = rs.getString(2); String ColumnSQL = rs.getString(24); - if (ColumnSQL != null && ColumnSQL.length() > 0 && (ColumnSQL.startsWith("@SQL=") || ColumnSQL.startsWith("@SQLFIND="))) + if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith("@SQLFIND=")) + ColumnSQL = ColumnSQL.substring(9); + if (ColumnSQL != null && ColumnSQL.length() > 0 && ColumnSQL.startsWith("@SQL=")) ColumnSQL = "NULL"; if (ColumnSQL != null && ColumnSQL.contains("@")) ColumnSQL = Env.parseContext(Env.getCtx(), -1, ColumnSQL, false, true); diff --git a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java index 61ccf8b147..5c3be7d46c 100644 --- a/org.adempiere.base/src/org/compiere/print/MPrintFormat.java +++ b/org.adempiere.base/src/org/compiere/print/MPrintFormat.java @@ -615,7 +615,7 @@ public class MPrintFormat extends X_AD_PrintFormat int seqNo = 1; for (GridField gridField : gridFields) { - if (gridField.isVirtualUIColumn() || gridField.isVirtualSearchColumn()) + if (gridField.isVirtualUIColumn()) continue; MPrintFormatItem pfi = MPrintFormatItem.createFromGridField(pf, gridField, seqNo++); if (pfi != null) @@ -878,7 +878,7 @@ public class MPrintFormat extends X_AD_PrintFormat { int columnID = rs.getInt(1); MColumn column = MColumn.get(ctx, columnID); - if (column.isVirtualUIColumn() || column.isVirtualSearchColumn()) + if (column.isVirtualUIColumn()) continue; MPrintFormatItem pfi = MPrintFormatItem.createFromColumn (format, columnID, seqNo++); if (pfi != null)