diff --git a/entity/Communication_entity/recordcontainers/db/onDBUpdate.js b/entity/Communication_entity/recordcontainers/db/onDBUpdate.js index bf5479355edafc66f94d997b930948efe05002b6..7e2690d20ab6fcf371c1b12e9e4fa2f4e8a7ef39 100644 --- a/entity/Communication_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Communication_entity/recordcontainers/db/onDBUpdate.js @@ -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 diff --git a/process/StandardObject_lib/process.js b/process/StandardObject_lib/process.js index 15358cf2b996fec4ef6745d0e6c32d8cd6050b04..28c728cd7666a4797f19fdaffebe90ba68e032d6 100644 --- a/process/StandardObject_lib/process.js +++ b/process/StandardObject_lib/process.js @@ -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