Skip to content
Snippets Groups Projects
Commit 158fd744 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

1082318 use communication settings in campaignParticipant

parent d8fedf67
No related branches found
No related tags found
No related merge requests found
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
......@@ -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
......@@ -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
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment