From bf3280200a8afad60f465dbacf39e5a431b69872 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Thu, 10 Jan 2019 10:05:36 +0100
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201030783][Vertriebsprojekt=20-=20Mitbewerber=20-=20Spalter=20?=
 =?UTF-8?q?Organisation=20wird=20noch=20nicht=20aufgel=C3=B6st]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 entity/Org_entity/Org_entity.aod              |  6 +++++
 entity/Pers_entity/Pers_entity.aod            | 23 ++-----------------
 .../org_id/displayValueProcess.js             |  8 -------
 .../org_id/linkedContextProcess.js            |  9 --------
 .../entityfields/pers_id/valueProcess.js      |  4 ----
 .../persid/displayValueProcess.js             |  0
 .../children/relid_param/code.js              | 22 +++++++++---------
 .../SalesprojectCompetition_entity.aod        | 15 ++++++++++++
 8 files changed, 34 insertions(+), 53 deletions(-)
 delete mode 100644 entity/Pers_entity/entityfields/org_id/displayValueProcess.js
 delete mode 100644 entity/Pers_entity/entityfields/org_id/linkedContextProcess.js
 delete mode 100644 entity/Pers_entity/entityfields/pers_id/valueProcess.js
 create mode 100644 entity/Pers_entity/entityfields/persid/displayValueProcess.js

diff --git a/entity/Org_entity/Org_entity.aod b/entity/Org_entity/Org_entity.aod
index 581d1c750e4..d56039b2ba6 100644
--- a/entity/Org_entity/Org_entity.aod
+++ b/entity/Org_entity/Org_entity.aod
@@ -353,6 +353,12 @@
           <fieldName>SalesprojectCompetitionOrg_dfo</fieldName>
           <isOutgoing v="false" />
         </entityDependency>
+        <entityDependency>
+          <name>14301a6c-7144-4d1b-800e-e4ca733769bb</name>
+          <entityName>SalesprojectCompetition_entity</entityName>
+          <fieldName>CompetitionOrg_lookup_dfo</fieldName>
+          <isOutgoing v="false" />
+        </entityDependency>
       </dependencies>
     </entityIncomingField>
     <entityField>
diff --git a/entity/Pers_entity/Pers_entity.aod b/entity/Pers_entity/Pers_entity.aod
index 67dfe2639ac..9624f5e5761 100644
--- a/entity/Pers_entity/Pers_entity.aod
+++ b/entity/Pers_entity/Pers_entity.aod
@@ -52,6 +52,7 @@
       <name>PERSID</name>
       <searchable v="false" />
       <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/persid/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/Pers_entity/entityfields/persid/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>SALUTATION</name>
@@ -143,19 +144,13 @@
         </entityDependency>
       </dependencies>
     </entityIncomingField>
-    <entityField>
-      <name>PERS_ID</name>
-      <searchable v="false" />
-      <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/pers_id/valueProcess.js</valueProcess>
-    </entityField>
     <entityField>
       <name>ORG_ID</name>
       <title>Firma</title>
-      <linkedContextProcess>%aditoprj%/entity/Pers_entity/entityfields/org_id/linkedContextProcess.js</linkedContextProcess>
+      <linkedContext>Org_context</linkedContext>
       <outgoingField>PersOrg_dfo</outgoingField>
       <searchable v="false" />
       <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/org_id/valueProcess.js</valueProcess>
-      <displayValueProcess>%aditoprj%/entity/Pers_entity/entityfields/org_id/displayValueProcess.js</displayValueProcess>
       <onValueChange>%aditoprj%/entity/Pers_entity/entityfields/org_id/onValueChange.js</onValueChange>
     </entityField>
     <entityField>
@@ -221,12 +216,6 @@
         </entityParameter>
       </children>
     </entityOutgoingField>
-    <entityField>
-      <name>ORGID</name>
-      <linkedContext>Org_context</linkedContext>
-      <outgoingField>PersOrg_dfo</outgoingField>
-      <searchable v="false" />
-    </entityField>
     <entityOutgoingField>
       <name>PersOrg_dfo</name>
       <fieldType>DEPENDENCY_OUT</fieldType>
@@ -511,10 +500,6 @@
           <name>PERSID.value</name>
           <recordfield>PERS.PERSID</recordfield>
         </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>ORGID.value</name>
-          <recordfield>ORG.ORGID</recordfield>
-        </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>DATEOFBIRTH.value</name>
           <recordfield>PERS.DATEOFBIRTH</recordfield>
@@ -535,10 +520,6 @@
           <name>LANGUAGE.value</name>
           <recordfield>RELATION.LANGUAGE</recordfield>
         </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>PERS_ID.value</name>
