From ae08e9984c1f1b03cf68a07f625152032f7413f3 Mon Sep 17 00:00:00 2001
From: "j.luginger" <j.luginger@JLuginger.aditosoftware.local>
Date: Thu, 28 Feb 2019 11:10:17 +0100
Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.: 1035026][[Person]:
 Anrede und Titel]

---
 entity/Person_entity/Person_entity.aod        | 11 ++++++++++
 .../salutation/possibleItemsProcess.js        |  0
 .../children/uiddefinition_param/code.js      |  3 +++
 .../children/uiddefinition_param/code.js      |  3 +++
 .../Salutation_entity/Salutation_entity.aod   | 21 +++++++++++++++++--
 .../entityfields/uid/titleProcess.js          | 11 ++++++++++
 .../entityfields/uid/valueProcess.js          | 12 +++++++++++
 .../contentProcess.js                         | 18 ++++++++++++++++
 entity/Salutation_entity/titleProcess.js      |  6 ++++++
 .../basic/2019.2/create_salutation.xml        |  2 +-
 10 files changed, 84 insertions(+), 3 deletions(-)
 create mode 100644 entity/Person_entity/entityfields/salutation/possibleItemsProcess.js
 create mode 100644 entity/Person_entity/entityfields/salutations/children/uiddefinition_param/code.js
 create mode 100644 entity/Person_entity/entityfields/salutationtitles/children/uiddefinition_param/code.js
 create mode 100644 entity/Salutation_entity/entityfields/uid/titleProcess.js
 create mode 100644 entity/Salutation_entity/entityfields/uid/valueProcess.js
 create mode 100644 entity/Salutation_entity/recordcontainers/distinctsalutation_jdito/contentProcess.js
 create mode 100644 entity/Salutation_entity/titleProcess.js

diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index 69d86391e6..49f121e1a5 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -49,6 +49,7 @@
       <name>SALUTATION</name>
       <title>Salutation</title>
       <consumer>Salutations</consumer>
+      <possibleItemsProcess>%aditoprj%/entity/Person_entity/entityfields/salutation/possibleItemsProcess.js</possibleItemsProcess>
     </entityField>
     <entityField>
       <name>TITLE</name>
@@ -551,6 +552,10 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
           <name>Language_param</name>
           <code>%aditoprj%/entity/Person_entity/entityfields/salutations/children/language_param/code.js</code>
         </entityParameter>
+        <entityParameter>
+          <name>uIdDefinition_param</name>
+          <code>%aditoprj%/entity/Person_entity/entityfields/salutations/children/uiddefinition_param/code.js</code>
+        </entityParameter>
       </children>
     </entityConsumer>
     <entityConsumer>
@@ -584,6 +589,12 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
         <entityName>Salutation_entity</entityName>
         <fieldName>Titles</fieldName>
       </dependency>
+      <children>
+        <entityParameter>
+          <name>uIdDefinition_param</name>
+          <code>%aditoprj%/entity/Person_entity/entityfields/salutationtitles/children/uiddefinition_param/code.js</code>
+        </entityParameter>
+      </children>
     </entityConsumer>
   </entityFields>
   <recordContainers>
diff --git a/entity/Person_entity/entityfields/salutation/possibleItemsProcess.js b/entity/Person_entity/entityfields/salutation/possibleItemsProcess.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/entity/Person_entity/entityfields/salutations/children/uiddefinition_param/code.js b/entity/Person_entity/entityfields/salutations/children/uiddefinition_param/code.js
new file mode 100644
index 0000000000..978d12e534
--- /dev/null
+++ b/entity/Person_entity/entityfields/salutations/children/uiddefinition_param/code.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("SALUTATION");
\ No newline at end of file
diff --git a/entity/Person_entity/entityfields/salutationtitles/children/uiddefinition_param/code.js b/entity/Person_entity/entityfields/salutationtitles/children/uiddefinition_param/code.js
new file mode 100644
index 0000000000..e2d104d4ae
--- /dev/null
+++ b/entity/Person_entity/entityfields/salutationtitles/children/uiddefinition_param/code.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("TITLE");
\ No newline at end of file
diff --git a/entity/Salutation_entity/Salutation_entity.aod b/entity/Salutation_entity/Salutation_entity.aod
index 45b480dcaf..ef6897d908 100644
--- a/entity/Salutation_entity/Salutation_entity.aod
+++ b/entity/Salutation_entity/Salutation_entity.aod
@@ -3,6 +3,7 @@
   <name>Salutation_entity</name>
   <title>Anrede</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <titleProcess>%aditoprj%/entity/Salutation_entity/titleProcess.js</titleProcess>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityProvider>
@@ -91,9 +92,9 @@
     <entityProvider>
       <name>Titles</name>
       <fieldType>DEPENDENCY_IN</fieldType>
-      <lookupIdfield>TITLE</lookupIdfield>
+      <lookupIdfield>UID</lookupIdfield>
       <titleProcess>%aditoprj%/entity/Salutation_entity/entityfields/titles/titleProcess.js</titleProcess>
-      <recordContainer>db</recordContainer>
+      <recordContainer>title_jdito</recordContainer>
       <dependencies>
         <entityDependency>
           <name>b6dff8b9-1eda-4cb1-97a0-2852756295b7</name>
