Skip to content
Snippets Groups Projects
Commit 625cab9a authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

IncomingCall: Fix error when the incoming phone number is stored in an organisation-contact

parent 60d64e35
No related branches found
No related tags found
No related merge requests found
...@@ -233,7 +233,7 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ...@@ -233,7 +233,7 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds)
var patternConfig = indexsearch.createPatternConfig(); var patternConfig = indexsearch.createPatternConfig();
var searchTerm = indexsearch.createTerm(pNumber).setIndexField("phone"); var searchTerm = indexsearch.createTerm(pNumber).setIndexField("phone");
patternConfig.plus(searchTerm); patternConfig.plus(searchTerm);
var pattern = indexsearch.buildPatternString(patternConfig); var pattern = indexsearch.buildPattern(patternConfig);
var indexQuery = indexsearch.createIndexQuery().setPattern(pattern) var indexQuery = indexsearch.createIndexQuery().setPattern(pattern)
.addIndexGroups("Person", "Organisation") .addIndexGroups("Person", "Organisation")
.addResultIndexFields([indexsearch.FIELD_ID]); .addResultIndexFields([indexsearch.FIELD_ID]);
...@@ -258,9 +258,8 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ...@@ -258,9 +258,8 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds)
.from("CONTACT") .from("CONTACT")
.join("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID") .join("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID")
.leftJoin("PERSON", "CONTACT.PERSON_ID = PERSON.PERSONID") .leftJoin("PERSON", "CONTACT.PERSON_ID = PERSON.PERSONID")
.join("COMMUNICATION", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID")
.where("CONTACT.STATUS", $KeywordRegistry.contactStatus$active()) .where("CONTACT.STATUS", $KeywordRegistry.contactStatus$active())
.and("COMMUNICATION.CONTACT_ID", pContactIds, SqlBuilder.IN()) .and("CONTACT.CONTACTID", pContactIds, SqlBuilder.IN())
.table(); .table();
//map to the result how the entities-methods would return it to have less effort later when the mentioned ticket is done //map to the result how the entities-methods would return it to have less effort later when the mentioned ticket is done
...@@ -268,10 +267,10 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ...@@ -268,10 +267,10 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds)
return { return {
CONTACTID: e[0], CONTACTID: e[0],
ORGANISATION_ID: e[1], ORGANISATION_ID: e[1],
ORGANISATION_NAME: e[2], ORGANISATION_NAME: e[2].trim(),
PERSON_ID: e[3], PERSON_ID: e[3],
LANGUAGE: e[4], LANGUAGE: e[4],
PERSON_FULL_NAME: e.slice(5).join(" ") PERSON_FULL_NAME: e.slice(5).join(" ").trim() //quick solution until the ticket above (#1047680) is solved
}; };
}); });
}; };
......
...@@ -31,6 +31,13 @@ function StringUtils(){} ...@@ -31,6 +31,13 @@ function StringUtils(){}
* *
* @return {String} concatenated string; if all elements are empty an emtpy string is returned * @return {String} concatenated string; if all elements are empty an emtpy string is returned
* *
* @example
*
* var necessaryColumns = [];
* //...
* //code that pushes into the necessaryColumns variable here
* //...
* var title = StringUtils.concat(", ", necessaryColumns);
*/ */
StringUtils.concat = function(pSeparator, pElements) StringUtils.concat = function(pSeparator, pElements)
{ {
...@@ -40,6 +47,27 @@ StringUtils.concat = function(pSeparator, pElements) ...@@ -40,6 +47,27 @@ StringUtils.concat = function(pSeparator, pElements)
return res; return res;
}; };
/**
* concats severel elements by a separator; the separator is only applied if a element is not null and not an empty string "";
* You can pass >=2 elements to the function and they will be all concated
*
* @param {String} pSeparator specifies how the not empty elements shall be concatenated
* @param {String} pElement1 first element
* @param {String} pElementN more elements
*
* @return {String} concatenated string; if all elements are empty an emtpy string is returned
*
* @example
* var title = StringUtils.concatArgs(", ", fullPersonContactName, organisationName, additionalInfo);
*
*/
StringUtils.concatArgs = function(pSeparator, pElement1, pElementN)
{
//arguments is not an actual array but an array-like variable so work around that to slice the separator away
var elements = Array.prototype.slice.call(arguments, 1);
return StringUtils.concat(pSeparator, elements);
};
/** /**
* converts a string to a string of always 36 chars. Whitespaces are added at the end if needed. * converts a string to a string of always 36 chars. Whitespaces are added at the end if needed.
......
import("Util_lib");
import("system.tools"); import("system.tools");
import("system.vars"); import("system.vars");
import("Date_lib"); import("Date_lib");
...@@ -41,7 +42,7 @@ var ringingHandlerFn = function() ...@@ -41,7 +42,7 @@ var ringingHandlerFn = function()
var title, desc; var title, desc;
if (this.contactsCall.length > 0) if (this.contactsCall.length > 0)
{ {
var contactTitle = this.contactsCall[0].PERSON_FULL_NAME + ", " + this.contactsCall[0].ORGANISATION_NAME; var contactTitle = StringUtils.concatArgs(", ", this.contactsCall[0].PERSON_FULL_NAME, this.contactsCall[0].ORGANISATION_NAME);
title = translate.withArguments("Call from %0", [contactTitle], targetLocale); title = translate.withArguments("Call from %0", [contactTitle], targetLocale);
desc = translate.withArguments("Incoming call from %0 (%1) to %2", [contactTitle, this.getFormattedCallAddress(), this.getFormattedLocalAddress()], targetLocale); desc = translate.withArguments("Incoming call from %0 (%1) to %2", [contactTitle, this.getFormattedCallAddress(), this.getFormattedLocalAddress()], targetLocale);
} }
...@@ -120,7 +121,7 @@ var disconnectingHandlerFn = function() ...@@ -120,7 +121,7 @@ var disconnectingHandlerFn = function()
} }
else else
{ {
var contactTitleMissed = this.contactsCall[0].PERSON_FULL_NAME + ", " + this.contactsCall[0].ORGANISATION_NAME; var contactTitleMissed = StringUtils.concatArgs(", ", this.contactsCall[0].PERSON_FULL_NAME, this.contactsCall[0].ORGANISATION_NAME);
title = translate.withArguments("Call from %0", [contactTitleMissed], targetLocale); title = translate.withArguments("Call from %0", [contactTitleMissed], targetLocale);
desc = translate.withArguments("Missed call from %0 (%1) to %2", [this.getFormattedCallAddress(), contactTitleMissed, this.getFormattedLocalAddress()], targetLocale); desc = translate.withArguments("Missed call from %0 (%1) to %2", [this.getFormattedCallAddress(), contactTitleMissed, this.getFormattedLocalAddress()], targetLocale);
} }
...@@ -135,7 +136,7 @@ var disconnectingHandlerFn = function() ...@@ -135,7 +136,7 @@ var disconnectingHandlerFn = function()
} }
else else
{ {
var contactTitleAccepted = this.contactsCall[0].PERSON_FULL_NAME + ", " + this.contactsCall[0].ORGANISATION_NAME; var contactTitleAccepted = StringUtils.concatArgs(", ", this.contactsCall[0].PERSON_FULL_NAME, this.contactsCall[0].ORGANISATION_NAME);
title = translate.withArguments("Call from %0", [contactTitleAccepted], targetLocale); title = translate.withArguments("Call from %0", [contactTitleAccepted], targetLocale);
desc = translate.withArguments("Accepted call from %0 (%1) to %2, duration: %3", [this.getFormattedCallAddress(), contactTitleAccepted, this.getFormattedLocalAddress(), talkDuration], targetLocale); desc = translate.withArguments("Accepted call from %0 (%1) to %2, duration: %3", [this.getFormattedCallAddress(), contactTitleAccepted, this.getFormattedLocalAddress(), talkDuration], targetLocale);
} }
......
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