Skip to content
Snippets Groups Projects
Commit 48073a27 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 b4a52415
No related branches found
No related tags found
No related merge requests found
...@@ -333,7 +333,7 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ...@@ -333,7 +333,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]);
...@@ -354,13 +354,12 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ...@@ -354,13 +354,12 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds)
return rows; return rows;
*/ */
var contactSql = SqlCondition.begin() var contactSql = SqlCondition.begin()
.andIn("COMMUNICATION.CONTACT_ID", contactIds)//this is automatically only added if pContactIds is filled .andIn("CONTACT.CONTACTID", contactIds)//this is automatically only added if pContactIds is filled
.andPrepare("CONTACT.STATUS", $KeywordRegistry.contactStatus$active()) .andPrepare("CONTACT.STATUS", $KeywordRegistry.contactStatus$active())
.buildSql("select CONTACT.CONTACTID, CONTACT.ORGANISATION_ID, ORGANISATION.NAME, CONTACT.PERSON_ID, \n\ .buildSql("select CONTACT.CONTACTID, CONTACT.ORGANISATION_ID, ORGANISATION.NAME, CONTACT.PERSON_ID, \n\
CONTACT.ISOLANGUAGE, PERSON.LASTNAME, PERSON.FIRSTNAME from CONTACT \n\ CONTACT.ISOLANGUAGE, PERSON.LASTNAME, PERSON.FIRSTNAME from CONTACT \n\
join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID \n\ join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID \n\
left join PERSON on CONTACT.PERSON_ID = PERSON.PERSONID \n\ left join PERSON on CONTACT.PERSON_ID = PERSON.PERSONID");
join COMMUNICATION on COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID");
var contacts = db.table(contactSql); var contacts = db.table(contactSql);
//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
...@@ -368,10 +367,10 @@ IncomingCallExecutor._getContactsFromNumber = function(pNumber, pContactIds) ...@@ -368,10 +367,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);
} }
...@@ -116,7 +117,7 @@ var disconnectingHandlerFn = function() ...@@ -116,7 +117,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);
} }
...@@ -131,7 +132,7 @@ var disconnectingHandlerFn = function() ...@@ -131,7 +132,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