From fe46dcc8da7dc65bf3cbe09d11b3c9d8c952caf5 Mon Sep 17 00:00:00 2001
From: Andre Loreth <a.loreth@adito.de>
Date: Wed, 27 Feb 2019 07:54:46 +0100
Subject: [PATCH] =?UTF-8?q?#1034869:=20Aktivit=C3=A4t=20aus=20Aufgabe=20er?=
 =?UTF-8?q?stellen=20und=20Aufgabe=20aus=20Aktivit=C3=A4t=20erstellen?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 aliasDefinition/Data_alias/Data_alias.aod     |  56 ++++++++
 entity/Activity_entity/Activity_entity.aod    |  62 ++++++++
 .../moduletrees/children/contextname/code.js  |   3 +
 .../moduletrees/children/id/code.js           |   4 +
 .../newactivity_action/onActionProcess.js     |   9 ++
 .../newtask_action/onActionProcess.js         |   9 ++
 .../parent_context/valueProcess.js            |   4 +
 .../entityfields/parent_id/valueProcess.js    |   4 +
 .../parentcontext_param/documentation.adoc    |   3 +
 .../parentid_param/documentation.adoc         |   3 +
 .../ModuleTree_entity/ModuleTree_entity.aod   |  82 +++++++++++
 .../recordcontainers/jdito/contentProcess.js  | 133 ++++++++++++++++++
 entity/Person_entity/Person_entity.aod        |   5 +
 .../children/commcategory_param/code.js       |   0
 entity/Task_entity/Task_entity.aod            |  61 ++++++++
 .../children/contactid_param/code.js          |   0
 .../children/contactid_param/code.js          |   0
 .../moduletrees/children/contextname/code.js  |   3 +
 .../children/contextname/documentation.adoc   |   0
 .../moduletrees/children/id/code.js           |   4 +
 .../newactivity_action/onActionProcess.js     |   9 ++
 .../newtask_action/onActionProcess.js         |   9 ++
 .../parent_context/valueProcess.js            |   4 +
 .../entityfields/parent_id/valueProcess.js    |   5 +
 neonContext/ModuleTree/ModuleTree.aod         |  13 ++
 .../ActivityMain_view/ActivityMain_view.aod   |   5 +
 neonView/ModuleTree_view/ModuleTree_view.aod  |  23 +++
 neonView/TaskMain_view/TaskMain_view.aod      |   5 +
 .../data_alias/struct/activity_add_parent.xml |  12 ++
 .../data_alias/struct/task_add_parent.xml     |  12 ++
 others/db_changes/masterChangelog.xml         |   3 +
 31 files changed, 545 insertions(+)
 create mode 100644 entity/Activity_entity/entityfields/moduletrees/children/contextname/code.js
 create mode 100644 entity/Activity_entity/entityfields/moduletrees/children/id/code.js
 create mode 100644 entity/Activity_entity/entityfields/newactivity_action/onActionProcess.js
 create mode 100644 entity/Activity_entity/entityfields/newtask_action/onActionProcess.js
 create mode 100644 entity/Activity_entity/entityfields/parent_context/valueProcess.js
 create mode 100644 entity/Activity_entity/entityfields/parent_id/valueProcess.js
 create mode 100644 entity/Activity_entity/entityfields/parentcontext_param/documentation.adoc
 create mode 100644 entity/Activity_entity/entityfields/parentid_param/documentation.adoc
 create mode 100644 entity/ModuleTree_entity/ModuleTree_entity.aod
 create mode 100644 entity/ModuleTree_entity/recordcontainers/jdito/contentProcess.js
 create mode 100644 entity/Person_entity/entityfields/communications/children/commcategory_param/code.js
 create mode 100644 entity/Task_entity/entityfields/contacteditors/children/contactid_param/code.js
 create mode 100644 entity/Task_entity/entityfields/contactrequestors/children/contactid_param/code.js
 create mode 100644 entity/Task_entity/entityfields/moduletrees/children/contextname/code.js
 create mode 100644 entity/Task_entity/entityfields/moduletrees/children/contextname/documentation.adoc
 create mode 100644 entity/Task_entity/entityfields/moduletrees/children/id/code.js
 create mode 100644 entity/Task_entity/entityfields/newactivity_action/onActionProcess.js
 create mode 100644 entity/Task_entity/entityfields/newtask_action/onActionProcess.js
 create mode 100644 entity/Task_entity/entityfields/parent_context/valueProcess.js
 create mode 100644 entity/Task_entity/entityfields/parent_id/valueProcess.js
 create mode 100644 neonContext/ModuleTree/ModuleTree.aod
 create mode 100644 neonView/ModuleTree_view/ModuleTree_view.aod
 create mode 100644 others/db_changes/data_alias/struct/activity_add_parent.xml
 create mode 100644 others/db_changes/data_alias/struct/task_add_parent.xml

diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod
index 9cfc964b7d..2d21eb809c 100644
--- a/aliasDefinition/Data_alias/Data_alias.aod
+++ b/aliasDefinition/Data_alias/Data_alias.aod
@@ -3027,6 +3027,34 @@
                 <title></title>
                 <description></description>
               </entityFieldDb>
+              <entityFieldDb>
+                <name>PARENT_CONTEXT</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="32" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>PARENT_ID</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="1" />
+                <size v="36" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
             </entityFields>
           </entityDb>
           <entityDb>
@@ -3672,6 +3700,34 @@
                 <title></title>
                 <description></description>
               </entityFieldDb>
+              <entityFieldDb>
+                <name>PARENT_ID</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="1" />
+                <size v="36" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>PARENT_CONTEXT</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="32" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
             </entityFields>
           </entityDb>
           <entityDb>
diff --git a/entity/Activity_entity/Activity_entity.aod b/entity/Activity_entity/Activity_entity.aod
index c87bb1efc1..d3c741ac84 100644
--- a/entity/Activity_entity/Activity_entity.aod
+++ b/entity/Activity_entity/Activity_entity.aod
@@ -279,6 +279,60 @@
       <searchable v="false" />
       <valueProcess>%aditoprj%/entity/Activity_entity/entityfields/creator/valueProcess.js</valueProcess>
     </entityField>
+    <entityConsumer>
+      <name>ModuleTrees</name>
+      <title>Baum</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>ModuleTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ContextName</name>
+          <code>%aditoprj%/entity/Activity_entity/entityfields/moduletrees/children/contextname/code.js</code>
+        </entityParameter>
+        <entityParameter>
+          <name>ID</name>
+          <code>%aditoprj%/entity/Activity_entity/entityfields/moduletrees/children/id/code.js</code>
+        </entityParameter>
+      </children>
+    </entityConsumer>
+    <entityActionField>
+      <name>newActivity_action</name>
+      <fieldType>ACTION</fieldType>
+      <title>Neue Aktivität</title>
+      <onActionProcess>%aditoprj%/entity/Activity_entity/entityfields/newactivity_action/onActionProcess.js</onActionProcess>
+      <iconId>VAADIN:PLUS</iconId>
+    </entityActionField>
+    <entityActionField>
+      <name>newTask_action</name>
+      <fieldType>ACTION</fieldType>
+      <title>Neue Aufgabe</title>
+      <onActionProcess>%aditoprj%/entity/Activity_entity/entityfields/newtask_action/onActionProcess.js</onActionProcess>
+      <iconId>VAADIN:PLUS</iconId>
+    </entityActionField>
+    <entityParameter>
+      <name>ParentId_param</name>
+      <expose v="true" />
+      <documentation>%aditoprj%/entity/Activity_entity/entityfields/parentid_param/documentation.adoc</documentation>
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityParameter>
+      <name>ParentContext_param</name>
+      <expose v="true" />
+      <documentation>%aditoprj%/entity/Activity_entity/entityfields/parentcontext_param/documentation.adoc</documentation>
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityField>
+      <name>PARENT_ID</name>
+      <valueProcess>%aditoprj%/entity/Activity_entity/entityfields/parent_id/valueProcess.js</valueProcess>
+    </entityField>
+    <entityField>
+      <name>PARENT_CONTEXT</name>
+      <valueProcess>%aditoprj%/entity/Activity_entity/entityfields/parent_context/valueProcess.js</valueProcess>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -330,6 +384,14 @@
           <name>CREATOR.value</name>
           <recordfield>ACTIVITY.CREATOR</recordfield>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>PARENT_CONTEXT.value</name>
