From 21e9dbb3cb17bca4fbbc3cfd6e00ae78da7729c5 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Mon, 4 Feb 2019 13:43:45 +0100
Subject: [PATCH] wip

---
 entity/Context_entity/Context_entity.aod      | 40 +++++++++++++
 .../recordcontainers/jdito/contentProcess.js  | 11 ++++
 entity/Context_entity/titleProcess.js         |  4 ++
 .../ObjectRelation_entity.aod                 | 29 +++++++--
 .../object1_rowid/stateProcess.js             | 14 +++++
 .../object1_rowid/valueProcess.js             | 16 +++++
 .../object1_type/displayValueProcess.js       | 18 ++++++
 .../entityfields/object1_type/stateProcess.js | 13 ++++
 .../entityfields/object1_type/valueProcess.js | 18 ++++++
 .../object2_rowid/stateProcess.js             | 12 ++++
 .../object2_rowid/valueProcess.js             | 12 ++++
 .../entityfields/object2_type/stateProcess.js | 10 ++++
 .../entityfields/object2_type/valueProcess.js | 12 ++++
 .../object1_rowid.displayvalue/expression.js  |  1 +
 .../object2_rowid.displayvalue/expression.js  |  1 +
 entity/Pers_entity/Pers_entity.aod            |  1 -
 .../children/anyobjecttype_param/code.js      |  2 +-
 .../Context_context/Context_context.aod       | 13 ++++
 .../ObjectRelation_context.aod                |  5 ++
 .../ContextLookup_view/ContextLookup_view.aod | 26 ++++++++
 .../ObjectRelationEdit_view.aod               | 35 +++++++++++
 .../_____PREFERENCES_PROJECT.aod              |  2 +-
 process/Context_lib/process.js                | 60 ++++++++++++++++---
 process/Entity_lib/process.js                 |  1 -
 .../ObjectRelation_lib/ObjectRelation_lib.aod |  9 +++
 process/ObjectRelation_lib/process.js         | 15 +++++
 26 files changed, 363 insertions(+), 17 deletions(-)
 create mode 100644 entity/Context_entity/Context_entity.aod
 create mode 100644 entity/Context_entity/recordcontainers/jdito/contentProcess.js
 create mode 100644 entity/Context_entity/titleProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object1_rowid/stateProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object2_rowid/stateProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js
 create mode 100644 entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js
 create mode 100644 neonContext/Context_context/Context_context.aod
 create mode 100644 neonView/ContextLookup_view/ContextLookup_view.aod
 create mode 100644 neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod
 create mode 100644 process/ObjectRelation_lib/ObjectRelation_lib.aod
 create mode 100644 process/ObjectRelation_lib/process.js

diff --git a/entity/Context_entity/Context_entity.aod b/entity/Context_entity/Context_entity.aod
new file mode 100644
index 00000000000..78700e60337
--- /dev/null
+++ b/entity/Context_entity/Context_entity.aod
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.1.1">
+  <name>Context_entity</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <titleProcess>%aditoprj%/entity/Context_entity/titleProcess.js</titleProcess>
+  <recordContainer>jdito</recordContainer>
+  <entityFields>
+    <entityIncomingField>
+      <name>#INCOMING</name>
+      <recordContainer>jdito</recordContainer>
+      <dependencies>
+        <entityDependency>
+          <name>40037d07-01a3-474a-aaf6-875aaf250bbf</name>
+          <entityName>ObjectRelation_entity</entityName>
+          <fieldName>Context_dfo</fieldName>
+          <isOutgoing v="false" />
+        </entityDependency>
+      </dependencies>
+    </entityIncomingField>
+    <entityField>
+      <name>UID</name>
+      <title>Context id</title>
+    </entityField>
+    <entityField>
+      <name>CONTEXT_NAME</name>
+      <title>Context name</title>
+    </entityField>
+  </entityFields>
+  <recordContainers>
+    <jDitoRecordContainer>
+      <name>jdito</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/Context_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
+      <recordFields>
+        <element>UID.value</element>
+        <element>CONTEXT_NAME.value</element>
+      </recordFields>
+    </jDitoRecordContainer>
+  </recordContainers>
+</entity>
diff --git a/entity/Context_entity/recordcontainers/jdito/contentProcess.js b/entity/Context_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 00000000000..b680913caaa
--- /dev/null
+++ b/entity/Context_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,11 @@
+import("system.result");
+import("system.project");
+import("system.logging");
+import("Context_lib");
+
+var contextNames = project.getDataModelNames(project.DATAMODEL_KIND_CONTEXT);
+// var contextModels = project.getDataModels(project.DATAMODEL_KIND_CONTEXT, contextNames);
+
+result.object(contextNames.map(function(contextName) {
+    return [contextName, ContextUtils.getContextName(contextName)];
+}));
\ No newline at end of file
diff --git a/entity/Context_entity/titleProcess.js b/entity/Context_entity/titleProcess.js
new file mode 100644
index 00000000000..1733703a2a6
--- /dev/null
+++ b/entity/Context_entity/titleProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.CONTEXT_NAME"))
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/ObjectRelation_entity.aod b/entity/ObjectRelation_entity/ObjectRelation_entity.aod
index 76b6aec8681..e5c221ca10f 100644
--- a/entity/ObjectRelation_entity/ObjectRelation_entity.aod
+++ b/entity/ObjectRelation_entity/ObjectRelation_entity.aod
@@ -12,11 +12,17 @@
     <entityField>
       <name>OBJECT1_TYPE</name>
       <title>Type 1</title>
+      <outgoingField>Context_dfo</outgoingField>
+      <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js</stateProcess>
+      <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>OBJECT1_ROWID</name>
       <title>Object 1</title>
       <linkedContextProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/linkedContextProcess.js</linkedContextProcess>
+      <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/stateProcess.js</stateProcess>
+      <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>AB_OBJECTRELATIONID</name>
@@ -47,10 +53,16 @@
       <name>OBJECT2_ROWID</name>
       <title>Object 2</title>
       <linkedContextProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/linkedContextProcess.js</linkedContextProcess>
+      <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/stateProcess.js</stateProcess>
+      <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>OBJECT2_TYPE</name>
       <title>Type 2</title>
+      <linkedContext>Context_context</linkedContext>
+      <outgoingField>Context_dfo</outgoingField>
+      <stateProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js</stateProcess>
+      <valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js</valueProcess>
     </entityField>
     <entityParameter>
       <name>Object1Type_param</name>
@@ -231,19 +243,19 @@
       <children>
         <entityParameter>
           <name>Object1Rowid_param</name>
-          <expose v="false" />
+          <expose v="true" />
         </entityParameter>
         <entityParameter>
           <name>Object1Type_param</name>
-          <expose v="false" />
+          <expose v="true" />
         </entityParameter>
         <entityParameter>
           <name>Object2Rowid_param</name>
-          <expose v="false" />
+          <expose v="true" />
         </entityParameter>
         <entityParameter>
           <name>Object2Type_param</name>
-          <expose v="false" />
+          <expose v="true" />
         </entityParameter>
         <entityParameter>
           <name>AnyObjectRowid_param</name>
@@ -255,6 +267,15 @@
         </entityParameter>
       </children>
     </entityIncomingField>
