diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index ea22dc2e7b6318cd19049c4144c441c73d3f5063..b88a83d77c84ec022dac4cc0c150b8e4ead442ff 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -1045,6 +1045,9 @@ <name>OnlyOwnSupervised_param</name> <expose v="true" /> </entityParameter> + <entityField> + <name>IndexCommPhone</name> + </entityField> <entityConsumer> <name>SelfDuplicatesUncached</name> <dependency> @@ -1287,14 +1290,6 @@ <indexFieldType>TEXT_PLAIN</indexFieldType> <additionalFieldNameAliases /> </indexRecordFieldMapping> - <indexRecordFieldMapping> - <name>IndexCommunication.value</name> - <indexFieldType>COMMUNICATION</indexFieldType> - <additionalFieldNameAliases> - <element>comm</element> - </additionalFieldNameAliases> - <isMultiValued v="true" /> - </indexRecordFieldMapping> <indexRecordFieldMapping> <name>IndexAddress.value</name> <indexFieldType>ADDRESS</indexFieldType> @@ -1327,6 +1322,22 @@ </additionalFieldNameAliases> <isMultiValued v="true" /> </indexRecordFieldMapping> + <indexRecordFieldMapping> + <name>IndexCommunication.value</name> + <indexFieldType>COMMUNICATION</indexFieldType> + <additionalFieldNameAliases> + <element>comm</element> + </additionalFieldNameAliases> + <isMultiValued v="true" /> + </indexRecordFieldMapping> + <indexRecordFieldMapping> + <name>IndexCommPhone.value</name> + <indexFieldType>TELEPHONE</indexFieldType> + <additionalFieldNameAliases> + <element>phone</element> + </additionalFieldNameAliases> + <isMultiValued v="true" /> + </indexRecordFieldMapping> </indexFieldMappings> </indexRecordContainer> </recordContainers> diff --git a/entity/Organisation_entity/recordcontainers/index/query.js b/entity/Organisation_entity/recordcontainers/index/query.js index 4e2010d5d0553fbc9c3753cdabd77d161947fdb6..6bd8d82c9550fe160e97d27b7033e1977d7bacb0 100644 --- a/entity/Organisation_entity/recordcontainers/index/query.js +++ b/entity/Organisation_entity/recordcontainers/index/query.js @@ -7,34 +7,39 @@ import("Sql_lib"); import("Communication_lib"); var sqlQuery, sqlHelper, queryCondition, affectedIds; +var CommMediumPhoneIds = db.array( db.COLUMN, "select KEYID from AB_KEYWORD_ENTRY join ab_keyword_attributerelation on AB_KEYWORD_ENTRYID = AB_KEYWORD_ENTRY_ID " + + " join ab_keyword_attribute on AB_KEYWORD_ATTRIBUTEID = AB_KEYWORD_ATTRIBUTE_ID and CHAR_VALUE = 'TELEPHONE' and AB_KEYWORD_ATTRIBUTE.CONTAINER = 'CommunicationMedium'"); + if (vars.exists("$local.idvalue")) { affectedIds = vars.get("$local.idvalue"); queryCondition = "where CONTACT.CONTACTID in ('" + affectedIds.join("', '") + "')"; } sqlHelper = new SqlMaskingUtils(); -sqlQuery = "select CONTACT.CONTACTID " // as "_uid_" - + ", " + sqlHelper.concat(["ORGANISATION.NAME", "'|'", "ORGANISATION.CUSTOMERCODE"]) //as "_title_" +sqlQuery = "select CONTACT.CONTACTID " + + ", " + sqlHelper.concat(["ORGANISATION.NAME", "'|'", "ORGANISATION.CUSTOMERCODE"]) + ", " + sqlHelper.concat([ sqlHelper.concat(["defaultAddress.ADDRESS", "defaultAddress.BUILDINGNO", "'-'" ,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"]) ,sqlHelper.concat(["'" + translate.text("Phone") + ":'", "(" + CommUtil.getStandardSubSqlPhone() + ")"]) ,sqlHelper.concat(["'" + translate.text("Email") + ":'", "(" + CommUtil.getStandardSubSqlMail() + ")"]) - ], " | ") // as "_description_" + ], " | ") //additional indexed fields + ", ORGANISATION.NAME" + ", ORGANISATION.ORGANISATIONID" + ", CONTACT.CONTACTID" + ", ORGANISATION.CUSTOMERCODE" - + ", COMMUNICATION.ADDR " // as IndexCommunication - + ", ADDRESS.ADDRESS " // as IndexAddress - + ", ADDRESS.COUNTRY " // as IndexCountry - + ", ADDRESS.ZIP " // as IndexZIP - + ", ADDRESS.CITY " // as IndexCity + + ", ADDRESS.ADDRESS " + + ", ADDRESS.COUNTRY " + + ", ADDRESS.ZIP " + + ", ADDRESS.CITY " + + ", COMMUNICATION.ADDR " + + ", PHONE.ADDR " + " from ORGANISATION " + " join CONTACT on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null " + " left join ADDRESS defaultAddress on defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID " + " left join ADDRESS on ADDRESS.CONTACT_ID = CONTACT.CONTACTID " - + " left join COMMUNICATION on COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID " + + " left join COMMUNICATION on COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID and COMMUNICATION.MEDIUM_ID not in ('" + CommMediumPhoneIds.join("', '") + "')" + + " left join COMMUNICATION PHONE on PHONE.CONTACT_ID = CONTACT.CONTACTID and PHONE.MEDIUM_ID in ('" + CommMediumPhoneIds.join("', '") + "')" + (queryCondition || "") + " order by CONTACT.CONTACTID "; result.string(sqlQuery); diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index ece24d1b9c4be2970cf2573d28b49bf94852b655..293cde536cdc2cf4d660d6446bd0b922ff9328b0 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -1112,12 +1112,8 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <expose v="true" /> </entityParameter> <entityField> - <name>IndexPhoneticLastname</name> - <valueProcess>%aditoprj%/entity/Person_entity/entityfields/indexphoneticlastname/valueProcess.js</valueProcess> - </entityField> - <entityField> - <name>IndexPhoneticFirstname</name> - <valueProcess>%aditoprj%/entity/Person_entity/entityfields/indexphoneticfirstname/valueProcess.js</valueProcess> + <name>IndexCommPhone</name> + <valueProcess>%aditoprj%/entity/Person_entity/entityfields/indexcommphone/valueProcess.js</valueProcess> </entityField> <entityConsumer> <name>SelfDuplicatesUncached</name> @@ -1426,22 +1422,14 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <name>PERSON_ID.value</name> <indexFieldType>STRING</indexFieldType> </indexRecordFieldMapping> - <indexRecordFieldMapping> - <name>SALUTATION.value</name> - <indexFieldType>PHONETIC_NAME</indexFieldType> - </indexRecordFieldMapping> - <indexRecordFieldMapping> - <name>TITLE.value</name> - <indexFieldType>PHONETIC_NAME</indexFieldType> - </indexRecordFieldMapping> <indexRecordFieldMapping> <name>FIRSTNAME.value</name> - <indexFieldType>TEXT_NO_STOPWORDS</indexFieldType> + <indexFieldType>PHONETIC_NAME</indexFieldType> <isBoosted v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> <name>LASTNAME.value</name> - <indexFieldType>TEXT_NO_STOPWORDS</indexFieldType> + <indexFieldType>PHONETIC_NAME</indexFieldType> <isBoosted v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> @@ -1456,14 +1444,6 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <name>ORGANISATION_NAME.value</name> <indexFieldType>PROPER_NAME</indexFieldType> </indexRecordFieldMapping> - <indexRecordFieldMapping> - <name>IndexCommunication.value</name> - <indexFieldType>COMMUNICATION</indexFieldType> - <additionalFieldNameAliases> - <element>comm</element> - </additionalFieldNameAliases> - <isMultiValued v="true" /> - </indexRecordFieldMapping> <indexRecordFieldMapping> <name>IndexAddress.value</name> <indexFieldType>ADDRESS</indexFieldType> @@ -1497,18 +1477,20 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <isMultiValued v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> - <name>IndexPhoneticFirstname.value</name> - <indexFieldType>PHONETIC_NAME</indexFieldType> + <name>IndexCommunication.value</name> + <indexFieldType>COMMUNICATION</indexFieldType> <additionalFieldNameAliases> - <element>firstname</element> + <element>comm</element> </additionalFieldNameAliases> + <isMultiValued v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> - <name>IndexPhoneticLastname.value</name> - <indexFieldType>PHONETIC_NAME</indexFieldType> + <name>IndexCommPhone.value</name> + <indexFieldType>TELEPHONE</indexFieldType> <additionalFieldNameAliases> - <element>lastname</element> + <element>phone</element> </additionalFieldNameAliases> + <isMultiValued v="true" /> </indexRecordFieldMapping> </indexFieldMappings> </indexRecordContainer> diff --git a/entity/Person_entity/entityfields/indexphoneticlastname/valueProcess.js b/entity/Person_entity/entityfields/indexcommphone/valueProcess.js similarity index 100% rename from entity/Person_entity/entityfields/indexphoneticlastname/valueProcess.js rename to entity/Person_entity/entityfields/indexcommphone/valueProcess.js diff --git a/entity/Person_entity/entityfields/indexphoneticfirstname/valueProcess.js b/entity/Person_entity/entityfields/indexphoneticfirstname/valueProcess.js deleted file mode 100644 index f042d9baa7e49f984ee20a0bd47612d636f124e2..0000000000000000000000000000000000000000 --- a/entity/Person_entity/entityfields/indexphoneticfirstname/valueProcess.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.result"); -import("system.vars"); - -result.string(vars.get("$field.FIRSTNAME")); \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/index/query.js b/entity/Person_entity/recordcontainers/index/query.js index cb7a36c3abd0d9217b2c7848b6e2b4f53bbb3151..a9893146702ac8196ca3d768c6a84f82da9dcffe 100644 --- a/entity/Person_entity/recordcontainers/index/query.js +++ b/entity/Person_entity/recordcontainers/index/query.js @@ -7,42 +7,45 @@ import("Sql_lib"); import("Communication_lib"); var sqlQuery, sqlHelper, queryCondition, affectedIds; +var CommMediumPhoneIds = db.array( db.COLUMN, "select KEYID from AB_KEYWORD_ENTRY join ab_keyword_attributerelation on AB_KEYWORD_ENTRYID = AB_KEYWORD_ENTRY_ID " + + " join ab_keyword_attribute on AB_KEYWORD_ATTRIBUTEID = AB_KEYWORD_ATTRIBUTE_ID and CHAR_VALUE = 'TELEPHONE' and AB_KEYWORD_ATTRIBUTE.CONTAINER = 'CommunicationMedium'"); + if (vars.exists("$local.idvalue")) { affectedIds = vars.get("$local.idvalue"); queryCondition = "where CONTACT.CONTACTID in ('" + affectedIds.join("', '") + "')"; } + sqlHelper = new SqlMaskingUtils(); -sqlQuery = 'select CONTACT.CONTACTID ' // as "_uid_" - + "," + sqlHelper.concat(["PERSON.SALUTATION", "PERSON.FIRSTNAME", "PERSON.LASTNAME", "'|'", "ORGANISATION.NAME"]) // as "_title_" - + "," + sqlHelper.concat([ +sqlQuery = "select CONTACT.CONTACTID " + + "," + sqlHelper.concat(["PERSON.SALUTATION", "PERSON.FIRSTNAME", "PERSON.LASTNAME", "'|'", "ORGANISATION.NAME"]) + + "," + sqlHelper.concat([ sqlHelper.concat(["defaultAddress.ADDRESS", "defaultAddress.BUILDINGNO", "'-'" ,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"]) ,sqlHelper.concat(["'" + translate.text("Phone") + ":'", "(" + CommUtil.getStandardSubSqlPhone() + ")"]) ,sqlHelper.concat(["'" + translate.text("Email") + ":'", "(" + CommUtil.getStandardSubSqlMail() + ")"]) - ], " | ") // as "_description_" + ], " | ") //additional indexed fields + ", CONTACT.CONTACTID " + ", PERSON.PERSONID " - + ", PERSON.SALUTATION " - + ", PERSON.TITLE " // as "TITLE.value + ", PERSON.FIRSTNAME " + ", PERSON.LASTNAME " - + ", TRIM(PERSON.GENDER) " // as GENDER + + ", TRIM(PERSON.GENDER) " + ", CONTACT.ORGANISATION_ID " + ", ORGANISATION.NAME " - + ", COMMUNICATION.ADDR " // as IndexCommunication - + ", ADDRESS.ADDRESS " // as IndexAddress - + ", ADDRESS.COUNTRY " // as IndexCountry - + ", ADDRESS.ZIP " // as IndexZIP - + ", ADDRESS.CITY " // as IndexCity" - + ", PERSON.FIRSTNAME " // as IndexPhoneticFirstname - + ", PERSON.LASTNAME " // as IndexPhoneticLastname + + ", ADDRESS.ADDRESS " + + ", ADDRESS.COUNTRY " + + ", ADDRESS.ZIP " + + ", ADDRESS.CITY " + + ", COMMUNICATION.ADDR " + + ", PHONE.ADDR " + " from PERSON " + " join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID " + " join ORGANISATION on CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID " + " left join ADDRESS defaultAddress on defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID " + " left join ADDRESS on ADDRESS.CONTACT_ID = CONTACT.CONTACTID or ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID " - + " left join COMMUNICATION on COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID " + + " left join COMMUNICATION on COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID and COMMUNICATION.MEDIUM_ID not in ('" + CommMediumPhoneIds.join("', '") + "')" + + " left join COMMUNICATION PHONE on PHONE.CONTACT_ID = CONTACT.CONTACTID and PHONE.MEDIUM_ID in ('" + CommMediumPhoneIds.join("', '") + "')" + (queryCondition || "") + " order by CONTACT.CONTACTID "; + result.string(sqlQuery); \ No newline at end of file