From d495fcbcb1f70eb6d6de24abb1f439ea80c3cf57 Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Wed, 27 Mar 2019 13:56:44 +0100
Subject: [PATCH] AttributeRelation Tree

---
 entity/Activity_entity/Activity_entity.aod    | 22 +++++
 .../objectrowid_param/valueProcess.js         |  4 +
 .../children/objecttype_param/valueProcess.js |  4 +
 .../AttributeRelationTree_entity.aod          | 84 +++++++++++++++++++
 .../recordcontainers/jdito/contentProcess.js  | 44 ++++++++++
 .../AttributeRelation_entity.aod              | 11 ++-
 entity/Contract_entity/Contract_entity.aod    | 22 +++++
 .../objectrowid_param/valueProcess.js         |  4 +
 .../children/objecttype_param/valueProcess.js |  4 +
 entity/Offer_entity/Offer_entity.aod          | 22 +++++
 .../objectrowid_param/valueProcess.js         |  4 +
 .../children/objecttype_param/valueProcess.js |  4 +
 .../Organisation_entity.aod                   | 23 +++++
 .../objectrowid_param/valueProcess.js         |  4 +
 .../children/objecttype_param/valueProcess.js |  4 +
 entity/Person_entity/Person_entity.aod        | 22 +++++
 .../objectrowid_param/valueProcess.js         |  4 +
 .../children/objecttype_param/valueProcess.js |  4 +
 entity/Product_entity/Product_entity.aod      | 22 +++++
 .../objectrowid_param/valueProcess.js         |  5 ++
 .../children/objecttype_param/valueProcess.js |  4 +
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     |  4 +
 .../AttributeRelationTree.aod                 | 12 +++
 .../ActivityMain_view/ActivityMain_view.aod   |  5 ++
 .../AttributeRelationFilter_view.aod          | 13 +--
 .../AttributeRelationTree_view.aod            | 39 ++++-----
 .../ContractMain_view/ContractMain_view.aod   |  5 ++
 neonView/OfferMain_view/OfferMain_view.aod    |  5 ++
 .../OrganisationMain_view.aod                 |  5 ++
 neonView/PersonMain_view/PersonMain_view.aod  |  5 ++
 .../ProductMain_view/ProductMain_view.aod     |  5 ++
 process/Attribute_lib/process.js              | 21 +++--
 32 files changed, 398 insertions(+), 42 deletions(-)
 create mode 100644 entity/Activity_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
 create mode 100644 entity/Activity_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
 create mode 100644 entity/AttributeRelationTree_entity/AttributeRelationTree_entity.aod
 create mode 100644 entity/AttributeRelationTree_entity/recordcontainers/jdito/contentProcess.js
 create mode 100644 entity/Contract_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
 create mode 100644 entity/Contract_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
 create mode 100644 entity/Offer_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
 create mode 100644 entity/Offer_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
 create mode 100644 entity/Organisation_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
 create mode 100644 entity/Organisation_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
 create mode 100644 entity/Person_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
 create mode 100644 entity/Person_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
 create mode 100644 neonContext/AttributeRelationTree/AttributeRelationTree.aod

diff --git a/entity/Activity_entity/Activity_entity.aod b/entity/Activity_entity/Activity_entity.aod
index 3f998199e7..ce3be16107 100644
--- a/entity/Activity_entity/Activity_entity.aod
+++ b/entity/Activity_entity/Activity_entity.aod
@@ -391,6 +391,28 @@
       <documentation>%aditoprj%/entity/Activity_entity/entityfields/presetlinks_param/documentation.adoc</documentation>
       <description>PARAMETER</description>
     </entityParameter>
