From 89faa3ac49a46f3d13f6318094e633225ffad699 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 20 May 2020 20:09:23 +0200 Subject: [PATCH] IDEMPIERE-2523 improve method to add comment to log script (#75) #resolve IDEMPIERE-2523 --- .../oracle/202005192336_IDEMPIERE-2523.sql | 31 +++++++++++++++++++ .../202005192336_IDEMPIERE-2523.sql | 28 +++++++++++++++++ .../src/org/compiere/dbPort/Convert.java | 9 ++---- .../src/org/compiere/model/MSequence.java | 4 +-- .../src/org/compiere/model/MSysConfig.java | 2 -- .../adempiere/webui/window/WPreference.java | 4 ++- 6 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 migration/i7.1z/oracle/202005192336_IDEMPIERE-2523.sql create mode 100644 migration/i7.1z/postgresql/202005192336_IDEMPIERE-2523.sql diff --git a/migration/i7.1z/oracle/202005192336_IDEMPIERE-2523.sql b/migration/i7.1z/oracle/202005192336_IDEMPIERE-2523.sql new file mode 100644 index 0000000000..1412e234d6 --- /dev/null +++ b/migration/i7.1z/oracle/202005192336_IDEMPIERE-2523.sql @@ -0,0 +1,31 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-2523 improve method to add comment to log script +-- May 19, 2020, 11:32:52 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203417,0,0,'Y',TO_DATE('2020-05-19 23:32:22','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-05-19 23:32:22','YYYY-MM-DD HH24:MI:SS'),100,'MigrationScriptComment','Migration Script Comment',NULL,NULL,'Migration Script Comment','D','f6a393c7-fe39-45d9-834b-2d6b43a92093') +; + +-- May 19, 2020, 11:34:33 PM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214200,0,'Migration Script Comment',200174,'MigrationScriptComment',NULL,255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_DATE('2020-05-19 23:34:32','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-05-19 23:34:32','YYYY-MM-DD HH24:MI:SS'),100,203417,'Y','N','D','N','N','N','Y','da1fd9e7-cc0f-467d-a994-752fc6213b88','Y',0,'N','N','N','N') +; + +-- May 19, 2020, 11:34:37 PM CEST +ALTER TABLE AD_UserPreference ADD MigrationScriptComment VARCHAR2(255) DEFAULT NULL +; + +-- May 19, 2020, 11:34:49 PM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206407,'Migration Script Comment',200189,214200,'Y',255,150,'N','N','N','N',0,0,'Y',TO_DATE('2020-05-19 23:34:48','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-05-19 23:34:48','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','15bae19e-2b5a-4300-808d-69123803bdc6','Y',150,5) +; + +-- May 19, 2020, 11:35:41 PM CEST +UPDATE AD_Field SET DisplayLogic='@P|LogMigrationScript@=Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsQuickEntry='Y', IsToolbarButton=NULL,Updated=TO_DATE('2020-05-19 23:35:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206407 +; + +-- May 19, 2020, 11:36:13 PM CEST +UPDATE AD_SysConfig SET IsActive='N',Updated=TO_DATE('2020-05-20 00:01:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_SysConfig_ID IN (50003,50008) +; + +SELECT register_migration_script('202005192336_IDEMPIERE-2523.sql') FROM dual +; + diff --git a/migration/i7.1z/postgresql/202005192336_IDEMPIERE-2523.sql b/migration/i7.1z/postgresql/202005192336_IDEMPIERE-2523.sql new file mode 100644 index 0000000000..992b9b1ca2 --- /dev/null +++ b/migration/i7.1z/postgresql/202005192336_IDEMPIERE-2523.sql @@ -0,0 +1,28 @@ +-- IDEMPIERE-2523 improve method to add comment to log script +-- May 19, 2020, 11:32:52 PM CEST +INSERT INTO AD_Element (AD_Element_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,ColumnName,Name,Description,Help,PrintName,EntityType,AD_Element_UU) VALUES (203417,0,0,'Y',TO_TIMESTAMP('2020-05-19 23:32:22','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-05-19 23:32:22','YYYY-MM-DD HH24:MI:SS'),100,'MigrationScriptComment','Migration Script Comment',NULL,NULL,'Migration Script Comment','D','f6a393c7-fe39-45d9-834b-2d6b43a92093') +; + +-- May 19, 2020, 11:34:33 PM CEST +INSERT INTO AD_Column (AD_Column_ID,Version,Name,AD_Table_ID,ColumnName,DefaultValue,FieldLength,IsKey,IsParent,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsEncrypted,AD_Reference_ID,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Element_ID,IsUpdateable,IsSelectionColumn,EntityType,IsSyncDatabase,IsAlwaysUpdateable,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsAllowCopy,SeqNoSelection,IsToolbarButton,IsSecure,FKConstraintType,IsHtml) VALUES (214200,0,'Migration Script Comment',200174,'MigrationScriptComment',NULL,255,'N','N','N','N','N',0,'N',10,0,0,'Y',TO_TIMESTAMP('2020-05-19 23:34:32','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-05-19 23:34:32','YYYY-MM-DD HH24:MI:SS'),100,203417,'Y','N','D','N','N','N','Y','da1fd9e7-cc0f-467d-a994-752fc6213b88','Y',0,'N','N','N','N') +; + +-- May 19, 2020, 11:34:37 PM CEST +ALTER TABLE AD_UserPreference ADD COLUMN MigrationScriptComment VARCHAR(255) DEFAULT NULL +; + +-- May 19, 2020, 11:34:49 PM CEST +INSERT INTO AD_Field (AD_Field_ID,Name,AD_Tab_ID,AD_Column_ID,IsDisplayed,DisplayLength,SeqNo,IsSameLine,IsHeading,IsFieldOnly,IsEncrypted,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,IsReadOnly,IsCentrallyMaintained,EntityType,AD_Field_UU,IsDisplayedGrid,SeqNoGrid,ColumnSpan) VALUES (206407,'Migration Script Comment',200189,214200,'Y',255,150,'N','N','N','N',0,0,'Y',TO_TIMESTAMP('2020-05-19 23:34:48','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-05-19 23:34:48','YYYY-MM-DD HH24:MI:SS'),100,'N','Y','D','15bae19e-2b5a-4300-808d-69123803bdc6','Y',150,5) +; + +-- May 19, 2020, 11:35:41 PM CEST +UPDATE AD_Field SET DisplayLogic='@P|LogMigrationScript@=Y', AD_Reference_Value_ID=NULL, AD_Val_Rule_ID=NULL, IsQuickEntry='Y', IsToolbarButton=NULL,Updated=TO_TIMESTAMP('2020-05-19 23:35:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=206407 +; + +-- May 19, 2020, 11:36:13 PM CEST +UPDATE AD_SysConfig SET IsActive='N',Updated=TO_TIMESTAMP('2020-05-20 00:01:19','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_SysConfig_ID IN (50003,50008) +; + +SELECT register_migration_script('202005192336_IDEMPIERE-2523.sql') FROM dual +; + diff --git a/org.adempiere.base/src/org/compiere/dbPort/Convert.java b/org.adempiere.base/src/org/compiere/dbPort/Convert.java index a2e38bed55..d9348b785d 100644 --- a/org.adempiere.base/src/org/compiere/dbPort/Convert.java +++ b/org.adempiere.base/src/org/compiere/dbPort/Convert.java @@ -37,7 +37,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.compiere.db.Database; -import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.DisplayType; import org.compiere.util.Env; @@ -515,6 +514,7 @@ public abstract class Convert "AD_WINDOW_ACCESS", "AD_WORKFLOW_ACCESS", "AD_WORKFLOWPROCESSORLOG", + "AD_USERPREFERENCE", "CM_WEBACCESSLOG", "C_ACCTPROCESSORLOG", "K_INDEXLOG", @@ -581,13 +581,8 @@ public abstract class Convert private static void writeLogMigrationScript(Writer w, String statement) throws IOException { - boolean isUseCentralizedID = "Y".equals(MSysConfig.getValue(MSysConfig.DICTIONARY_ID_USE_CENTRALIZED_ID, "Y")); // defaults to Y - boolean isUseProjectCentralizedID = "Y".equals(MSysConfig.getValue(MSysConfig.PROJECT_ID_USE_CENTRALIZED_ID, "N")); // defaults to N String prm_COMMENT; - if (!isUseCentralizedID && isUseProjectCentralizedID) - prm_COMMENT = MSysConfig.getValue(MSysConfig.PROJECT_ID_COMMENTS); - else - prm_COMMENT = MSysConfig.getValue(MSysConfig.DICTIONARY_ID_COMMENTS); + prm_COMMENT = Env.getContext(Env.getCtx(), "MigrationScriptComment"); if (prm_COMMENT != null && ! m_oldprm_COMMENT.equals(prm_COMMENT)) { // log sysconfig comment w.append("-- "); diff --git a/org.adempiere.base/src/org/compiere/model/MSequence.java b/org.adempiere.base/src/org/compiere/model/MSequence.java index f5c4eae630..e397ca9e8b 100644 --- a/org.adempiere.base/src/org/compiere/model/MSequence.java +++ b/org.adempiere.base/src/org/compiere/model/MSequence.java @@ -1243,7 +1243,7 @@ public class MSequence extends X_AD_Sequence String prm_PASSWORD = MSysConfig.getValue(MSysConfig.DICTIONARY_ID_PASSWORD); // "password_inseguro"; String prm_TABLE = TableName; String prm_ALTKEY = ""; // TODO: generate alt-key based on key of table - String prm_COMMENT = MSysConfig.getValue(MSysConfig.DICTIONARY_ID_COMMENTS); + String prm_COMMENT = Env.getContext(Env.getCtx(), "MigrationScriptComment"); String prm_PROJECT = new String("Adempiere"); return getNextID_HTTP(TableName, website, prm_USER, @@ -1264,7 +1264,7 @@ public class MSequence extends X_AD_Sequence String prm_PASSWORD = MSysConfig.getValue(MSysConfig.PROJECT_ID_PASSWORD); // "password_inseguro"; String prm_TABLE = TableName; String prm_ALTKEY = ""; // TODO: generate alt-key based on key of table - String prm_COMMENT = MSysConfig.getValue(MSysConfig.PROJECT_ID_COMMENTS); + String prm_COMMENT = Env.getContext(Env.getCtx(), "MigrationScriptComment"); String prm_PROJECT = MSysConfig.getValue(MSysConfig.PROJECT_ID_PROJECT); return getNextID_HTTP(TableName, website, prm_USER, diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 8702948d4b..c13a82c8ea 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -85,7 +85,6 @@ public class MSysConfig extends X_AD_SysConfig public static final String DB_READ_REPLICA_NORMAL_MAX_ITERATIONS = "DB_READ_REPLICA_NORMAL_MAX_ITERATIONS"; public static final String DB_READ_REPLICA_NORMAL_TIMEOUT_IN_MILLISECONDS = "DB_READ_REPLICA_NORMAL_TIMEOUT_IN_MILLISECONDS"; public static final String DB_READ_REPLICA_URLS = "DB_READ_REPLICA_URLS"; - public static final String DICTIONARY_ID_COMMENTS = "DICTIONARY_ID_COMMENTS"; public static final String DICTIONARY_ID_PASSWORD = "DICTIONARY_ID_PASSWORD"; public static final String DICTIONARY_ID_USE_CENTRALIZED_ID = "DICTIONARY_ID_USE_CENTRALIZED_ID"; public static final String DICTIONARY_ID_USER = "DICTIONARY_ID_USER"; @@ -130,7 +129,6 @@ public class MSysConfig extends X_AD_SysConfig public static final String PDF_FONT_DIR = "PDF_FONT_DIR"; public static final String ProductUOMConversionRateValidate = "ProductUOMConversionRateValidate"; public static final String ProductUOMConversionUOMValidate = "ProductUOMConversionUOMValidate"; - public static final String PROJECT_ID_COMMENTS = "PROJECT_ID_COMMENTS"; public static final String PROJECT_ID_PASSWORD = "PROJECT_ID_PASSWORD"; public static final String PROJECT_ID_PROJECT = "PROJECT_ID_PROJECT"; public static final String PROJECT_ID_USE_CENTRALIZED_ID = "PROJECT_ID_USE_CENTRALIZED_ID"; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPreference.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPreference.java index 8879cbf66e..77416fb19f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPreference.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPreference.java @@ -190,8 +190,10 @@ public class WPreference extends WQuickEntry implements EventListener { actionSave(); // Log Migration Script and AdempiereSys are just in-memory preferences, must not be saved - if (logMigrationScript != null) + if (logMigrationScript != null) { Env.getCtx().setProperty("LogMigrationScript", (Boolean)logMigrationScript.getValue() ? "Y" : "N"); + Env.getCtx().setProperty("P|LogMigrationScript", (Boolean)logMigrationScript.getValue() ? "Y" : "N"); + } if (adempiereSys != null) Env.getCtx().setProperty("AdempiereSys", (Boolean)adempiereSys.getValue() ? "Y" : "N");