From e2fd3d58904331c3207eeba7c8aff4e031491b4f Mon Sep 17 00:00:00 2001
From: "j.goderbauer" <j.goderbauer@adito.de>
Date: Tue, 27 Aug 2019 14:38:19 +0200
Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.: 1037815][Umsetzung
 Telefon- und Mailanbindung]

---
 .../Communication_entity/Communication_entity.aod   | 11 +++++++++++
 .../recordcontainers/groupextension/query.js        |  3 ++-
 .../recordcontainers/groupextension/subProcess.js   |  0
 .../UnlinkedMailMappingLink_entity.aod              |  2 ++
 .../documentation.adoc                              |  5 +++++
 .../recordcontainers/jdito/contentProcess.js        | 13 ++++++++-----
 .../recordcontainers/jdito/onInsert.js              | 11 +++++++++--
 .../recordcontainers/jdito/rowCountProcess.js       |  3 +++
 .../UnlinkedMailMappingWrapper_entity.aod           |  1 +
 .../unlinkedmailmappinglinks/documentation.adoc     |  2 ++
 entity/UnlinkedMail_entity/UnlinkedMail_entity.aod  |  8 ++++++++
 .../UnlinkedMailMappingWrapperMapping_view.aod      |  2 +-
 12 files changed, 52 insertions(+), 9 deletions(-)
 create mode 100644 entity/Communication_entity/recordcontainers/groupextension/subProcess.js
 create mode 100644 entity/UnlinkedMailMappingLink_entity/documentation.adoc
 create mode 100644 entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/rowCountProcess.js
 create mode 100644 entity/UnlinkedMailMappingWrapper_entity/entityfields/unlinkedmailmappinglinks/documentation.adoc

diff --git a/entity/Communication_entity/Communication_entity.aod b/entity/Communication_entity/Communication_entity.aod
index f45da937b4..ecc051c0a0 100644
--- a/entity/Communication_entity/Communication_entity.aod
+++ b/entity/Communication_entity/Communication_entity.aod
@@ -234,6 +234,9 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
       <expose v="true" />
       <documentation>%aditoprj%/entity/Communication_entity/entityfields/address_param/documentation.adoc</documentation>
     </entityParameter>
+    <entityField>
+      <name>SEARCHADDR</name>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -310,6 +313,7 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
       <indexRecordAlias>Data_alias</indexRecordAlias>
       <idColumn>COMMUNICATIONID</idColumn>
       <query>%aditoprj%/entity/Communication_entity/recordcontainers/groupextension/query.js</query>
+      <subProcess>%aditoprj%/entity/Communication_entity/recordcontainers/groupextension/subProcess.js</subProcess>
       <affectedTables>
         <element>COMMUNICATION</element>
         <element>AB_KEYWORD_ENTRY</element>
@@ -318,8 +322,15 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
         <indexRecordFieldMapping>
           <name>ADDR.value</name>
           <indexFieldType>COMMUNICATION</indexFieldType>
+          <additionalFieldNameAliases />
           <isMultiValued v="true" />
         </indexRecordFieldMapping>
+        <indexRecordFieldMapping>
+          <name>SEARCHADDR.value</name>
+          <indexFieldType>STRING</indexFieldType>
+          <isStored v="true" />
+          <isGlobalSearchField v="false" />
+        </indexRecordFieldMapping>
       </indexFieldMappings>
     </indexRecordContainer>
   </recordContainers>
diff --git a/entity/Communication_entity/recordcontainers/groupextension/query.js b/entity/Communication_entity/recordcontainers/groupextension/query.js
index 175c25d9aa..90e60238b1 100644
--- a/entity/Communication_entity/recordcontainers/groupextension/query.js
+++ b/entity/Communication_entity/recordcontainers/groupextension/query.js
@@ -10,7 +10,8 @@ if (vars.exists("$local.idvalue")) {
     //TODO: refactor this for incremental indexer (injections?)
 }
 
-sqlQuery = "select COMMUNICATION.COMMUNICATIONID" 
+sqlQuery = "select COMMUNICATION.COMMUNICATIONID"
+ + ', COMMUNICATION.COMMUNICATIONID as "_uid_"'
     + ", COMMUNICATION.ADDR" 
     + " from COMMUNICATION"
  + (queryCondition || "") 