@@ -111,7 +112,16 @@
     </entityParameter>
     <entityField>
       <name>UID</name>
+      <titleProcess>%aditoprj%/entity/Salutation_entity/entityfields/uid/titleProcess.js</titleProcess>
+      <valueProcess>%aditoprj%/entity/Salutation_entity/entityfields/uid/valueProcess.js</valueProcess>
     </entityField>
+    <entityParameter>
+      <name>uIdDefinition_param</name>
+      <expose v="true" />
+      <triggerRecalculation v="true" />
+      <mandatory v="false" />
+      <description>PARAMETER</description>
+    </entityParameter>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -172,10 +182,17 @@
     </dbRecordContainer>
     <jDitoRecordContainer>
       <name>distinctSalutation_jdito</name>
+      <title>Test</title>
       <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/Salutation_entity/recordcontainers/distinctsalutation_jdito/contentProcess.js</contentProcess>
       <recordFields>
         <element>UID.value</element>
+        <element>UID.displayValue</element>
       </recordFields>
     </jDitoRecordContainer>
+    <jDitoRecordContainer>
+      <name>title_jdito</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+    </jDitoRecordContainer>
   </recordContainers>
 </entity>
diff --git a/entity/Salutation_entity/entityfields/uid/titleProcess.js b/entity/Salutation_entity/entityfields/uid/titleProcess.js
new file mode 100644
index 0000000000..8e908a6ca5
--- /dev/null
+++ b/entity/Salutation_entity/entityfields/uid/titleProcess.js
@@ -0,0 +1,11 @@
+import("system.vars");
+import("system.result");
+
+var uIdDefinition = vars.get("$param.uIdDefinition_param")
+
+
+if(uIdDefinition == "SALUTATION")
+    result.string("Anrede")
+
+if(uIdDefinition == "TITLE")
+    result.string("Titel")
\ No newline at end of file
diff --git a/entity/Salutation_entity/entityfields/uid/valueProcess.js b/entity/Salutation_entity/entityfields/uid/valueProcess.js
new file mode 100644
index 0000000000..ef19222863
--- /dev/null
+++ b/entity/Salutation_entity/entityfields/uid/valueProcess.js
@@ -0,0 +1,12 @@
+//import("system.logging");
+//import("system.vars");
+//import("system.result");
+//
+//var uIdDefinition = vars.get("$param.uIdDefinition_param")
+//
+//
+//if(uIdDefinition == "SALUTATION")
+//    result.string(vars.get("$field.SALUTATION"))
+//
+//if(uIdDefinition == "TITLE")
+//    result.string(vars.get("$field.TITLE"))
diff --git a/entity/Salutation_entity/recordcontainers/distinctsalutation_jdito/contentProcess.js b/entity/Salutation_entity/recordcontainers/distinctsalutation_jdito/contentProcess.js
new file mode 100644
index 0000000000..577b640acd
--- /dev/null
+++ b/entity/Salutation_entity/recordcontainers/distinctsalutation_jdito/contentProcess.js
@@ -0,0 +1,18 @@
+import("system.logging");
+import("system.vars");
+import("system.result");
+import("system.db");
+import("Sql_lib");
+
+
+logging.log("kkkdjdkdjdf")
+var cond = SqlCondition.begin()
+    .and("SALUTATION is not NULL")
+    .buildSql("select distinct SALUTATION, SALUTATION from SALUTATION", "1=2");
+    
+var salutation = db.table(cond);
+logging.log(salutation)
+logging.log(cond)
+
+
+result.object(salutation);
\ No newline at end of file
diff --git a/entity/Salutation_entity/titleProcess.js b/entity/Salutation_entity/titleProcess.js
new file mode 100644
index 0000000000..a35437175f
--- /dev/null
+++ b/entity/Salutation_entity/titleProcess.js
@@ -0,0 +1,6 @@
+import("system.result");
+import("system.vars");
+
+if (vars.get("$param.uIdDefinition_param") && vars.exists("$param.uIdDefinition_param"))
+    result.string(vars.get("$field.UID"))
+else result.string("Anrede")
\ No newline at end of file
diff --git a/others/db_changes/data_alias/basic/2019.2/create_salutation.xml b/others/db_changes/data_alias/basic/2019.2/create_salutation.xml
index acf107ae03..7e3a196121 100644
--- a/others/db_changes/data_alias/basic/2019.2/create_salutation.xml
+++ b/others/db_changes/data_alias/basic/2019.2/create_salutation.xml
@@ -6,7 +6,7 @@
                 <constraints primaryKey="true" primaryKeyName="PK_SALUTATION_SALUTATIONID"/>
             </column>   
             <column name="HEADLINE" type="NVARCHAR(50)"/>                       
-            <column name="LANGUAGE" type="CHAR(36)"/>
+            <column name="LANGUAGE" type="CHAR(3)"/>
             <column name="LETTERSALUTATION" type="NVARCHAR(50)"/>
             <column name="SALUTATION" type="NVARCHAR(50)"/>
             <column name="SEX" type="CHAR(36)"/>
-- 
GitLab