Skip to content
Snippets Groups Projects
Commit 76953b72 authored by Andre Loreth's avatar Andre Loreth
Browse files

#1035771 Standard address/communication

parent a147dd5d
No related branches found
No related tags found
No related merge requests found
......@@ -2,9 +2,5 @@ import("system.logging");
import("system.vars");
import("StandardObject_lib");
logging.log("Object " + vars.get("$field.COMMUNICATIONID"))
logging.log("Contact " + vars.get("$field.CONTACT_ID"))
logging.log("Medium " + vars.get("$field.MEDIUM_ID"))
new StandardObject("Communication", vars.get("$field.COMMUNICATIONID"), "Person", vars.get("$field.CONTACT_ID"))
.onCommunicationUpdate(vars.get("$field.MEDIUM_ID"));
\ No newline at end of file
......@@ -13,8 +13,6 @@ function StandardObject (pObjectType, pObjectID, pScopeType, pScopeID) {
this.objectID = pObjectID
this.scopeType = pScopeType
this.scopeID = pScopeID
this.__mediumCache = {};
}
StandardObject.CONST_OBJECT_ADDRESS = function () {
......@@ -122,10 +120,6 @@ StandardObject.prototype.onObjectInsert = function () {
}
}
StandardObject.prototype.onObjectUpdate = function () {
}
/**
* Shall be execute only on the `onDBInsert` process of the recordContainer
* of the `Address` entity. This will set the standard address on the
......@@ -164,19 +158,13 @@ StandardObject.prototype.onCommunicationUpdate = function (pMediumID) {
var mediumCategory = this._getMediumCategory(pMediumID);
var hasStandard = this._hasStandardCommunicationByMedium(this.scopeID, mediumCategory);
var contactID = this._getContactIdByCommunication(this.objectID);
var hasStandard = this._hasStandardCommunicationByMedium(contactID, mediumCategory);
if (!hasStandard)
this._setStandardCommunication(this.objectID, 1);
}
StandardObject.prototype._onAddressUpdate = function (pAddressID) {
}
StandardObject.prototype._onAddressDelete = function (pAddressID) {
}
/**
* Checks if the given contact ID has any address ID set. If there is a standard
* address it will return `true`, otherwise `false`. This function asserts that
......@@ -239,9 +227,7 @@ StandardObject.prototype._getCompanyStandardAddress = function (pOrganisationID)
* @return {Boolean} If the contact already has a standard addres with the given
* medium category.
*/
StandardObject.prototype._hasStandardCommunicationByMedium = function (pContactID, pMediumCategory) {
logging.log("Contact: " + pContactID)
StandardObject.prototype._hasStandardCommunicationByMedium = function (pContactID, pMediumCategory) {
var dbResult = db.array(db.COLUMN, "select CHAR_VALUE from COMMUNICATION"
+ " left join AB_KEYWORD_ENTRY on KEYID = MEDIUM_ID"
+ " left join AB_KEYWORD_ATTRIBUTERELATION on AB_KEYWORD_ENTRY_ID = AB_KEYWORD_ENTRYID and AB_KEYWORD_ATTRIBUTE_ID = '7250ff28-1d48-41cc-bb36-8c33ace341bb'"
......@@ -280,4 +266,14 @@ StandardObject.prototype._setStandardCommunication = function (pCommunicationID,
db.getColumnTypes("COMMUNICATION", ["STANDARD"]),
[pValue],
"COMMUNICATIONID = '" + pCommunicationID + "'")
}
/**
* Will return the Contact ID by the given communication ID.
*
* @param pCommunicationID {String} Communication ID to get the contact ID for.
* @return The contact ID.
*/
StandardObject.prototype._getContactIdByCommunication = function (pCommunicationID) {
return db.cell("select CONTACT_ID from COMMUNICATION where COMMUNICATIONID = '" + pCommunicationID + "'")
}
\ No newline at end of file
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