+    <entityConsumer>
+      <name>AttributeTree</name>
+      <title>Attribute Tree</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>AttributeRelationTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ObjectRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Activity_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>ObjectType_param</name>
+          <valueProcess>%aditoprj%/entity/Activity_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Activity_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js b/entity/Activity_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
new file mode 100644
index 0000000000..6717e012d6
--- /dev/null
+++ b/entity/Activity_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.ACTIVITYID"));
\ No newline at end of file
diff --git a/entity/Activity_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js b/entity/Activity_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
new file mode 100644
index 0000000000..431bcc9521
--- /dev/null
+++ b/entity/Activity_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("Context_lib");
+
+result.string(ContextUtils.getCurrentContextId());
diff --git a/entity/AttributeRelationTree_entity/AttributeRelationTree_entity.aod b/entity/AttributeRelationTree_entity/AttributeRelationTree_entity.aod
new file mode 100644
index 0000000000..12f10e91e6
--- /dev/null
+++ b/entity/AttributeRelationTree_entity/AttributeRelationTree_entity.aod
@@ -0,0 +1,84 @@
+<?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.3.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.0">
+  <name>AttributeRelationTree_entity</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <recordContainer>jdito</recordContainer>
+  <entityFields>
+    <entityProvider>
+      <name>#PROVIDER</name>
+    </entityProvider>
+    <entityField>
+      <name>PARENT_ID</name>
+    </entityField>
+    <entityField>
+      <name>TITLE</name>
+    </entityField>
+    <entityField>
+      <name>UID</name>
+    </entityField>
+    <entityParameter>
+      <name>ObjectType_param</name>
+      <expose v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityParameter>
+      <name>ObjectRowId_param</name>
+      <expose v="true" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityProvider>
+      <name>TreeProvider</name>
+      <fieldType>DEPENDENCY_IN</fieldType>
+      <dependencies>
+        <entityDependency>
+          <name>e0a7a4bc-ec7f-4f09-9b94-cbeb328cd7b8</name>
+          <entityName>Organisation_entity</entityName>
+          <fieldName>AttributeTree</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+        <entityDependency>
+          <name>f29d91fe-2537-486f-b9de-44065a7790d4</name>
+          <entityName>Person_entity</entityName>
+          <fieldName>AttributeTree</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+        <entityDependency>
+          <name>445c1bd7-4e72-4ab7-a5b1-cc77924eb562</name>
+          <entityName>Product_entity</entityName>
+          <fieldName>AttributeTree</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+        <entityDependency>
+          <name>4498139f-067c-4cca-b122-d9bc9100c53d</name>
+          <entityName>Activity_entity</entityName>
+          <fieldName>AttributeTree</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+        <entityDependency>
+          <name>d6d5f9aa-4582-4ec5-9381-394a38a726e8</name>
+          <entityName>Offer_entity</entityName>
+          <fieldName>AttributeTree</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+        <entityDependency>
+          <name>b728166d-a74f-4ca1-8ce7-7e57032f2a7d</name>
+          <entityName>Contract_entity</entityName>
+          <fieldName>AttributeTree</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
+      </dependencies>
+    </entityProvider>
+  </entityFields>
+  <recordContainers>
+    <jDitoRecordContainer>
+      <name>jdito</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/AttributeRelationTree_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
+      <recordFields>
+        <element>UID.value</element>
+        <element>PARENT_ID.value</element>
+        <element>TITLE.value</element>
+      </recordFields>
+    </jDitoRecordContainer>
+  </recordContainers>
+</entity>
diff --git a/entity/AttributeRelationTree_entity/recordcontainers/jdito/contentProcess.js b/entity/AttributeRelationTree_entity/recordcontainers/jdito/contentProcess.js
new file mode 100644
index 0000000000..e6b4f8a517
--- /dev/null
+++ b/entity/AttributeRelationTree_entity/recordcontainers/jdito/contentProcess.js
@@ -0,0 +1,44 @@
+import("system.vars");
+import("system.result");
+import("system.db");
+import("Attribute_lib");
+import("Sql_lib");
+
+var objectType = vars.get("$param.ObjectType_param");
+var rowId = vars.get("$param.ObjectRowId_param");
+var attributeObj = {};
+var allAttributes = [];
+var sqlSelect = "select AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, ATTRIBUTE_NAME, ATTRIBUTE_LEVEL from AB_ATTRIBUTE";
+
+var attributeValues = AttributeRelationUtils.getAllAttributes(rowId, objectType, false, true);
+
+_fetchAttributes(attributeValues.map(function (row) {return row[1]}));
+
+allAttributes = allAttributes
+    .sort(function (a, b) {return a[3] - b[3];}) //sort by level to make sure parents are added first
+    .map(function (row) {return [row[0], row[1], row[2]];}) //remove level from array
+    .concat(attributeValues);
+result.object(allAttributes);
+
+function _fetchAttributes (pAttributeIds)
+{
+    var condition = SqlCondition.begin();
+    var nextIds = [];
+    pAttributeIds.forEach(function (id)
+    {
+        if (!(id in this))
+            condition.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id);
+    }, attributeObj);
+    db.table(condition.buildSql(sqlSelect, "1=2"))
+        .forEach(function (row)
+            {
+                this[row[0]] = true;
+                if (row[1])
+                    nextIds.push(row[1]);
+                else
+                    row[1] = null;
+                allAttributes.push(row);
+            }, attributeObj);
+    if (nextIds.length)
+        _fetchAttributes(nextIds);
+}
\ No newline at end of file
diff --git a/entity/AttributeRelation_entity/AttributeRelation_entity.aod b/entity/AttributeRelation_entity/AttributeRelation_entity.aod
index f4ad545d26..73827d2c93 100644
--- a/entity/AttributeRelation_entity/AttributeRelation_entity.aod
+++ b/entity/AttributeRelation_entity/AttributeRelation_entity.aod
@@ -11,6 +11,7 @@
     </entityProvider>
     <entityField>
       <name>AB_ATTRIBUTERELATIONID</name>
