diff --git a/entity/CampaignParticipant_entity/recordcontainers/db/recordfieldmappings/advertisingban_icon.value/expression.js b/entity/CampaignParticipant_entity/recordcontainers/db/recordfieldmappings/advertisingban_icon.value/expression.js index 3343ac44d8f919400aa9972b5f1c0cd3f7837c57..e5f98a118e95f457dd7ff4f5a74986a409ee6213 100644 --- a/entity/CampaignParticipant_entity/recordcontainers/db/recordfieldmappings/advertisingban_icon.value/expression.js +++ b/entity/CampaignParticipant_entity/recordcontainers/db/recordfieldmappings/advertisingban_icon.value/expression.js @@ -1,7 +1,13 @@ import("system.vars"); import("Contact_lib"); -import("Sql_lib"); import("system.result"); +import("MarketingCondition_lib"); // Now show warning always, if any commrestriction exists. No matter which medium the current step has. -result.string("(" + ContactUtils.getCommRestrictionCount(undefined, vars.get("$sys.date")) + ")"); \ No newline at end of file +var condition = new CommunicationSettingsCondition() + .anyMedium() + .rejected() + .existSettings() + .buildCondition(); + +result.string(condition.toString()); \ No newline at end of file diff --git a/entity/Organisation_entity/recordcontainers/db/onDBDelete.js b/entity/Organisation_entity/recordcontainers/db/onDBDelete.js index 320f4e3329fa4fd7195da03495b3cd7e5812a9d6..1c79f609e4a6fe4174ecd97e5d2eb712ed3c6e28 100644 --- a/entity/Organisation_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Organisation_entity/recordcontainers/db/onDBDelete.js @@ -14,8 +14,8 @@ new AttributeRelationQuery(contactId, null, ContextUtils.getCurrentContextId()) newWhere("COMMUNICATION.CONTACT_ID", contactId).deleteData(); newWhere("ADDRESS.CONTACT_ID", contactId).deleteData(); -newWhere("COMMRESTRICTION.CONTACT_ID", contactId).deleteData(); -newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", vars.get("$field.CONTACTID")).deleteData(); -newWhere("CLASSIFICATION.OBJECT_ROWID", vars.get("$field.CONTACTID")).deleteData(); +newWhere("COMMUNICATIONSETTINGS.CONTACT_ID", contactId).deleteData(); +newWhere("CLASSIFICATIONSTORAGE.OBJECT_ROWID", contactId).deleteData(); +newWhere("CLASSIFICATION.OBJECT_ROWID", contactId).deleteData(); WorkflowSignalSender.deleted(); \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/db/onDBDelete.js b/entity/Person_entity/recordcontainers/db/onDBDelete.js index 26d095805ed1fc2a0f944c3a99c4f7e49475057a..bccd1c92888786d6c6388db00bacae3689906f02 100644 --- a/entity/Person_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Person_entity/recordcontainers/db/onDBDelete.js @@ -6,17 +6,18 @@ import("system.vars"); import("DuplicateScanner_lib"); var contactId = vars.get("$field.CONTACTID"); +var context = ContextUtils.getCurrentContextId(); DuplicateScannerUtils.deleteHasDuplicateEntries("Person_entity", [contactId]); -new AttributeRelationQuery(contactId, null, ContextUtils.getCurrentContextId()) +new AttributeRelationQuery(contactId, null, context) .deleteAllAttributes(); newWhere("COMMUNICATION.CONTACT_ID", contactId).deleteData(); newWhere("ADDRESS.CONTACT_ID", contactId).deleteData(); -newWhere("COMMRESTRICTION.CONTACT_ID", contactId).deleteData(); -newWhere("AB_APPOINTMENTLINK.OBJECT_TYPE", "Person") -.and("AB_APPOINTMENTLINK.OBJECT_ROWID", contactId).deleteData(); -newWhere("AB_ATTRIBUTERELATION.OBJECT_TYPE", "Person") -.and("AB_ATTRIBUTERELATION.OBJECT_ROWID", contactId).deleteData(); +newWhere("COMMUNICATIONSETTINGS.CONTACT_ID", contactId).deleteData(); +newWhere("AB_APPOINTMENTLINK.OBJECT_TYPE", context) + .and("AB_APPOINTMENTLINK.OBJECT_ROWID", contactId).deleteData(); +newWhere("AB_ATTRIBUTERELATION.OBJECT_TYPE", context) + .and("AB_ATTRIBUTERELATION.OBJECT_ROWID", contactId).deleteData(); WorkflowSignalSender.deleted(); \ No newline at end of file diff --git a/process/MarketingCondition_lib/process.js b/process/MarketingCondition_lib/process.js index f6033c7d1a46915e82ac55d20eb36b10b43e6d4c..2a2e22e6ca05668d5031a587e0786327db73dc6c 100644 --- a/process/MarketingCondition_lib/process.js +++ b/process/MarketingCondition_lib/process.js @@ -16,8 +16,15 @@ function CommunicationSettingsCondition () this._channelIdSql = null; this._settingStatus = null; this._existsOperator = SqlBuilder.EXISTS(); + this._useAnyMedium = false; } +/** + * Sets a sql expression for the contact id + * + * @param {String|SqlBuilder} pContactIdSql sql field or expression to get the contactId + * @return {CommunicationSettingsCondition} current object + */ CommunicationSettingsCondition.prototype.contactIdField = function (pContactIdSql) { this._contactIdSql = pContactIdSql; @@ -25,6 +32,12 @@ CommunicationSettingsCondition.prototype.contactIdField = function (pContactIdSq return this; } +/** + * Sets the contactId to get the communication settings from + * + * @param {String} pContactId contact id + * @return {CommunicationSettingsCondition} current object + */ CommunicationSettingsCondition.prototype.contactId = function (pContactId) { this._contactId = pContactId; @@ -32,12 +45,22 @@ CommunicationSettingsCondition.prototype.contactId = function (pContactId) return this; } +/** + * Makes the condition yield true if no communication setting exists + * + * @return {CommunicationSettingsCondition} current object + */ CommunicationSettingsCondition.prototype.existNoSettings = function () { this._existsOperator = SqlBuilder.NOT_EXISTS(); return this; } +/** + * Makes the condition yield true if at least one communication setting exists + * + * @return {CommunicationSettingsCondition} current object + */ CommunicationSettingsCondition.prototype.existSettings = function () { this._existsOperator = SqlBuilder.EXISTS(); @@ -120,12 +143,32 @@ CommunicationSettingsCondition.prototype.pending = function () return this; } +/** + * Only fetch settings with the given status + * + * @param {String} pStatus staus that the communication settings need to have + * @return {CommunicationSettingsCondition} current object + */ CommunicationSettingsCondition.prototype.status = function (pStatus) { this._settingStatus = pStatus; return this; } +/** + * Fetch communication settings of any kind, regardless of medium or channel. + * + * @return {CommunicationSettingsCondition} current object + */ +CommunicationSettingsCondition.prototype.anyMedium = function () +{ + this._useAnyMedium = true; + this._medium = null; + this._channelType = null; + this._channelIdSql = null; + return this; +} + /** * Builds a sub select for fetching the communication settings with the properies as configured. * @@ -149,19 +192,22 @@ CommunicationSettingsCondition.prototype.buildSelect = function (pSelectFields) sql.and("COMMUNICATIONSETTINGS.CONTACT_ID", this._contactId); } - var channelCondition = newWhere("COMMUNICATIONSETTINGS.CHANNEL_TYPE", $KeywordRegistry.communicationChannelType$global()); - if (this._channelType) + if (!this._useAnyMedium) { - var specificChannelCondition = newWhere("COMMUNICATIONSETTINGS.CHANNEL_TYPE", this._channelType) - .andIfSet("COMMUNICATIONSETTINGS.MEDIUM", this._medium); - if (this._channelIdSql) + var channelCondition = newWhere("COMMUNICATIONSETTINGS.CHANNEL_TYPE", $KeywordRegistry.communicationChannelType$global()); + if (this._channelType) { - specificChannelCondition.and(newWhere("COMMUNICATIONSETTINGS.CHANNEL_ID = " + this._channelIdSql) - .or("COMMUNICATIONSETTINGS.CHANNEL_ID is null")); + var specificChannelCondition = newWhere("COMMUNICATIONSETTINGS.CHANNEL_TYPE", this._channelType) + .andIfSet("COMMUNICATIONSETTINGS.MEDIUM", this._medium); + if (this._channelIdSql) + { + specificChannelCondition.and(newWhere("COMMUNICATIONSETTINGS.CHANNEL_ID = " + this._channelIdSql) + .or("COMMUNICATIONSETTINGS.CHANNEL_ID is null")); + } + channelCondition.or(specificChannelCondition); } - channelCondition.or(specificChannelCondition); + sql.and(channelCondition); } - sql.and(channelCondition); return sql; }