+          <recordfield>ACTIVITY.PARENT_CONTEXT</recordfield>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>PARENT_ID.value</name>
+          <recordfield>ACTIVITY.PARENT_ID</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/Activity_entity/entityfields/moduletrees/children/contextname/code.js b/entity/Activity_entity/entityfields/moduletrees/children/contextname/code.js
new file mode 100644
index 0000000000..109d9bf5c8
--- /dev/null
+++ b/entity/Activity_entity/entityfields/moduletrees/children/contextname/code.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("Activity");
\ No newline at end of file
diff --git a/entity/Activity_entity/entityfields/moduletrees/children/id/code.js b/entity/Activity_entity/entityfields/moduletrees/children/id/code.js
new file mode 100644
index 0000000000..06fe7d3632
--- /dev/null
+++ b/entity/Activity_entity/entityfields/moduletrees/children/id/code.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("system.vars");
+
+result.string(vars.get("$field.ACTIVITYID"));
\ No newline at end of file
diff --git a/entity/Activity_entity/entityfields/newactivity_action/onActionProcess.js b/entity/Activity_entity/entityfields/newactivity_action/onActionProcess.js
new file mode 100644
index 0000000000..39352aaa73
--- /dev/null
+++ b/entity/Activity_entity/entityfields/newactivity_action/onActionProcess.js
@@ -0,0 +1,9 @@
+import("system.neon");
+import("system.vars");
+
+var params = {
+  "ParentId_param": vars.get("$field.ACTIVITYID"),
+  "ParentContext_param": "Activity"
+};
+
+neon.openContext("Activity", "ActivityEdit_view", null, neon.OPERATINGSTATE_NEW, params)
\ No newline at end of file
diff --git a/entity/Activity_entity/entityfields/newtask_action/onActionProcess.js b/entity/Activity_entity/entityfields/newtask_action/onActionProcess.js
new file mode 100644
index 0000000000..9417c7e293
--- /dev/null
+++ b/entity/Activity_entity/entityfields/newtask_action/onActionProcess.js
@@ -0,0 +1,9 @@
+import("system.neon");
+import("system.vars");
+
+var params = {
+  "ParentId_param": vars.get("$field.ACTIVITYID"),
+  "ParentContext_param": "Activity"
+};
+
+neon.openContext("Task", "TaskEdit_view", null, neon.OPERATINGSTATE_NEW, params)
\ No newline at end of file
diff --git a/entity/Activity_entity/entityfields/parent_context/valueProcess.js b/entity/Activity_entity/entityfields/parent_context/valueProcess.js
new file mode 100644
index 0000000000..348cc486cb
--- /dev/null
+++ b/entity/Activity_entity/entityfields/parent_context/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$param.ParentContext_param"));
diff --git a/entity/Activity_entity/entityfields/parent_id/valueProcess.js b/entity/Activity_entity/entityfields/parent_id/valueProcess.js
new file mode 100644
index 0000000000..4ee2e31107
--- /dev/null
+++ b/entity/Activity_entity/entityfields/parent_id/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$param.ParentId_param"));
diff --git a/entity/Activity_entity/entityfields/parentcontext_param/documentation.adoc b/entity/Activity_entity/entityfields/parentcontext_param/documentation.adoc
new file mode 100644
index 0000000000..d2438f4203
--- /dev/null
+++ b/entity/Activity_entity/entityfields/parentcontext_param/documentation.adoc
@@ -0,0 +1,3 @@
+Describes the name of the parent element's context name. 
+This parameter is used to link a new activity to an existing.
+(Also see `ParentId_param`)
\ No newline at end of file
diff --git a/entity/Activity_entity/entityfields/parentid_param/documentation.adoc b/entity/Activity_entity/entityfields/parentid_param/documentation.adoc
new file mode 100644
index 0000000000..06e595d64f
--- /dev/null
+++ b/entity/Activity_entity/entityfields/parentid_param/documentation.adoc
@@ -0,0 +1,3 @@
+Describes the ID of the parent element's context name. 
+This parameter is used to link a new activity to an existing.
+(Also see `ParentContextName_param`)
\ No newline at end of file
diff --git a/entity/ModuleTree_entity/ModuleTree_entity.aod b/entity/ModuleTree_entity/ModuleTree_entity.aod
new file mode 100644
index 0000000000..c23de76143
--- /dev/null
+++ b/entity/ModuleTree_entity/ModuleTree_entity.aod
@@ -0,0 +1,82 @@
+<?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.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.2.0">
+  <name>ModuleTree_entity</name>
+  <title>Tree Entity</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <entityFields>
+    <entityProvider>
+      <name>#PROVIDER</name>
+      <recordContainer>jdito</recordContainer>
+    </entityProvider>
+    <entityField>
+      <name>TITLE</name>
+    </entityField>
+    <entityField>
+      <name>DESCRIPTION</name>
+    </entityField>
+    <entityField>
+      <name>ICON</name>
+    </entityField>
+    <entityProvider>
+      <name>TreeProvider</name>
+      <fieldType>DEPENDENCY_IN</fieldType>
+      <targetContextField>TYPE</targetContextField>
+      <targetIdField>UID</targetIdField>
+      <recordContainer>jdito</recordContainer>
+      <dependencies>
+        <entityDependency>
+          <name>7da88ffb-4292-4fe2-88e2-dda2dc4aa625</name>
+          <entityName>Task_entity</entityName>
+          <fieldName>ModuleTrees</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+        <entityDependency>
+          <name>70e2ea81-1e08-47a6-ac89-3164bdbd9e02</name>
+          <entityName>Activity_entity</entityName>
+          <fieldName>ModuleTrees</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+      </dependencies>
+    </entityProvider>
+    <entityField>
+      <name>PARENT_ID</name>
+    </entityField>
+    <entityField>
+      <name>UID</name>
+    </entityField>
+    <entityField>
+      <name>PARENT_CONTEXT</name>
+    </entityField>
+    <entityField>
+      <name>TYPE</name>
+    </entityField>
+    <entityParameter>
+      <name>ContextName</name>
+      <expose v="true" />
+      <mandatory v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityParameter>
+      <name>ID</name>
+      <expose v="true" />
+      <mandatory v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+  </entityFields>
+  <recordContainers>
+    <jDitoRecordContainer>
+      <name>jdito</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/ModuleTree_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
+      <recordFields>
+        <element>UID.value</element>
+        <element>TYPE.value</element>
+        <element>PARENT_ID.value</element>
+        <element>PARENT_CONTEXT.value</element>
+        <element>TITLE.value</element>
+        <element>DESCRIPTION.value</element>
+        <element>ICON.value</element>
+      </recordFields>
+    </jDitoRecordContainer>
+  </recordContainers>
+</entity>
diff --git a/entity/ModuleTree_entity/recordcontainers/jdito/contentProcess.js b/entity/ModuleTree_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 0000000000..0710ff8b81
--- /dev/null
+++ b/entity/ModuleTree_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,133 @@
+import("system.vars");
+import("Sql_lib")
+import("system.result");
+import("system.db");
+
+var fixedContextName = vars.get("$param.ContextName");
+var fixedID = vars.get("$param.ID");
+
+let resArray = [];
+
+// Query root element
+var root = queryRootElement(fixedContextName, fixedID);
+if (root !== null) {
+    // Push root element
+    resArray.push(root);
+
+    // Query children of root
+    var children = queryChildrenElements(fixedContextName, fixedID);
+    
+    if (children !== null) {
+     
+       // Push each children
+       for(let i = 0; i < children.length; i++) {
+           resArray.push(children[i]);
+       }
+
+       result.object(resArray);
+    }
+}
+
+/**
+ * Queries the children of the given parent element.
+ * This function will recursively go through each level of children.
+ * 
+ * @param pContextName Context name of the parent element.
+ * @param pID ID of the parent element.
+ */
+function queryChildrenElements (pContextName, pID) {
+    var taskResult = db.table("select TASKID, PARENT_ID, PARENT_CONTEXT, SUBJECT, DESCRIPTION from TASK where PARENT_ID = '" + pID +"' and PARENT_CONTEXT = '" + pContextName + "'");
+    var activityResult = db.table("select ACTIVITYID, PARENT_ID, PARENT_CONTEXT, SUBJECT, INFO from ACTIVITY where PARENT_ID = '" + pID +"' and PARENT_CONTEXT = '" + pContextName + "'");
+  
+    var res = []
+  
+    for (let i = 0; i < taskResult.length; i++) {
+        // Augment data
+        taskResult[i] = augmentData(taskResult[i], "Task");
+        res.push(taskResult[i]);
+        
+        // Query children
+        let children = queryChildrenElements("Task", taskResult[i][0]);
+        for (let i = 0; i < children.length; i++) {
+            res.push(children[i]);
+        }
+    }
+    
+    for (let i = 0; i < activityResult.length; i++) {
+        // Augment data
+        activityResult[i] = augmentData(activityResult[i], "Activity");
+        res.push(activityResult[i]);
+        
+        // Query children
+        let children = queryChildrenElements("Activity", activityResult[i][0]);
+        for (let i = 0; i < children.length; i++) {
+            res.push(children[i]);
+        }
+    }
+      
+    return res;
+}
+
+/**
+ * Queries the root element.
+ * 
+ * @param pContextName Context name of the root element.
+ * @param pID ID of the root element.
+ */
+function queryRootElement (pContextName, pID) {
+    var resultArray;
+    if (pContextName === "Task") {
+        resultArray = db.table("select TASKID, PARENT_ID, PARENT_CONTEXT, SUBJECT, DESCRIPTION from TASK where TASKID = '" + pID + "'");
+        if (resultArray.length === 0) {
+            return null;
+        }
+        
+        return augmentData(resultArray[0], "Task");
+    } else if (pContextName === "Activity") {
+        resultArray = db.table("select ACTIVITYID, PARENT_ID, PARENT_CONTEXT, SUBJECT, INFO from ACTIVITY where ACTIVITYID = '" + pID +"'");
+        if (resultArray.length === 0) {
+            return null;
+        }
+        
+        return augmentData(resultArray[0], "Activity");
+    } else {
+        return null;
+    }
+}
+
+/**
+ * Augments the given row to match the required result signature.
+ * 
+ * @param pDataRow Requires the following format:
+ *                 UID, PARENT_ID, PARENT_CONTEXT, TITLE, DESCRIPTION
+ * @param pType The type of the row which needs adjustment.
+ * @return Returns the following format:
+ *         UID, TYPE, PARENT_ID, PARENT_CONTEX, TITL, DESCRIPTION, ICON
+ * 
+ */
+function augmentData (pDataRow, pType) {
+    if (pDataRow === null || pDataRow === undefined)
+        return null;
+    
+    if (pDataRow.length === 0)
+        return null;
+    
+    if (pType !== "Task" && pType !== "Activity")
+        return null;
+    
+    // PARENT_ID check
+    if (pDataRow[2] === "")
+        pDataRow[2] = null;
+    
+    // PARENT_CONTEXT check
+    if (pDataRow[3] === "")
+        pDataRow[3] = null;
+    
+    // Insert type
+    pDataRow.splice(1, 0, pType);
+    
+    // Insert icon
+    pDataRow.splice(6, 0, pType === "Task" ? "VAADIN:TASKS" : pType === "Activity" ? "NEON:HISTORY": null);
+    
+    return pDataRow;
+}
\ No newline at end of file
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index d3bf5b0f9c..33c0699ff3 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -186,6 +186,11 @@
           <description>This parameter is used for specifing a related &amp;quot;CONTACTID&amp;quot; to a COMMUNICATION-entry. 
 Usually this is used for filtering COMMUNICATION-entries by a specified contact or creating a new entry that is related to a contact.</description>
         </entityParameter>
