From f91263007e34f554b745650fefa74d0c86e2c89a Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Tue, 12 Nov 2019 16:44:07 +0100
Subject: [PATCH] correct alias & use sqlBuilder

---
 .../PermissionDetail_entity.aod               |  2 +-
 entity/Person_entity/Person_entity.aod        |  6 -----
 .../recordcontainers/index/affectedIds.js     | 25 +++++++++++++------
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/entity/PermissionDetail_entity/PermissionDetail_entity.aod b/entity/PermissionDetail_entity/PermissionDetail_entity.aod
index 13f858e6eb..e62d1cbaeb 100644
--- a/entity/PermissionDetail_entity/PermissionDetail_entity.aod
+++ b/entity/PermissionDetail_entity/PermissionDetail_entity.aod
@@ -201,7 +201,7 @@
   <recordContainers>
     <jDitoRecordContainer>
       <name>jDito</name>
-      <jDitoRecordAlias>_____SYSTEMALIAS</jDitoRecordAlias>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
       <contentProcess>%aditoprj%/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
       <onInsert>%aditoprj%/entity/PermissionDetail_entity/recordcontainers/jdito/onInsert.js</onInsert>
       <onUpdate>%aditoprj%/entity/PermissionDetail_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index 233a335676..ce7b25e84a 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -1337,17 +1337,11 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
           <name>FIRSTNAME.value</name>
           <indexFieldType>TEXT_NO_STOPWORDS</indexFieldType>
           <isBoosted v="true" />
-          <name>FIRSTNAME.value</name>
-          <indexFieldType>PHONETIC_NAME</indexFieldType>
-          <isBoosted v="true" />
         </indexRecordFieldMapping>
         <indexRecordFieldMapping>
           <name>LASTNAME.value</name>
           <indexFieldType>TEXT_NO_STOPWORDS</indexFieldType>
           <isBoosted v="true" />
-          <name>LASTNAME.value</name>
-          <indexFieldType>PHONETIC_NAME</indexFieldType>
-          <isBoosted v="true" />
         </indexRecordFieldMapping>
         <indexRecordFieldMapping>
           <name>SALUTATION.value</name>
diff --git a/entity/Person_entity/recordcontainers/index/affectedIds.js b/entity/Person_entity/recordcontainers/index/affectedIds.js
index 488e44a0b1..24ea484ba1 100644
--- a/entity/Person_entity/recordcontainers/index/affectedIds.js
+++ b/entity/Person_entity/recordcontainers/index/affectedIds.js
@@ -19,23 +19,32 @@ switch (tableName)
         res = [idValue];
         break;    
     case "PERSON":
-        res = db.array(db.COLUMN, "select CONTACT.CONTACTID from CONTACT where CONTACT.PERSON_ID = '" + idValue + "'");
+        res = newSelect("CONTACT.CONTACTID")
+                    .from("CONTACT")
+                    .where("CONTACT.PERSON_ID", idValue)
+                    .arrayColumn();
         break;
     case "ORGANISATION":
-        res = db.array(db.COLUMN, "select CONTACT.CONTACTID from CONTACT where CONTACT.PERSON_ID is not null and CONTACT.ORGANISATION_ID = '" + idValue + "'");
+        res = newSelect("CONTACT.CONTACTID")
+                    .from("CONTACT")
+                    .where("CONTACT.ORGANISATION_ID", idValue)
+                    .and("CONTACT.PERSON_ID is not null")
+                    .arrayColumn();
         break;
     case "ADDRESS":
         res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){
-            return db.array(db.COLUMN, ["select ADDRESS.CONTACT_ID from ADDRESS where ADDRESS.ADDRESSID = ?", [
-                    [id, SqlUtils.getSingleColumnType("ADDRESS", "ADDRESSID")]
-            ]]);
+            return newSelect("ADDRESS.CONTACT_ID")
+                    .from("ADDRESS")
+                    .where("ADDRESS.ADDRESSID", id)
+                    .arrayColumn();
         });
         break;
     case "COMMUNICATION":
         res = IndexsearchUtils.getAffectedIdValues("CONTACT_ID", infoContainer, function (id){
-            return db.array(db.COLUMN, ["select COMMUNICATION.CONTACT_ID from COMMUNICATION where COMMUNICATIONID = ?", [
-                    [id, SqlUtils.getSingleColumnType("COMMUNICATION", "COMMUNICATIONID")]
-            ]]);
+            return newSelect("COMMUNICATION.CONTACT_ID")
+                    .from("COMMUNICATION")
+                    .where("COMMUNICATION.COMMUNICATIONID", id)
+                    .arrayColumn();
         });
         break;
 }
-- 
GitLab