Skip to content
Snippets Groups Projects
Commit d174a948 authored by Heinz Boesl's avatar Heinz Boesl Committed by Johannes Goderbauer
Browse files

improve the Index of Organisation and Person

# Conflicts:
#	entity/Organisation_entity/Organisation_entity.aod

# Conflicts:
#	entity/Organisation_entity/recordcontainers/index/query.js
#	entity/Person_entity/Person_entity.aod
#	entity/Person_entity/recordcontainers/index/query.js
parent 1303576b
No related branches found
No related tags found
No related merge requests found
......@@ -1009,6 +1009,9 @@
<name>OnlyOwnSupervised_param</name>
<expose v="true" />
</entityParameter>
<entityField>
<name>IndexCommPhone</name>
</entityField>
<entityConsumer>
<name>SelfDuplicatesUncached</name>
<dependency>
......@@ -1251,14 +1254,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>
......@@ -1291,6 +1286,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>
......
......@@ -6,30 +6,35 @@ import("system.db");
import("Sql_lib");
import("Communication_lib");
//TODO: refactor to new SqlBuilder
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'");
var sqlHelper = new SqlMaskingUtils();
var querySelect = newSelect("CONTACT.CONTACTID " // as "_uid_"
+ ", " + sqlHelper.concat(["ORGANISATION.NAME", "'|'", "ORGANISATION.CUSTOMERCODE"]) //as "_title_"
var querySelect = newSelect("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
], " | ")
//additional indexed fields
+ ", ORGANISATION.NAME"
+ ", ORGANISATION.ORGANISATIONID"
+ ", CONTACT.CONTACTID"
+ ", ORGANISATION.CUSTOMERCODE"
+ ", ADDRESS.ADDRESS "
+ ", ADDRESS.COUNTRY "
+ ", ADDRESS.ZIP "
+ ", ADDRESS.CITY "
+ ", COMMUNICATION.ADDR "
+ ", PHONE.ADDR "
.from("ORGANISATION")
.join("CONTACT", "CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null")
.leftJoin("ADDRESS", "defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID", "defaultAddress")
.leftJoin("ADDRESS", "ADDRESS.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", "PHONE.CONTACT_ID = CONTACT.CONTACTID and PHONE.MEDIUM_ID in ('" + CommMediumPhoneIds.join("', '") + "'), "PHONE")//TODO: refactor to new SqlBuilder
if (vars.exists("$local.idvalue") && vars.get("$local.idvalue") && vars.get("$local.idvalue").length > 0)
{
......
......@@ -1067,6 +1067,32 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<name>OnlyOwnSupervised_param</name>
<expose v="true" />
</entityParameter>
<entityField>
<name>IndexCommPhone</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/indexcommphone/valueProcess.js</valueProcess>
</entityField>
<entityConsumer>
<name>SelfDuplicatesUncached</name>
<dependency>
<name>dependency</name>
<entityName>Person_entity</entityName>
<fieldName>SelfDuplicatesProvider</fieldName>
</dependency>
<children>
<entityParameter>
<name>DuplicateActionsControl_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicatesuncached/children/duplicateactionscontrol_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>DuplicateCurrentContactId_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicatesuncached/children/duplicatecurrentcontactid_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>OnlyShowContactIds_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -1350,20 +1376,14 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<isBoosted v="true" />
</indexRecordFieldMapping>
<indexRecordFieldMapping>
<name>SALUTATION.value</name>
<name>FIRSTNAME.value</name>
<indexFieldType>PHONETIC_NAME</indexFieldType>
<isBoosted v="true" />
</indexRecordFieldMapping>
<indexRecordFieldMapping>
<name>TITLE.value</name>
<name>LASTNAME.value</name>
<indexFieldType>PHONETIC_NAME</indexFieldType>
</indexRecordFieldMapping>
<indexRecordFieldMapping>
<name>ORGANISATION_ID.value</name>
<indexFieldType>STRING</indexFieldType>
</indexRecordFieldMapping>
<indexRecordFieldMapping>
<name>ORGANISATION_NAME.value</name>
<indexFieldType>PROPER_NAME</indexFieldType>
<isBoosted v="true" />
</indexRecordFieldMapping>
<indexRecordFieldMapping>
<name>PERSON_ID.value</name>
......@@ -1418,18 +1438,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>
......
import("system.result");
import("system.vars");
result.string(vars.get("$field.FIRSTNAME"));
\ No newline at end of file
......@@ -6,38 +6,39 @@ import("system.db");
import("Sql_lib");
import("Communication_lib");
//TODO: refactor to new SqlBuilder
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'");
var sqlHelper = new SqlMaskingUtils();
var querySelect = newSelect("CONTACT.CONTACTID as \"_uid_\""
+ "," + sqlHelper.concat(["PERSON.SALUTATION", "PERSON.FIRSTNAME", "PERSON.LASTNAME", "'|'", "ORGANISATION.NAME"]) // as "_title_"
var querySelect = newSelect("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
+ ", 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 ")
], " | ") "
//additional indexed fields
+ ", CONTACT.CONTACTID "
+ ", PERSON.PERSONID "
+ ", PERSON.FIRSTNAME "
+ ", PERSON.LASTNAME "
+ ", TRIM(PERSON.GENDER) "
+ ", CONTACT.ORGANISATION_ID "
+ ", ORGANISATION.NAME "
+ ", ADDRESS.ADDRESS "
+ ", ADDRESS.COUNTRY "
+ ", ADDRESS.ZIP "
+ ", ADDRESS.CITY "
+ ", COMMUNICATION.ADDR "
+ ", PHONE.ADDR "
.from("PERSON")
.join("CONTACT", "CONTACT.PERSON_ID = PERSON.PERSONID")
.join("ORGANISATION", "CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID")
.leftJoin("ADDRESS", "defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID", "defaultAddress")
.leftJoin("ADDRESS", "ADDRESS.CONTACT_ID = CONTACT.CONTACTID or ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID")
.leftJoin("COMMUNICATION", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", "PHONE.CONTACT_ID = CONTACT.CONTACTID and PHONE.MEDIUM_ID in ('" + CommMediumPhoneIds.join("', '") + "'), "PHONE")//TODO: refactor to new SqlBuilder
.orderBy("CONTACT.CONTACTID");
if (vars.exists("$local.idvalue")) {
......@@ -45,4 +46,5 @@ if (vars.exists("$local.idvalue")) {
sqlQuery.whereIfSet("CONTACT.CONTACTID", affectedIds, SqlBuilder.IN());
}
result.string(sqlQuery);
\ 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