+        <entityParameter>
+          <name>CommCategory_param</name>
+          <code>%aditoprj%/entity/Person_entity/entityfields/communications/children/commcategory_param/code.js</code>
+          <description>TODO: expose auf false. aktuell wird der Code nicht ausgeführt, wenn Expose false ist.</description>
+        </entityParameter>
       </children>
     </entityConsumer>
     <entityConsumer>
diff --git a/entity/Person_entity/entityfields/communications/children/commcategory_param/code.js b/entity/Person_entity/entityfields/communications/children/commcategory_param/code.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/entity/Task_entity/Task_entity.aod b/entity/Task_entity/Task_entity.aod
index 4e792a2dec..ae40a70777 100644
--- a/entity/Task_entity/Task_entity.aod
+++ b/entity/Task_entity/Task_entity.aod
@@ -170,6 +170,59 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityConsumer>
+      <name>ModuleTrees</name>
+      <title>Baum</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>ModuleTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ID</name>
+          <code>%aditoprj%/entity/Task_entity/entityfields/moduletrees/children/id/code.js</code>
+          <description>PARAMETER</description>
+        </entityParameter>
+        <entityParameter>
+          <name>ContextName</name>
+          <code>%aditoprj%/entity/Task_entity/entityfields/moduletrees/children/contextname/code.js</code>
+        </entityParameter>
+      </children>
+    </entityConsumer>
+    <entityField>
+      <name>PARENT_CONTEXT</name>
+      <valueProcess>%aditoprj%/entity/Task_entity/entityfields/parent_context/valueProcess.js</valueProcess>
+    </entityField>
+    <entityField>
+      <name>PARENT_ID</name>
+      <valueProcess>%aditoprj%/entity/Task_entity/entityfields/parent_id/valueProcess.js</valueProcess>
+    </entityField>
+    <entityParameter>
+      <name>ParentId_param</name>
+      <expose v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityParameter>
+      <name>ParentContext_param</name>
+      <expose v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityActionField>
+      <name>newActivity_action</name>
+      <fieldType>ACTION</fieldType>
+      <title>Neue Aktivität</title>
+      <onActionProcess>%aditoprj%/entity/Task_entity/entityfields/newactivity_action/onActionProcess.js</onActionProcess>
+      <iconId>VAADIN:PLUS</iconId>
+    </entityActionField>
+    <entityActionField>
+      <name>newTask_action</name>
+      <fieldType>ACTION</fieldType>
+      <title>Neue Aufgabe</title>
+      <onActionProcess>%aditoprj%/entity/Task_entity/entityfields/newtask_action/onActionProcess.js</onActionProcess>
+      <iconId>VAADIN:PLUS</iconId>
+    </entityActionField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -250,6 +303,14 @@
           <name>STATUS.displayValue</name>
           <expression>%aditoprj%/entity/Task_entity/recordcontainers/db/recordfieldmappings/status.displayvalue/expression.js</expression>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>PARENT_CONTEXT.value</name>