-          <recordfield>RELATION.PERS_ID</recordfield>
-        </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>LASTNAME.value</name>
           <recordfield>PERS.LASTNAME</recordfield>
diff --git a/entity/Pers_entity/entityfields/org_id/displayValueProcess.js b/entity/Pers_entity/entityfields/org_id/displayValueProcess.js
deleted file mode 100644
index 93bb6fe066b..00000000000
--- a/entity/Pers_entity/entityfields/org_id/displayValueProcess.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import("system.result");
-import("system.vars");
-import("Sql_lib");
-import("system.db");
-
-result.string(db.cell(SqlCondition.begin(db.getCurrentAlias())
-    .andPrepareVars("ORG.ORGID", "$field.ORG_ID", "# = ?")
-    .buildSelect("SELECT ORG.NAME FROM ORG", "1 = 2"), db.getCurrentAlias()));
diff --git a/entity/Pers_entity/entityfields/org_id/linkedContextProcess.js b/entity/Pers_entity/entityfields/org_id/linkedContextProcess.js
deleted file mode 100644
index cd8a3d2174a..00000000000
--- a/entity/Pers_entity/entityfields/org_id/linkedContextProcess.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import("system.vars");
-import("system.result");
-
-if(vars.get("$field.ORG_ID") != 0) {
-    result.string("Org_context");
-}
-else {
-    result.string("");
-}
\ No newline at end of file
diff --git a/entity/Pers_entity/entityfields/pers_id/valueProcess.js b/entity/Pers_entity/entityfields/pers_id/valueProcess.js
deleted file mode 100644
index 53099fc99d6..00000000000
--- a/entity/Pers_entity/entityfields/pers_id/valueProcess.js
+++ /dev/null
@@ -1,4 +0,0 @@
-import("system.vars");
-import("system.result");
-
-result.string(vars.getString("$field.PERSID"));
\ No newline at end of file
diff --git a/entity/Pers_entity/entityfields/persid/displayValueProcess.js b/entity/Pers_entity/entityfields/persid/displayValueProcess.js
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/entity/Pers_entity/entityfields/persorgsaddresses_dfo/children/relid_param/code.js b/entity/Pers_entity/entityfields/persorgsaddresses_dfo/children/relid_param/code.js
index 91438434939..30f588988c8 100644
--- a/entity/Pers_entity/entityfields/persorgsaddresses_dfo/children/relid_param/code.js
+++ b/entity/Pers_entity/entityfields/persorgsaddresses_dfo/children/relid_param/code.js
@@ -1,12 +1,12 @@
-import("system.result");
-import("system.db");
-import("system.vars");
-import("Sql_lib");
-
-var orgId = vars.get("$field.ORGID");
-if (orgId)
-{
-    var cond = SqlCondition.begin().and("RELATION.PERS_ID is null").andPrepare("RELATION.ORG_ID", orgId);
-    var orgRelId = db.cell(cond.buildSelect("select RELATION.RELATIONID from RELATION", "1 = 1"));
-    result.string(orgRelId);
+import("system.result");
+import("system.db");
+import("system.vars");
+import("Sql_lib");
+
+var orgId = vars.get("$field.ORG_ID");
+if (orgId)
+{
+    var cond = SqlCondition.begin().and("RELATION.PERS_ID is null").andPrepare("RELATION.ORG_ID", orgId);
+    var orgRelId = db.cell(cond.buildSelect("select RELATION.RELATIONID from RELATION", "1 = 1"));
+    result.string(orgRelId);
 }
\ No newline at end of file
diff --git a/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod b/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod
index f31ade89bbb..e3276ac8d54 100644
--- a/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod
+++ b/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod
@@ -78,6 +78,8 @@
     <entityField>
       <name>RELATION_ID</name>
       <title>Organisation</title>
+      <linkedContext>Org_context</linkedContext>
+      <outgoingField>CompetitionOrg_lookup_dfo</outgoingField>
     </entityField>
     <entityField>
       <name>ORG_NAME</name>
@@ -123,6 +125,15 @@
       <title>Weakness</title>
       <possibleItemsProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/org_weakness/possibleItemsProcess.js</possibleItemsProcess>
     </entityField>
+    <entityOutgoingField>
+      <name>CompetitionOrg_lookup_dfo</name>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>Org_entity</entityName>
+        <fieldName>SalesprojectCompetitionOrg_dfi</fieldName>
+      </dependency>
+    </entityOutgoingField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -211,6 +222,10 @@
           <name>ORG_WEAKNESS.value</name>
           <recordfield>ORG.WEAKNESS</recordfield>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>RELATION_ID.displayValue</name>
+          <recordfield>ORG.NAME</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
-- 
GitLab