+      <searchable v="false" />
       <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/ab_attributerelationid/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
@@ -25,11 +26,13 @@
     <entityField>
       <name>OBJECT_ROWID</name>
       <mandatory v="true" />
+      <searchable v="false" />
       <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/object_rowid/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>OBJECT_TYPE</name>
       <mandatory v="true" />
+      <searchable v="false" />
       <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/object_type/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
@@ -46,6 +49,7 @@
     <entityField>
       <name>CHAR_VALUE</name>
       <mandatory v="false" />
+      <searchable v="false" />
     </entityField>
     <entityProvider>
       <name>RelationsForSpecificObject</name>
@@ -105,11 +109,13 @@
     <entityField>
       <name>DATE_VALUE</name>
       <contentType>DATE</contentType>
+      <searchable v="false" />
       <state>EDITABLE</state>
     </entityField>
     <entityField>
       <name>NUMBER_VALUE</name>
       <contentType>NUMBER</contentType>
+      <searchable v="false" />
       <state>EDITABLE</state>
     </entityField>
     <entityParameter>
@@ -120,16 +126,18 @@
     <entityField>
       <name>BOOL_VALUE</name>
       <contentType>BOOLEAN</contentType>
+      <searchable v="false" />
       <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/bool_value/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>ID_VALUE</name>
+      <searchable v="false" />
     </entityField>
     <entityField>
       <name>ATTRIBUTE_PARENT_ID</name>
       <title>Superordinate Attribute</title>
       <possibleItemsProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attribute_parent_id/possibleItemsProcess.js</possibleItemsProcess>
-      <groupable v="true" />
+      <searchable v="false" />
       <displayValueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attribute_parent_id/displayValueProcess.js</displayValueProcess>
       <onValueChangeTypes>
         <element>MASK</element>
@@ -155,6 +163,7 @@
     </entityConsumer>
     <entityField>
       <name>MEMO_VALUE</name>
+      <searchable v="false" />
     </entityField>
     <entityParameter>
       <name>FilteredAttributeIds_param</name>
diff --git a/entity/Contract_entity/Contract_entity.aod b/entity/Contract_entity/Contract_entity.aod
index f50f874903..0e8b88c748 100644
--- a/entity/Contract_entity/Contract_entity.aod
+++ b/entity/Contract_entity/Contract_entity.aod
@@ -300,6 +300,28 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityConsumer>
+      <name>AttributeTree</name>
+      <title>Attribute Tree</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>AttributeRelationTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ObjectType_param</name>
+          <valueProcess>%aditoprj%/entity/Contract_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>ObjectRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Contract_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Contract_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js b/entity/Contract_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
new file mode 100644
index 0000000000..1dc63e18db
--- /dev/null
+++ b/entity/Contract_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.CONTRACTID"));
diff --git a/entity/Contract_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js b/entity/Contract_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
new file mode 100644
index 0000000000..431bcc9521
--- /dev/null
+++ b/entity/Contract_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("Context_lib");
+
+result.string(ContextUtils.getCurrentContextId());
diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod
index 381b03b869..d1ed432323 100644
--- a/entity/Offer_entity/Offer_entity.aod
+++ b/entity/Offer_entity/Offer_entity.aod
@@ -636,6 +636,28 @@
       <expose v="true" />
       <description>PARAMETER</description>
     </entityParameter>
+    <entityConsumer>
+      <name>AttributeTree</name>
+      <title>Attribute Tree</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>AttributeRelationTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ObjectRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>ObjectType_param</name>
+          <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Offer_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js b/entity/Offer_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
new file mode 100644
index 0000000000..4adebe4edf
--- /dev/null
+++ b/entity/Offer_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.OFFERID"));
\ No newline at end of file
diff --git a/entity/Offer_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js b/entity/Offer_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
new file mode 100644
index 0000000000..431bcc9521
--- /dev/null
+++ b/entity/Offer_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("Context_lib");
+
+result.string(ContextUtils.getCurrentContextId());
diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod
index 90e490097c..71a1654983 100644
--- a/entity/Organisation_entity/Organisation_entity.aod
+++ b/entity/Organisation_entity/Organisation_entity.aod
@@ -398,6 +398,7 @@
       <children>
         <entityParameter>
           <name>ObjectRowId_param</name>
+          <title></title>
           <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/attributes/children/objectrowid_param/valueProcess.js</valueProcess>
           <triggerRecalculation v="true" />
         </entityParameter>
@@ -721,6 +722,28 @@
       <expose v="true" />
       <description>PARAMETER</description>
     </entityParameter>
+    <entityConsumer>
+      <name>AttributeTree</name>
+      <title>Attribute Tree</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>AttributeRelationTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ObjectRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>ObjectType_param</name>
+          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Organisation_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js b/entity/Organisation_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
new file mode 100644
index 0000000000..957f645b37
--- /dev/null
+++ b/entity/Organisation_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.ORGANISATIONID"));
\ No newline at end of file
diff --git a/entity/Organisation_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js b/entity/Organisation_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
new file mode 100644
index 0000000000..431bcc9521
--- /dev/null
+++ b/entity/Organisation_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("Context_lib");
+
+result.string(ContextUtils.getCurrentContextId());
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index b8b639094d..3772446a2f 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -781,6 +781,28 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityConsumer>
+      <name>AttributeTree</name>
+      <title>Attribute Tree</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>AttributeRelationTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ObjectRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Person_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>ObjectType_param</name>
+          <valueProcess>%aditoprj%/entity/Person_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Person_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js b/entity/Person_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
new file mode 100644
index 0000000000..07081dc34f
--- /dev/null
+++ b/entity/Person_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.PERSONID"));
diff --git a/entity/Person_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js b/entity/Person_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
new file mode 100644
index 0000000000..431bcc9521
--- /dev/null
+++ b/entity/Person_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("Context_lib");
+
+result.string(ContextUtils.getCurrentContextId());
diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod
index cd11c3d2bc..481c5df54c 100644
--- a/entity/Product_entity/Product_entity.aod
+++ b/entity/Product_entity/Product_entity.aod
@@ -404,6 +404,28 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityConsumer>
+      <name>AttributeTree</name>
+      <title>Attribute Tree</title>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>AttributeRelationTree_entity</entityName>
+        <fieldName>TreeProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ObjectRowId_param</name>
+          <valueProcess>%aditoprj%/entity/Product_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+        <entityParameter>
+          <name>ObjectType_param</name>
+          <valueProcess>%aditoprj%/entity/Product_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js</valueProcess>
+          <triggerRecalculation v="true" />
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
diff --git a/entity/Product_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js b/entity/Product_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
new file mode 100644
index 0000000000..60b7269a1b
--- /dev/null
+++ b/entity/Product_entity/entityfields/attributetree/children/objectrowid_param/valueProcess.js
@@ -0,0 +1,5 @@
+import("system.vars");
+import("system.result");
+import("Context_lib");
+
+result.string(vars.get("$field.PRODUCTID"));
diff --git a/entity/Product_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js b/entity/Product_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
new file mode 100644
index 0000000000..431bcc9521
--- /dev/null
+++ b/entity/Product_entity/entityfields/attributetree/children/objecttype_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("Context_lib");
+
+result.string(ContextUtils.getCurrentContextId());
diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
index 7b30b805b9..4e36c06524 100644
--- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
+++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
@@ -359,6 +359,10 @@
       <key>Touchpoints</key>
       <value>Kontaktpunkte</value>
     </entry>
