From bfa1ef643ff3ae263a90ea4f0eb2f0b86b4c5635 Mon Sep 17 00:00:00 2001 From: Sebastian Listl <s.listl@adito.de> Date: Mon, 10 May 2021 15:56:51 +0200 Subject: [PATCH] 1080074 communication settings in log history --- aliasDefinition/Data_alias/Data_alias.aod | 80 +++++++++++++++++-- .../translate4log/property.js | 23 ++++++ .../children/tablenames_param/valueProcess.js | 2 +- .../children/tablenames_param/valueProcess.js | 2 +- process/Loghistory_lib/process.js | 43 +++++----- 5 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 aliasDefinition/Data_alias/aliasdefinitionsub/entitygroup/entities/communicationsettings/entityfields/channel_id/customproperties/translate4log/property.js diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index c060b095c1a..b2902498d34 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -18338,7 +18338,7 @@ <description></description> <auditSyncConfig> <name>auditSyncConfig</name> - <auditMode v="0" /> + <auditMode v="1" /> <syncActive v="false" /> <syncComplete v="true" /> <syncDirection v="1" /> @@ -18356,8 +18356,20 @@ <isUnique v="false" /> <index v="false" /> <documentation></documentation> - <title></title> + <title>Status</title> <description></description> + <customProperties> + <customBooleanProperty> + <name>log</name> + <global v="false" /> + <property v="true" /> + </customBooleanProperty> + <customStringProperty> + <name>keyword</name> + <global v="false" /> + <property>CommunicationSettingStatus</property> + </customStringProperty> + </customProperties> </entityFieldDb> <entityFieldDb> <name>CHANNEL_ID</name> @@ -18370,8 +18382,20 @@ <isUnique v="false" /> <index v="true" /> <documentation></documentation> - <title></title> + <title>Channel</title> <description></description> + <customProperties> + <customBooleanProperty> + <name>log</name> + <global v="false" /> + <property v="true" /> + </customBooleanProperty> + <customJDitoProperty> + <name>translate4Log</name> + <global v="false" /> + <property>%aditoprj%/aliasDefinition/Data_alias/aliasdefinitionsub/entitygroup/entities/communicationsettings/entityfields/channel_id/customproperties/translate4log/property.js</property> + </customJDitoProperty> + </customProperties> </entityFieldDb> <entityFieldDb> <name>CHANNEL_TYPE</name> @@ -18384,8 +18408,21 @@ <isUnique v="false" /> <index v="false" /> <documentation></documentation> - <title></title> + <title>Channel type</title> <description></description> + <customProperties> + <customBooleanProperty> + <name>log</name> + <global v="false" /> + <description></description> + <property v="true" /> + </customBooleanProperty> + <customStringProperty> + <name>keyword</name> + <global v="false" /> + <property>CommunicationChannelType</property> + </customStringProperty> + </customProperties> </entityFieldDb> <entityFieldDb> <name>CONTACT_ID</name> @@ -18398,8 +18435,27 @@ <isUnique v="false" /> <index v="true" /> <documentation></documentation> - <title></title> + <title>Contact</title> <description></description> + <customProperties> + <customBooleanProperty> + <name>log</name> + <global v="false" /> + <property v="false" /> + </customBooleanProperty> + <customStringProperty> + <name>tableRef</name> + <global v="false" /> + <property>CONTACT</property> + </customStringProperty> + </customProperties> + <dependencies> + <entityDependency> + <name>776b88c0-8606-4445-b5f0-c7a258cd5b00</name> + <entityName>CONTACT</entityName> + <fieldName>CONTACTID</fieldName> + </entityDependency> + </dependencies> </entityFieldDb> <entityFieldDb> <name>COMMUNICATIONSETTINGSID</name> @@ -18426,8 +18482,20 @@ <isUnique v="false" /> <index v="true" /> <documentation></documentation> - <title></title> + <title>Medium</title> <description></description> + <customProperties> + <customBooleanProperty> + <name>log</name> + <global v="false" /> + <property v="true" /> + </customBooleanProperty> + <customStringProperty> + <name>keyword</name> + <global v="false" /> + <property>CommunicationMediumCampaign</property> + </customStringProperty> + </customProperties> </entityFieldDb> <entityFieldDb> <name>DATE_EDIT</name> diff --git a/aliasDefinition/Data_alias/aliasdefinitionsub/entitygroup/entities/communicationsettings/entityfields/channel_id/customproperties/translate4log/property.js b/aliasDefinition/Data_alias/aliasdefinitionsub/entitygroup/entities/communicationsettings/entityfields/channel_id/customproperties/translate4log/property.js new file mode 100644 index 00000000000..c3396d4867a --- /dev/null +++ b/aliasDefinition/Data_alias/aliasdefinitionsub/entitygroup/entities/communicationsettings/entityfields/channel_id/customproperties/translate4log/property.js @@ -0,0 +1,23 @@ +import("Sql_lib"); +import("Contact_lib"); +import("system.result"); +import("Loghistory_lib"); +import("PostalAddress_lib"); + +var params = Translate4LogParams.load(); + +var displayValue = ""; +if (params.value) +{ + displayValue = newSelect("ADDR") + .from("COMMUNICATION") + .where("COMMUNICATION.COMMUNICATIONID", params.value) + .cell(); + + if (!displayValue) + { + displayValue = AddressUtils.getFormattedOnlineAddressById(params.value); + } +} + +result.string(displayValue); \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js b/entity/Organisation_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js index 17ba5b0226b..723ad4e60c5 100644 --- a/entity/Organisation_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js +++ b/entity/Organisation_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js @@ -3,7 +3,7 @@ import("system.result"); import("Context_lib"); var res = []; -res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION"]}); +res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION", "COMMUNICATIONSETTINGS"]}); res.push({id: vars.get("$field.ORGANISATIONID"), tableNames: ["ORGANISATION"]}); res = JSON.stringify(res);//currently only strings can be passed as param diff --git a/entity/Person_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js b/entity/Person_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js index 602247f4551..a8eb5202412 100644 --- a/entity/Person_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js +++ b/entity/Person_entity/entityfields/loghistories/children/tablenames_param/valueProcess.js @@ -3,7 +3,7 @@ import("system.result"); import("Context_lib"); var res = []; -res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION", "DSGVODELETEFLAG", "DSGVO"]}); +res.push({id: vars.get("$field.CONTACTID"), tableNames: ["CONTACT", "COMMUNICATION", "ADDRESS", "AB_ATTRIBUTERELATION", "DSGVODELETEFLAG", "DSGVO", "COMMUNICATIONSETTINGS"]}); res.push({id: vars.get("$field.PERSONID"), tableNames: ["PERSON"]}); res = JSON.stringify(res);//currently only strings can be passed as param diff --git a/process/Loghistory_lib/process.js b/process/Loghistory_lib/process.js index 48aecff059e..e7f2e76a4ce 100644 --- a/process/Loghistory_lib/process.js +++ b/process/Loghistory_lib/process.js @@ -1,3 +1,4 @@ +import("Context_lib"); import("system.vars"); import("system.util"); import("system.logging"); @@ -19,6 +20,12 @@ import("Util_lib"); import("KeywordRegistry_basic"); import("system.entities"); +const AuditSqlActions = { + INSERT: "I", + UPDATE: "U", + DELETE: "D" +}; + /** * object for writing the LogHistory based on audit-changes * this object will be probably only usefull within the "process_audit"-process @@ -160,11 +167,11 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra) for(let i = 0; i < this.columns.length; i++ ) { - if (this.sqlAction == 'D' || this.sqlAction == 'U') oldvalues[this.columns[i]] = this.oldValues[i]; - if (this.sqlAction == 'I' || this.sqlAction == 'U') newvalues[this.columns[i]] = this.newValues[i]; + if (this.sqlAction == AuditSqlActions.DELETE || this.sqlAction == AuditSqlActions.UPDATE) oldvalues[this.columns[i]] = this.oldValues[i]; + if (this.sqlAction == AuditSqlActions.INSERT || this.sqlAction == AuditSqlActions.UPDATE) newvalues[this.columns[i]] = this.newValues[i]; } - if (this.sqlAction == 'D') newvalues = oldvalues; - if ((this.sqlAction == 'D' || this.sqlAction == 'I') && newvalues[conf.IDs[1]]) + if (this.sqlAction == AuditSqlActions.DELETE) newvalues = oldvalues; + if ((this.sqlAction == AuditSqlActions.DELETE || this.sqlAction == AuditSqlActions.INSERT) && newvalues[conf.IDs[1]]) { pIdvalue = newvalues[conf.IDs[0]]; var data = this._getDataForExtras(newvalues[conf.IDs[1]], newvalues); @@ -173,7 +180,7 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra) else //this may happen for Attributes of type VOID (=attributes that have no values, compareable to "tags") description.push(conf.Description + " " + data[0]); } - if (this.sqlAction == 'U') + if (this.sqlAction == AuditSqlActions.UPDATE) { var ids = newSelect(conf.IDs).from(this.affectedTable).where([this.affectedTable, this.affectedTable + "ID"], pIdvalue).arrayRow(); pIdvalue = ids[0]; @@ -213,20 +220,20 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra) if (references[this.columns[i]]) { - if (this.sqlAction == "I") references[this.columns[i]].id = this.newValues[i]; - if (this.sqlAction == "D") references[this.columns[i]].id = this.oldValues[i]; + if (this.sqlAction == AuditSqlActions.INSERT) references[this.columns[i]].id = this.newValues[i]; + if (this.sqlAction == AuditSqlActions.DELETE) references[this.columns[i]].id = this.oldValues[i]; } var logfield = columnStructure[this.columns[i]]; if (logfield && logfield.log) { - if (this.sqlAction != 'I' && this.oldValues[i] != "") + if (this.sqlAction != AuditSqlActions.INSERT && this.oldValues[i] != "") oldvalues[i] = this._getFormattedValue(this.columns[i], logfield, this.oldValues[i]); - if (this.sqlAction != 'D' && this.newValues[i] != "") + if (this.sqlAction != AuditSqlActions.DELETE && this.newValues[i] != "") newvalues[i] = this._getFormattedValue(this.columns[i], logfield, this.newValues[i]); var logfieldTitle = (logfield.title ? translate.text(logfield.title, this.translationLanguage) : translate.text("Value", this.translationLanguage)); - if (this.sqlAction == 'U' && oldvalues[i] != newvalues[i]) + if (this.sqlAction == AuditSqlActions.UPDATE && oldvalues[i] != newvalues[i]) { //TODO: CLOB-check should be done by viewing the structure column type //use .trim() for "[CLOB]" check because in some case the value "[CLOB]\n" my be given @@ -237,14 +244,14 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra) } //use .trim() for "[CLOB]" check because in some case the value "[CLOB]\n" my be given - if (this.sqlAction == 'I' && newvalues[i] != "" && newvalues[i] != null && newvalues[i].trim() != "[CLOB]") + if (this.sqlAction == AuditSqlActions.INSERT && newvalues[i] != "" && newvalues[i] != null && newvalues[i].trim() != "[CLOB]") description.push(logfieldTitle + ": \"" + newvalues[i] + "\""); //use .trim() for "[CLOB]" check because in some case the value "[CLOB]\n" my be given - if (this.sqlAction == 'D' && oldvalues[i] != "" && oldvalues[i] != null && oldvalues[i].trim() != "[CLOB]") + if (this.sqlAction == AuditSqlActions.DELETE && oldvalues[i] != "" && oldvalues[i] != null && oldvalues[i].trim() != "[CLOB]") description.push(logfieldTitle + ": \"" + oldvalues[i] + "\""); } } - if (this.sqlAction == "U") + if (this.sqlAction == AuditSqlActions.UPDATE) { for (let index in references) references[index].id = newSelect(index).from(this.affectedTable).where([this.affectedTable, primaryKey], this.idValue).cell(); } @@ -252,9 +259,9 @@ LogHistoryExecutor.prototype.generateLogHistory = function (pIdvalue, pExtra) if (description.length > 0) { - if (this.sqlAction == 'I') description = translate.withArguments("%0 added.", [description.join(",\n")], this.translationLanguage); - else if (this.sqlAction == 'U') description = translate.withArguments("%0 modified.", [description.join(",\n")], this.translationLanguage); - else if (this.sqlAction == 'D') description = translate.withArguments("%0 deleted.", [description.join(",\n")], this.translationLanguage); + if (this.sqlAction == AuditSqlActions.INSERT) description = translate.withArguments("%0 added.", [description.join(",\n")], this.translationLanguage); + else if (this.sqlAction == AuditSqlActions.UPDATE) description = translate.withArguments("%0 modified.", [description.join(",\n")], this.translationLanguage); + else if (this.sqlAction == AuditSqlActions.DELETE) description = translate.withArguments("%0 deleted.", [description.join(",\n")], this.translationLanguage); } return [description, pIdvalue, references]; } @@ -343,8 +350,8 @@ LogHistoryExecutor.prototype._getDataForExtras = function(pId, pValues) */ LogHistoryExecutor.prototype._getCalendarDescription = function (pIndex) { - if (this.sqlAction != "D") this.newValues[pIndex] = _getEntry("DESCRIPTION:", this.newValues[pIndex]); - if (this.sqlAction != "I") this.oldValues[pIndex] = _getEntry("DESCRIPTION:", this.oldValues[pIndex]); + if (this.sqlAction != AuditSqlActions.DELETE) this.newValues[pIndex] = _getEntry("DESCRIPTION:", this.newValues[pIndex]); + if (this.sqlAction != AuditSqlActions.INSERT) this.oldValues[pIndex] = _getEntry("DESCRIPTION:", this.oldValues[pIndex]); function _getEntry(pWert, pVcomponent) { -- GitLab