diff --git a/entity/Communication_entity/recordcontainers/groupextension/subProcess.js b/entity/Communication_entity/recordcontainers/groupextension/subProcess.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/entity/UnlinkedMailMappingLink_entity/UnlinkedMailMappingLink_entity.aod b/entity/UnlinkedMailMappingLink_entity/UnlinkedMailMappingLink_entity.aod
index e749b7a469..c6c4c213d4 100644
--- a/entity/UnlinkedMailMappingLink_entity/UnlinkedMailMappingLink_entity.aod
+++ b/entity/UnlinkedMailMappingLink_entity/UnlinkedMailMappingLink_entity.aod
@@ -2,6 +2,7 @@
 <entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.11" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.11">
   <name>UnlinkedMailMappingLink_entity</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <documentation>%aditoprj%/entity/UnlinkedMailMappingLink_entity/documentation.adoc</documentation>
   <title>${UNLINKEDMAILMAPPING_ADDITIONAL_LINK}</title>
   <titlePlural>${UNLINKEDMAILMAPPING_ADDITIONAL_LINKS}</titlePlural>
   <recordContainer>jdito</recordContainer>
@@ -55,6 +56,7 @@
       <name>jdito</name>
       <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
       <contentProcess>%aditoprj%/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
+      <rowCountProcess>%aditoprj%/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/rowCountProcess.js</rowCountProcess>
       <onInsert>%aditoprj%/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/onInsert.js</onInsert>
       <recordFieldMappings>
         <jDitoRecordFieldMapping>
diff --git a/entity/UnlinkedMailMappingLink_entity/documentation.adoc b/entity/UnlinkedMailMappingLink_entity/documentation.adoc
new file mode 100644
index 0000000000..a63d45f86e
--- /dev/null
+++ b/entity/UnlinkedMailMappingLink_entity/documentation.adoc
@@ -0,0 +1,5 @@
+The purpose of this whole entity is to be a dummy datamodel that allows the user to provide some information.
+That's the reason why this entity has a dummy-jdito-record container that does nothing. 
+It does not load any "real" data and does not execute anything within the insert/update/delete progress.
+
+Currently this can only be solved with help of a dummy entity like this one here.
\ No newline at end of file
diff --git a/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/contentProcess.js b/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/contentProcess.js
index cfd1bf845e..1272eb14ad 100644
--- a/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/contentProcess.js
+++ b/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/contentProcess.js
@@ -1,11 +1,14 @@
-import("IncomingEmailExecutor_lib");
-import("system.mail");
-import("system.util");
-import("system.db");
 import("system.vars");
 import("system.result");
 
-var mailObject = null;
 var res = [];
+var idvalues = vars.get("$local.idvalues");
+if (idvalues)
+{
+    for (var i = 0, l = idvalues.length; i < l; i++) 
+    {
+        res.push([idvalues[i], "", ""]);
+    }
+}
 
 result.object(res);
\ No newline at end of file
diff --git a/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/onInsert.js b/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/onInsert.js
index d162d2aecc..9e1560a292 100644
--- a/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/onInsert.js
+++ b/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/onInsert.js
@@ -1,2 +1,9 @@
-/*nothing happens here, everything is done within the UnlinkedMailMappingWrapper
- --do not remove this comment otherwhile the kernel will detect that this process is empty and throws an error--*/
\ No newline at end of file
+import("system.datetime");
+
+/* In this process here basically nothing happens because everything is done within the UnlinkedMailMappingWrapper.
+ * To make the UnlinkedMailMappingLink_entity NOT read only we've to specify some code (comments excluded). This seems (and IS) odd but it's currenty
+ * the only way to do the job
+ * If you wan't more information about the entity and why it exists like this: See the documentation of the entity.
+ * 
+ * Tl;dr; do not remove the following line: */
+datetime.date();
\ No newline at end of file
diff --git a/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/rowCountProcess.js b/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/rowCountProcess.js
new file mode 100644
index 0000000000..9358b57687
--- /dev/null
+++ b/entity/UnlinkedMailMappingLink_entity/recordcontainers/jdito/rowCountProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string(0);
\ No newline at end of file
diff --git a/entity/UnlinkedMailMappingWrapper_entity/UnlinkedMailMappingWrapper_entity.aod b/entity/UnlinkedMailMappingWrapper_entity/UnlinkedMailMappingWrapper_entity.aod
index d2162015a9..e50f2bc980 100644
--- a/entity/UnlinkedMailMappingWrapper_entity/UnlinkedMailMappingWrapper_entity.aod
+++ b/entity/UnlinkedMailMappingWrapper_entity/UnlinkedMailMappingWrapper_entity.aod
@@ -46,6 +46,7 @@
     </entityConsumer>
     <entityConsumer>
       <name>UnlinkedMailMappingLinks</name>