+    <entityOutgoingField>
+      <name>Context_dfo</name>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>Context_entity</entityName>
+        <fieldName>#INCOMING</fieldName>
+      </dependency>
+    </entityOutgoingField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/ObjectRelation_entity/entityfields/object1_rowid/stateProcess.js b/entity/ObjectRelation_entity/entityfields/object1_rowid/stateProcess.js
new file mode 100644
index 00000000000..5f470da0cc2
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object1_rowid/stateProcess.js
@@ -0,0 +1,14 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+
+    if ((vars.exists("$param.AnyObjectRowid_param") && vars.get("$param.AnyObjectRowid_param"))
+        || (vars.exists("$param.Object1Rowid_param") && vars.get("$param.Object1Rowid_param")))
+    {
+        result.string(neon.COMPONENTSTATE_READONLY);
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js b/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js
new file mode 100644
index 00000000000..d189f026bbd
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object1_rowid/valueProcess.js
@@ -0,0 +1,16 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if (vars.exists("$param.AnyObjectRowid_param") && vars.get("$param.AnyObjectRowid_param"))
+    {
+        result.string(vars.get("$param.AnyObjectRowid_param"));
+    }
+    else if (vars.exists("$param.Object1Rowid_param") && vars.get("$param.Object1Rowid_param"))
+    {
+        result.string(vars.get("$param.Object1Rowid_param"));
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js b/entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js
new file mode 100644
index 00000000000..8a80d4be7ef
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object1_type/displayValueProcess.js
@@ -0,0 +1,18 @@
+import("system.logging");
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if (vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param"))
+    {
+        logging.log(vars.get("$param.AnyObjectType_param"));
+        result.string("disp: " + vars.get("$param.AnyObjectType_param"));
+    }
+    else if (vars.exists("$param.Object1Type_param") && vars.get("$param.Object1Type_param"))
+    {
+        result.string("disp: " + vars.get("$param.Object1Type_param"));
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js b/entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js
new file mode 100644
index 00000000000..2160ef62efa
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object1_type/stateProcess.js
@@ -0,0 +1,13 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if ((vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param"))
+        || (vars.exists("$param.Object1Type_param") && vars.get("$param.Object1Type_param")))
+    {
+        result.string(neon.COMPONENTSTATE_READONLY);
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js b/entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js
new file mode 100644
index 00000000000..4ad606ce758
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object1_type/valueProcess.js
@@ -0,0 +1,18 @@
+import("system.logging");
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if (vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param"))
+    {
+        logging.log(vars.get("$param.AnyObjectType_param"));
+        result.string(vars.get("$param.AnyObjectType_param"));
+    }
+    else if (vars.exists("$param.Object1Type_param") && vars.get("$param.Object1Type_param"))
+    {
+        result.string(vars.get("$param.Object1Type_param"));
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object2_rowid/stateProcess.js b/entity/ObjectRelation_entity/entityfields/object2_rowid/stateProcess.js
new file mode 100644
index 00000000000..b78d71076c7
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object2_rowid/stateProcess.js
@@ -0,0 +1,12 @@
+import("system.logging");
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    logging.log(vars.exists("$param.Object2Rowid_param") && vars.get("$param.Object2Rowid_param"))
+    if (vars.exists("$param.Object2Rowid_param") && vars.get("$param.Object2Rowid_param"))
+        result.string(neon.COMPONENTSTATE_READONLY);
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js b/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js
new file mode 100644
index 00000000000..710c40de475
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object2_rowid/valueProcess.js
@@ -0,0 +1,12 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if (vars.exists("$param.Object2Rowid_param") && vars.get("$param.Object2Rowid_param"))
+    {
+        result.string(vars.get("$param.Object2Rowid_param"));
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js b/entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js
new file mode 100644
index 00000000000..7d99ab991e0
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object2_type/stateProcess.js
@@ -0,0 +1,10 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if (vars.exists("$param.Object2Type_param") && vars.get("$param.Object2Type_param"))
+        result.string(neon.COMPONENTSTATE_READONLY);
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js b/entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js
new file mode 100644
index 00000000000..57711c82d25
--- /dev/null
+++ b/entity/ObjectRelation_entity/entityfields/object2_type/valueProcess.js
@@ -0,0 +1,12 @@
+import("system.result");
+import("system.neon");
+import("system.vars");
+
+var recordstate = vars.get("$sys.recordstate");
+if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
+{
+    if (vars.exists("$param.Object2Type_param") && vars.get("$param.Object2Type_param"))
+    {
+        result.string(vars.get("$param.Object2Type_param"));
+    }
+}
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object1_rowid.displayvalue/expression.js b/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object1_rowid.displayvalue/expression.js
index 3333669e4c6..7534f59b799 100644
--- a/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object1_rowid.displayvalue/expression.js
+++ b/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object1_rowid.displayvalue/expression.js
@@ -1,4 +1,5 @@
 import("system.result");
 import("Context_lib");
 
+// TODO: no subselect?
 result.string(ContextUtils.getNameSubselectSql("OBJECT1_TYPE", "OBJECT1_ROWID"))
\ No newline at end of file
diff --git a/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object2_rowid.displayvalue/expression.js b/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object2_rowid.displayvalue/expression.js
index bb0a5084254..261298d7050 100644
--- a/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object2_rowid.displayvalue/expression.js
+++ b/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object2_rowid.displayvalue/expression.js
@@ -1,4 +1,5 @@
 import("system.result");
 import("Context_lib");
 
+// TODO: no subselect?
 result.string(ContextUtils.getNameSubselectSql("OBJECT2_TYPE", "OBJECT2_ROWID"))
\ No newline at end of file
diff --git a/entity/Pers_entity/Pers_entity.aod b/entity/Pers_entity/Pers_entity.aod
index 834f62928bf..3ea38fd37c8 100644
--- a/entity/Pers_entity/Pers_entity.aod
+++ b/entity/Pers_entity/Pers_entity.aod
@@ -513,7 +513,6 @@
       <children>
         <entityParameter>
           <name>AnyObjectRowid_param</name>
-          <title></title>
           <code>%aditoprj%/entity/Pers_entity/entityfields/objectrelation_dfo/children/anyobjectrowid_param/code.js</code>
         </entityParameter>
         <entityParameter>
diff --git a/entity/Pers_entity/entityfields/objectrelation_dfo/children/anyobjecttype_param/code.js b/entity/Pers_entity/entityfields/objectrelation_dfo/children/anyobjecttype_param/code.js
index efc405cb8b7..008915f61de 100644
--- a/entity/Pers_entity/entityfields/objectrelation_dfo/children/anyobjecttype_param/code.js
+++ b/entity/Pers_entity/entityfields/objectrelation_dfo/children/anyobjecttype_param/code.js
@@ -1,4 +1,4 @@
 import("system.result");
 import("Context_lib");
 
-result.string(ContextUtils.getCurrentContextId())
\ No newline at end of file
+result.string(ContextUtils.getCurrentContextId());
\ No newline at end of file
diff --git a/neonContext/Context_context/Context_context.aod b/neonContext/Context_context/Context_context.aod
new file mode 100644
index 00000000000..9d48a70d99b
--- /dev/null
+++ b/neonContext/Context_context/Context_context.aod
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.0.0">
+  <name>Context_context</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <lookupview>ContextLookup_view</lookupview>
+  <entity>Context_entity</entity>
+  <references>
+    <neonViewReference>
+      <name>3eedbcba-63f3-4825-852a-ab8269343e9a</name>
+      <view>ContextLookup_view</view>
+    </neonViewReference>
+  </references>
+</neonContext>
diff --git a/neonContext/ObjectRelation_context/ObjectRelation_context.aod b/neonContext/ObjectRelation_context/ObjectRelation_context.aod
index 4e07153b0da..c077fd895d6 100644
--- a/neonContext/ObjectRelation_context/ObjectRelation_context.aod
+++ b/neonContext/ObjectRelation_context/ObjectRelation_context.aod
@@ -3,6 +3,7 @@
   <name>ObjectRelation_context</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <filterview>ObjectRelationFilter_view</filterview>
+  <editview>ObjectRelationEdit_view</editview>
   <preview>ObjectRelationPreview_view</preview>
   <entity>ObjectRelation_entity</entity>
   <references>
@@ -14,5 +15,9 @@
       <name>dc0bd793-a472-4a7b-8394-06c4bc31258a</name>
       <view>ObjectRelationPreview_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>3b480346-0cf4-44ee-9422-1693b386aa86</name>
+      <view>ObjectRelationEdit_view</view>
+    </neonViewReference>
   </references>
 </neonContext>
diff --git a/neonView/ContextLookup_view/ContextLookup_view.aod b/neonView/ContextLookup_view/ContextLookup_view.aod
new file mode 100644
index 00000000000..caa1d92103c
--- /dev/null
+++ b/neonView/ContextLookup_view/ContextLookup_view.aod
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.1">
+  <name>ContextLookup_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <tableViewTemplate>
+      <name>contexts</name>
+      <entityField>#ENTITY</entityField>
+      <columns>
+        <neonTableColumn>
+          <name>a748ea55-7c16-4b09-81f3-0bf88674e18a</name>
+          <entityField>UID</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>e3178147-3010-48e2-b23c-022e1badc3f7</name>
+          <entityField>CONTEXT_NAME</entityField>
+        </neonTableColumn>
+      </columns>
+    </tableViewTemplate>
+  </children>
+</neonView>
diff --git a/neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod b/neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod
new file mode 100644
index 00000000000..a3d6d915729
--- /dev/null
+++ b/neonView/ObjectRelationEdit_view/ObjectRelationEdit_view.aod
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.1">
+  <name>ObjectRelationEdit_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <genericViewTemplate>
+      <name>ObjectRelationData</name>
+      <editMode v="true" />
+      <entityField>#ENTITY</entityField>
+      <fields>
+        <entityFieldLink>
+          <name>ba83e512-e1d3-4c21-a4d3-067df3816e74</name>
+          <entityField>OBJECT1_TYPE</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>86f45e13-f96b-4d84-908b-444e238bb9ea</name>
+          <entityField>OBJECT1_ROWID</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>3415855d-b97e-46df-9bee-6b33101b950a</name>
+          <entityField>OBJECT2_TYPE</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>e9bb5d31-712f-4643-b183-61584400707c</name>
+          <entityField>OBJECT2_ROWID</entityField>
+        </entityFieldLink>
+      </fields>
+    </genericViewTemplate>
+  </children>
+</neonView>
diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
index 336d6b092bd..5edf76c7779 100644
--- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
+++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
@@ -2,7 +2,7 @@
 <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.3" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.3">
   <name>_____PREFERENCES_PROJECT</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
-  <projectName>xRM-Basic2019</projectName>
+  <projectName>xRM-Basic5</projectName>
   <jditoMaxContentSize v="57671680" />
   <calendarCategoriesEvent>
     <entry>
diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js
index 34ae91ccc4b..ba515aa7454 100644
--- a/process/Context_lib/process.js
+++ b/process/Context_lib/process.js
@@ -1,3 +1,5 @@
+import("system.logging");
+import("system.project");
 import("system.SQLTYPES");
 import("system.vars");
 import("Sql_lib");
@@ -19,6 +21,8 @@ function ContextUtils() {}
 ContextUtils.getCurrentContextId = function() 
 {
     var entityName = vars.getString("$sys.currententityname");
+    //logging.log(vars.getString("$sys.currentcontextname"))
+    //return vars.getString("$sys.currentcontextname");
     // TODO: replace with Core-method instead of switch-case!!!
     switch (entityName)
     {
@@ -31,7 +35,7 @@ ContextUtils.getCurrentContextId = function()
 }
 
 /**
- * TODO: use System function
+ * TODO: use System function. Currently the Name is also the id.
  * Returns the Name of a context by the Id
  * 
  * @param {String} pContextId the id of a context
@@ -43,23 +47,61 @@ ContextUtils.getContextName = function(pContextId)
     return pContextId;
 }
 
+/**
+ * Get all contexts of the project.
+ * 
+ * @return {String[][]} [ ["contextid", "contextName" ], [..., ...], ...]
+ */
+ContextUtils.getContexts = function() 
+{
+    // TODO: The name is currently also the id. This may change.
+    return project.getDataModelNames(project.DATAMODEL_KIND_CONTEXT).map(function(contextName) {
+        return [contextName, ContextUtils.getContextName(contextName)];
+    });
+}
+
+/**
+ * TODO: !!!temporary function until you can get fields from another Entity!!!
+ */
+ContextUtils._getNameSelectMap = function()
+{
+    var maskingUtils = new SqlMaskingUtils();
+    return {
+        "Org_context": ["select \"NAME\" from ORG", "ORG.ORGID"],
+        "Pers_context": ["select " + maskingUtils.concat(["FIRSTNAME", "LASTNAME"]) + " from PERS", "PERS.PERSID"],
+        "Activity_context": ["select SUBJECT from ACTIVITY", "ACTIVITY.ACTIVITYID"],
+        "Salesproject_context": ["select " + maskingUtils.concat([maskingUtils.cast("PROJECTCODE", SQLTYPES.VARCHAR, 10), "':'", "PROJECTTITLE"]) + " from SALESPROJECT", "SALESPROJECT.SALESPROJECTID"],
+        // TODO: keywords sind noch nicht in der DB somit gibt es nichts ähnliches zu getKeySQL.
+        // select " + maskingUtils.concat([SqlMaskingUtils.cast("CONTRACTCODE", "varchar", 10), getKeySQL("CONTRACTTYPE", "CONTRACTTYPE" )]) + " from CONTRACT
+        "Contract_context": ["select " + maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10) + " from CONTRACT", "CONTRACT.CONTRACTID"]       
+    }
+}
+
 /**
  * TODO: !!!temporary function until you can get fields from another Entity!!!
  */
 ContextUtils.getNameSubselectSql = function(pContextIdDbField, pRowIdDbField)
 {
     var select = "(case " + pContextIdDbField + " ";
-    var maskingUtils = new SqlMaskingUtils();
     
-    select += "when 'Org_context' then (select \"NAME\" from ORG where ORG.ORGID = " + pRowIdDbField + ") ";
-    select += "when 'Pers_context' then (select " + maskingUtils.concat(["FIRSTNAME", "LASTNAME"]) + " from PERS where PERS.PERSID = " + pRowIdDbField + ") ";
-    select += "when 'Activity_context' then (select SUBJECT from ACTIVITY where ACTIVITY.ACTIVITYID = " + pRowIdDbField + ") ";
-    select += "when 'Salesproject_context' then (select " + maskingUtils.concat([maskingUtils.cast("PROJECTCODE", SQLTYPES.VARCHAR, 10), "':'", "PROJECTTITLE"]) + " from SALESPROJECT where SALESPROJECT.SALESPROJECTID = " + pRowIdDbField + ") ";
-    // TODO: keywords sind noch nicht in der DB somit gibt es nichts ähnliches zu getKeySQL.
-    //select += "when 'Contract_context' then (select " + maskingUtils.concat([SqlMaskingUtils.cast("CONTRACTCODE", "varchar", 10), getKeySQL("CONTRACTTYPE", "CONTRACTTYPE" )]) + " from CONTRACT where CONTRACT.CONTRACTID = " + pRowIdDbField + ") ";
-    select += "when 'Contract_context' then (select " + maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10) + " from CONTRACT where CONTRACT.CONTRACTID = " + pRowIdDbField + ") ";
+    
+    var selectMap = ContextUtils._getNameSelectMap()
+    for (let contextId in selectMap) 
+    {
+        select += "when '" + contextId + "' then (" + selectMap[contextId][0] + " where " + selectMap[contextId][1] + " = " + pRowIdDbField + ") ";
+    }
+    
     select += "else 'Not defined in ContextUtils.getNameSql()!'";
     select += "end)";
     
     return select;
+}
+
+/**
+ * TODO: !!!temporary function until you can get fields from another Entity!!!
+ */
+ContextUtils.getNameSql = function(pContextId, pRowId)
+{
+    var selectMap = ContextUtils._getNameSelectMap()
+    return SqlCondition.begin().andPrepare(selectMap[pContextId][1], pRowId).buildSql(selectMap[pContextId][0], "1=2");
 }
\ No newline at end of file
diff --git a/process/Entity_lib/process.js b/process/Entity_lib/process.js
index 50293fbada3..ef7c4093889 100644
--- a/process/Entity_lib/process.js
+++ b/process/Entity_lib/process.js
@@ -44,7 +44,6 @@ ProcessHandlingUtils.initialParamToResult = function(pParamVarName)
             result.object(paramValue);
         }
     }
-    
 }
 
 /**
diff --git a/process/ObjectRelation_lib/ObjectRelation_lib.aod b/process/ObjectRelation_lib/ObjectRelation_lib.aod
new file mode 100644
index 00000000000..77cc2f184e4
--- /dev/null
+++ b/process/ObjectRelation_lib/ObjectRelation_lib.aod
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.7" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.1.7">
+  <name>ObjectRelation_lib</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <process>%aditoprj%/process/ObjectRelation_lib/process.js</process>
+  <variants>
+    <element>LIBRARY</element>
+  </variants>
+</process>
diff --git a/process/ObjectRelation_lib/process.js b/process/ObjectRelation_lib/process.js
new file mode 100644
index 00000000000..25512e27c7b
--- /dev/null
+++ b/process/ObjectRelation_lib/process.js
@@ -0,0 +1,15 @@
+/**
+ * Methods to manage ObjectRelations.
+ * Do not create an instance of this!
+ * 
+ * @class
+ */
+function ObjectRelationUtils() {}
+   
+/**
+ *  
+ */
+ObjectRelationUtils.get = function() 
+{
+   
+}
\ No newline at end of file
-- 
GitLab