+    <entry>
+      <key>Attribute Tree</key>
+      <value>Eigenschaftsbaum</value>
+    </entry>
     <entry>
       <key>Company Addresses</key>
       <value>Firmenadressen</value>
diff --git a/neonContext/AttributeRelationTree/AttributeRelationTree.aod b/neonContext/AttributeRelationTree/AttributeRelationTree.aod
new file mode 100644
index 0000000000..bcd7bec8f8
--- /dev/null
+++ b/neonContext/AttributeRelationTree/AttributeRelationTree.aod
@@ -0,0 +1,12 @@
+<?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.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0">
+  <name>AttributeRelationTree</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <entity>AttributeRelationTree_entity</entity>
+  <references>
+    <neonViewReference>
+      <name>55f89863-72b0-4179-8494-b1e320d79de9</name>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
+  </references>
+</neonContext>
diff --git a/neonView/ActivityMain_view/ActivityMain_view.aod b/neonView/ActivityMain_view/ActivityMain_view.aod
index eb9974e40d..af453fbc92 100644
--- a/neonView/ActivityMain_view/ActivityMain_view.aod
+++ b/neonView/ActivityMain_view/ActivityMain_view.aod
@@ -39,5 +39,10 @@
       <entityField>Attributes</entityField>
       <view>AttributeRelationFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>f57fb116-d356-47c7-8da6-ee64b4a01b46</name>
+      <entityField>AttributeTree</entityField>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod b/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod
index d655cdd2da..3a0762d98f 100644
--- a/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod
+++ b/neonView/AttributeRelationFilter_view/AttributeRelationFilter_view.aod
@@ -5,9 +5,9 @@
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <filterable v="true" />
   <layout>
-    <groupLayout>
+    <boxLayout>
       <name>layout</name>
-    </groupLayout>
+    </boxLayout>
   </layout>
   <children>
     <tableViewTemplate>
@@ -25,14 +25,5 @@
         </neonTableColumn>
       </columns>
     </tableViewTemplate>
-    <treetableViewTemplate>
-      <name>RelationsTreetable</name>
-      <titleField>valueProxy</titleField>
-      <defaultGroupFields>
-        <element>ATTRIBUTE_PARENT_ID</element>
-        <element>AB_ATTRIBUTE_ID</element>
-      </defaultGroupFields>
-      <entityField>#ENTITY</entityField>
-    </treetableViewTemplate>
   </children>
 </neonView>