+      <documentation>%aditoprj%/entity/UnlinkedMailMappingWrapper_entity/entityfields/unlinkedmailmappinglinks/documentation.adoc</documentation>
       <dependency>
         <name>dependency</name>
         <entityName>UnlinkedMailMappingLink_entity</entityName>
diff --git a/entity/UnlinkedMailMappingWrapper_entity/entityfields/unlinkedmailmappinglinks/documentation.adoc b/entity/UnlinkedMailMappingWrapper_entity/entityfields/unlinkedmailmappinglinks/documentation.adoc
new file mode 100644
index 0000000000..47f9f80930
--- /dev/null
+++ b/entity/UnlinkedMailMappingWrapper_entity/entityfields/unlinkedmailmappinglinks/documentation.adoc
@@ -0,0 +1,2 @@
+In the target entity basically nothing happens. It's only for configuring the creation of the activity.
+Within this entity (the UnlinkedMailMappingWrapper_entity) the data of the consumer is read and processed.
\ No newline at end of file
diff --git a/entity/UnlinkedMail_entity/UnlinkedMail_entity.aod b/entity/UnlinkedMail_entity/UnlinkedMail_entity.aod
index 816faae9a7..63295e0422 100644
--- a/entity/UnlinkedMail_entity/UnlinkedMail_entity.aod
+++ b/entity/UnlinkedMail_entity/UnlinkedMail_entity.aod
@@ -57,6 +57,14 @@
           <iconIdProcess>%aditoprj%/entity/UnlinkedMail_entity/entityfields/toactivity_actiongroup/children/toactivity_action/iconIdProcess.js</iconIdProcess>
           <tooltip>Try to create activity automatically and ask for more information if necessary</tooltip>
         </entityActionField>
+        <entityActionField>
+          <name>test</name>
+          <title>test</title>
+          <onActionProcess>%aditoprj%/entity/UnlinkedMail_entity/entityfields/toactivity_actiongroup/children/test/onActionProcess.js</onActionProcess>
+          <isMenuAction v="false" />
+          <isObjectAction v="false" />
+          <iconId>NEON:RECURRING_APPOINTMENT_MOVED</iconId>
+        </entityActionField>
       </children>
     </entityActionGroup>
   </entityFields>
diff --git a/neonView/UnlinkedMailMappingWrapperMapping_view/UnlinkedMailMappingWrapperMapping_view.aod b/neonView/UnlinkedMailMappingWrapperMapping_view/UnlinkedMailMappingWrapperMapping_view.aod
index 0686a25fef..ed47e7dc92 100644
--- a/neonView/UnlinkedMailMappingWrapperMapping_view/UnlinkedMailMappingWrapperMapping_view.aod
+++ b/neonView/UnlinkedMailMappingWrapperMapping_view/UnlinkedMailMappingWrapperMapping_view.aod
@@ -23,7 +23,7 @@
       </fields>
     </genericViewTemplate>
     <neonViewReference>
-      <name>10cbd0dc-4297-4703-ad84-b52312700f2e</name>
+      <name>7de3255c-edc7-469f-9836-0e56fab21921</name>
       <entityField>UnlinkedMailMappingLinks</entityField>
       <view>UnlinkedMailMappingLinkList_view</view>
     </neonViewReference>
-- 
GitLab