+          <recordfield>TASK.PARENT_CONTEXT</recordfield>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>PARENT_ID.value</name>
+          <recordfield>TASK.PARENT_ID</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/Task_entity/entityfields/contacteditors/children/contactid_param/code.js b/entity/Task_entity/entityfields/contacteditors/children/contactid_param/code.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/entity/Task_entity/entityfields/contactrequestors/children/contactid_param/code.js b/entity/Task_entity/entityfields/contactrequestors/children/contactid_param/code.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/entity/Task_entity/entityfields/moduletrees/children/contextname/code.js b/entity/Task_entity/entityfields/moduletrees/children/contextname/code.js
new file mode 100644
index 0000000000..86bf9bdfc9
--- /dev/null
+++ b/entity/Task_entity/entityfields/moduletrees/children/contextname/code.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("Task");
\ No newline at end of file
diff --git a/entity/Task_entity/entityfields/moduletrees/children/contextname/documentation.adoc b/entity/Task_entity/entityfields/moduletrees/children/contextname/documentation.adoc
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/entity/Task_entity/entityfields/moduletrees/children/id/code.js b/entity/Task_entity/entityfields/moduletrees/children/id/code.js
new file mode 100644
index 0000000000..890f0a3405
--- /dev/null
+++ b/entity/Task_entity/entityfields/moduletrees/children/id/code.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("system.vars");
+
+result.string(vars.get("$field.TASKID"));
\ No newline at end of file
diff --git a/entity/Task_entity/entityfields/newactivity_action/onActionProcess.js b/entity/Task_entity/entityfields/newactivity_action/onActionProcess.js
new file mode 100644
index 0000000000..f3c7bcbb72
--- /dev/null
+++ b/entity/Task_entity/entityfields/newactivity_action/onActionProcess.js
@@ -0,0 +1,9 @@
+import("system.neon");
+import("system.vars");
+
+var params = {
+  "ParentId_param": vars.get("$field.TASKID"),
+  "ParentContext_param": "Task"
+};
+
+neon.openContext("Activity", "ActivityEdit_view", null, neon.OPERATINGSTATE_NEW, params)
\ No newline at end of file
diff --git a/entity/Task_entity/entityfields/newtask_action/onActionProcess.js b/entity/Task_entity/entityfields/newtask_action/onActionProcess.js
new file mode 100644
index 0000000000..b4e2fd874a
--- /dev/null
+++ b/entity/Task_entity/entityfields/newtask_action/onActionProcess.js
@@ -0,0 +1,9 @@
+import("system.neon");
+import("system.vars");
+
+var params = {
+  "ParentId_param": vars.get("$field.TASKID"),
+  "ParentContext_param": "Task"
+};
+
+neon.openContext("Task", "TaskEdit_view", null, neon.OPERATINGSTATE_NEW, params)
\ No newline at end of file
diff --git a/entity/Task_entity/entityfields/parent_context/valueProcess.js b/entity/Task_entity/entityfields/parent_context/valueProcess.js
new file mode 100644
index 0000000000..348cc486cb
--- /dev/null
+++ b/entity/Task_entity/entityfields/parent_context/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$param.ParentContext_param"));
diff --git a/entity/Task_entity/entityfields/parent_id/valueProcess.js b/entity/Task_entity/entityfields/parent_id/valueProcess.js
new file mode 100644
index 0000000000..d628d7b124
--- /dev/null
+++ b/entity/Task_entity/entityfields/parent_id/valueProcess.js
@@ -0,0 +1,5 @@
+import("system.vars");
+import("system.result");
+import("system.logging");
+
+result.string(vars.get("$param.ParentId_param"));
diff --git a/neonContext/ModuleTree/ModuleTree.aod b/neonContext/ModuleTree/ModuleTree.aod
new file mode 100644
index 0000000000..4b0216f17a
--- /dev/null
+++ b/neonContext/ModuleTree/ModuleTree.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>ModuleTree</name>
+  <title>Tree</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <entity>ModuleTree_entity</entity>
+  <references>
+    <neonViewReference>
+      <name>90d2e21e-1231-418e-8729-d29f2453dfdd</name>
+      <view>ModuleTree_view</view>
+    </neonViewReference>
+  </references>
+</neonContext>
diff --git a/neonView/ActivityMain_view/ActivityMain_view.aod b/neonView/ActivityMain_view/ActivityMain_view.aod
index 79170c513d..5937e2ba7b 100644
--- a/neonView/ActivityMain_view/ActivityMain_view.aod
+++ b/neonView/ActivityMain_view/ActivityMain_view.aod
@@ -29,5 +29,10 @@
       <entityField>Links</entityField>
       <view>ActivityLinkFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>f6c6888a-f3d6-410a-b97b-30c34a9dd6a2</name>