diff --git a/neonView/AttributeRelationTree_view/AttributeRelationTree_view.aod b/neonView/AttributeRelationTree_view/AttributeRelationTree_view.aod
index b1cd03b35f..cdb9d96720 100644
--- a/neonView/AttributeRelationTree_view/AttributeRelationTree_view.aod
+++ b/neonView/AttributeRelationTree_view/AttributeRelationTree_view.aod
@@ -1,21 +1,18 @@
-<?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.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.0">
-  <name>AttributeRelationTree_view</name>
-  <title>Attributes</title>
-  <majorModelMode>DISTRIBUTED</majorModelMode>
-  <filterable v="true" />
-  <layout>
-    <groupLayout>
-      <name>layout</name>
-    </groupLayout>
-  </layout>
-  <children>
-    <treetableViewTemplate>
-      <name>Treetable</name>
-      <titleField>AB_ATTRIBUTE_ID</titleField>
-      <descriptionField>ATTRIBUTERELATION_VALUE</descriptionField>
-      <entityField>#ENTITY</entityField>
-      <title></title>
-    </treetableViewTemplate>
-  </children>
-</neonView>
+<?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.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.0">
+  <name>AttributeRelationTree_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <treetableViewTemplate>
+      <name>AttributeRelationTree</name>
+      <parentField>PARENT_ID</parentField>
+      <titleField>TITLE</titleField>
+      <entityField>#ENTITY</entityField>
+    </treetableViewTemplate>
+  </children>
+</neonView>
diff --git a/neonView/ContractMain_view/ContractMain_view.aod b/neonView/ContractMain_view/ContractMain_view.aod
index 3ceece9059..a40e7c73b8 100644
--- a/neonView/ContractMain_view/ContractMain_view.aod
+++ b/neonView/ContractMain_view/ContractMain_view.aod
@@ -29,5 +29,10 @@
       <entityField>Attributes</entityField>
       <view>AttributeRelationFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>940f0dca-aee3-4af6-ae50-9334964ce414</name>
+      <entityField>AttributeTree</entityField>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/OfferMain_view/OfferMain_view.aod b/neonView/OfferMain_view/OfferMain_view.aod
index 5acba02e0c..bd7a35f5f6 100644
--- a/neonView/OfferMain_view/OfferMain_view.aod
+++ b/neonView/OfferMain_view/OfferMain_view.aod
@@ -44,5 +44,10 @@
       <entityField>Attributes</entityField>
       <view>AttributeRelationFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>e1554e33-710f-4bb5-a345-953c15985ca4</name>
+      <entityField>AttributeTree</entityField>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/OrganisationMain_view/OrganisationMain_view.aod b/neonView/OrganisationMain_view/OrganisationMain_view.aod
index 3e7ccf4980..a8dde5ffe1 100644
--- a/neonView/OrganisationMain_view/OrganisationMain_view.aod
+++ b/neonView/OrganisationMain_view/OrganisationMain_view.aod
@@ -60,5 +60,10 @@
       <entityField>Attributes</entityField>
       <view>AttributeRelationFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>ba50e069-06da-440e-b04a-5a686fcf5303</name>
+      <entityField>AttributeTree</entityField>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/PersonMain_view/PersonMain_view.aod b/neonView/PersonMain_view/PersonMain_view.aod
index afe8033aee..6ab7d40c76 100644
--- a/neonView/PersonMain_view/PersonMain_view.aod
+++ b/neonView/PersonMain_view/PersonMain_view.aod
@@ -49,6 +49,11 @@
       <entityField>Attributes</entityField>
       <view>AttributeRelationFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>cf989bf6-3e49-44fc-ba98-322aae377da3</name>
+      <entityField>AttributeTree</entityField>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
     <neonViewReference>
       <name>c2606a8b-eac1-412e-893d-bb788d4a5b5c</name>
       <entityField>OtherContacts</entityField>