+      <entityField>ModuleTrees</entityField>
+      <view>ModuleTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/ModuleTree_view/ModuleTree_view.aod b/neonView/ModuleTree_view/ModuleTree_view.aod
new file mode 100644
index 0000000000..255c830a3d
--- /dev/null
+++ b/neonView/ModuleTree_view/ModuleTree_view.aod
@@ -0,0 +1,23 @@
+<?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>ModuleTree_view</name>
+  <title>Tree</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <treetableViewTemplate>
+      <name>Treetable</name>
+      <parentField>PARENT_ID</parentField>
+      <favoriteActionGroup3></favoriteActionGroup3>
+      <titleField>TITLE</titleField>
+      <descriptionField>DESCRIPTION</descriptionField>
+      <iconField>ICON</iconField>
+      <entityField>#ENTITY</entityField>
+      <title></title>
+    </treetableViewTemplate>
+  </children>
+</neonView>
diff --git a/neonView/TaskMain_view/TaskMain_view.aod b/neonView/TaskMain_view/TaskMain_view.aod
index cc31fbb6b1..4dde27df13 100644
--- a/neonView/TaskMain_view/TaskMain_view.aod
+++ b/neonView/TaskMain_view/TaskMain_view.aod
@@ -39,5 +39,10 @@
       <entityField>MainDocuments</entityField>
       <view>DocumentFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>4211b2cf-3a1f-4447-ad1c-f521d2d3f258</name>