diff --git a/neonView/ProductMain_view/ProductMain_view.aod b/neonView/ProductMain_view/ProductMain_view.aod
index 7ac4a87c4d..28de5da816 100644
--- a/neonView/ProductMain_view/ProductMain_view.aod
+++ b/neonView/ProductMain_view/ProductMain_view.aod
@@ -49,5 +49,10 @@
       <entityField>Attributes</entityField>
       <view>AttributeRelationFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>6ee1258f-b571-45c1-b833-f292361b5a04</name>
+      <entityField>AttributeTree</entityField>
+      <view>AttributeRelationTree_view</view>
+    </neonViewReference>
   </children>
 </neonView>
diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js
index 6614f1c741..08b0fba8f9 100644
--- a/process/Attribute_lib/process.js
+++ b/process/Attribute_lib/process.js
@@ -199,17 +199,18 @@ AttributeRelationUtils.getAttribute = function (pAttributeId, pObjectRowId, pObj
  * @param {String} pObjectRowId object rowid
  * @param {String} [pObjectType=null] object-type
  * @param {String} [pResolveNames=false] if true the full attribute names are used instead of the ids
+ * @param {String} [pGetUID=false] include the attributeRelation id
  * 
- * @return {String[][]} two-dimensional array a row is [attributeId|attributeName, value]
+ * @return {String[][]} two-dimensional array a row is [attributeId|attributeName, value] or if pGetUID is true, [attriuteRelationId, attributeId|attributeName, value]
  */
-AttributeRelationUtils.getAllAttributes = function (pObjectRowId, pObjectType, pResolveNames)
+AttributeRelationUtils.getAllAttributes = function (pObjectRowId, pObjectType, pResolveNames, pGetUID)
 {
     var attrCond = SqlCondition.begin()
         .andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", pObjectRowId);
     if (pObjectType != null)
-        attrCond.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", pAttributeId);
+        attrCond.andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", pObjectType);
     
-    var attributeSql = attrCond.buildSql("select AB_ATTRIBUTE_ID, AB_ATTRIBUTE.ATTRIBUTE_TYPE, AB_ATTRIBUTE.KEYWORD_CONTAINER, COMBOVAL.ATTRIBUTE_NAME, " 
+    var attributeSql = attrCond.buildSql("select AB_ATTRIBUTERELATIONID, AB_ATTRIBUTE_ID, AB_ATTRIBUTE.ATTRIBUTE_TYPE, AB_ATTRIBUTE.KEYWORD_CONTAINER, COMBOVAL.ATTRIBUTE_NAME, " 
         + AttributeTypeUtil.getAllDatabaseFields().join(", ")
         + " from AB_ATTRIBUTERELATION join AB_ATTRIBUTE on AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID"
         + " left join AB_ATTRIBUTE COMBOVAL on " + $AttributeTypes.COMBO.databaseField + " = COMBOVAL.AB_ATTRIBUTEID");
@@ -217,7 +218,7 @@ AttributeRelationUtils.getAllAttributes = function (pObjectRowId, pObjectType, p
     var attributeNameMap = {};
     var attributeValues = db.table(attributeSql).map(function (row) 
     {
-        let attribute = row[0];
+        let attribute = row[1];
         if (pResolveNames)
         {
             if (!(attribute in attributeNameMap))
@@ -225,13 +226,15 @@ AttributeRelationUtils.getAllAttributes = function (pObjectRowId, pObjectType, p
             attribute = attributeNameMap[attribute];
         }
         let value;
-        if (row[1].trim() == $AttributeTypes.COMBO)
-            value = row[3];
+        if (row[2].trim() == $AttributeTypes.COMBO)
+            value = row[4];
         else
         {
-            value = row[AttributeTypeUtil.getTypeColumnIndex(row[1]) + 4];
-            value = AttributeTypeUtil.getAttributeViewValue(row[1].trim(), value, row[2]);
+            value = row[AttributeTypeUtil.getTypeColumnIndex(row[2]) + 5];
+            value = AttributeTypeUtil.getAttributeViewValue(row[2].trim(), value, row[3]);
         }
+        if (pGetUID)
+            return [row[0], attribute, value];
         return [attribute, value];
     });
     
-- 
GitLab