+      <entityField>ModuleTrees</entityField>
+      <view>ModuleTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/others/db_changes/data_alias/struct/activity_add_parent.xml b/others/db_changes/data_alias/struct/activity_add_parent.xml
new file mode 100644
index 0000000000..6fdf4af25f
--- /dev/null
+++ b/others/db_changes/data_alias/struct/activity_add_parent.xml
@@ -0,0 +1,12 @@
+<?xml version="1.1" encoding="UTF-8" standalone="no"?>
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
+<changeSet author="a.loreth" id="31d7b6f2-c376-4bfa-ba42-9aab6f07737c">
+    <addColumn 
+        tableName="ACTIVITY">
+        <column name="PARENT_CONTEXT" type="VARCHAR(64)" />
+        <column name="PARENT_ID" type="CHAR(36)" />
+    </addColumn>
+</changeSet>
+</databaseChangeLog>
+
+
diff --git a/others/db_changes/data_alias/struct/task_add_parent.xml b/others/db_changes/data_alias/struct/task_add_parent.xml
new file mode 100644
index 0000000000..e2d9493bd4
--- /dev/null
+++ b/others/db_changes/data_alias/struct/task_add_parent.xml
@@ -0,0 +1,12 @@
+<?xml version="1.1" encoding="UTF-8" standalone="no"?>
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
+<changeSet author="a.loreth" id="a1890934-4f52-4623-a587-9d690505bbaf">
+    <addColumn 
+        tableName="TASK">
+        <column name="PARENT_CONTEXT" type="VARCHAR(64)" />
+        <column name="PARENT_ID" type="CHAR(36)" />
+    </addColumn>
+</changeSet>
+</databaseChangeLog>
+
+
diff --git a/others/db_changes/masterChangelog.xml b/others/db_changes/masterChangelog.xml
index c93c6d8738..6f00bed589 100644
--- a/others/db_changes/masterChangelog.xml
+++ b/others/db_changes/masterChangelog.xml
@@ -37,6 +37,9 @@
     <include file="data_alias/struct/create_timetracking.xml"/>
     <include file="data_alias/struct/create_task.xml"/>
     
+    <include file="data_alias/struct/task_add_parent.xml" />
+    <include file="data_alias/struct/activity_add_parent.xml" />
+    
     <include file="data_alias/data/example_organisation/ORGANISATION_privat.xml"/>
     <include file="data_alias/data/example_organisation/ORGANISATION_gfk.xml"/>
     <include file="data_alias/data/example_organisation/ORGANISATION_mnf.xml"/>
-- 
GitLab