From 1fb8bd42233fc4559aa55c82b9d3c6106173bcf0 Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Thu, 31 Jan 2019 16:25:10 +0100
Subject: [PATCH] Attribute doku

---
 .../AttributeRelation_entity.aod              |  18 +-
 .../documentation.adoc                        |   6 +
 .../ab_attribute_id/stateProcess.js           |   6 +-
 .../attributerelation_value/onValueChange.js  |   5 +-
 .../attributerelation_value/valueProcess.js   |  10 +-
 .../attribute_name.value/expression.js        |   3 -
 .../attribute_type.value/expression.js        |   0
 .../AttributeUsage_entity.aod                 |   5 +-
 .../AttributeUsage_entity/documentation.adoc  |   6 +
 .../object_type/possibleItemsProcess.js       |   1 +
 entity/Attribute_entity/Attribute_entity.aod  |   7 +
 entity/Attribute_entity/documentation.adoc    |   8 +
 .../_____LANGUAGE_EXTRA.aod                   |   4 +-
 .../_____LANGUAGE_en/_____LANGUAGE_en.aod     |   5 +-
 .../AttributeUsageFilter_view.aod             |   1 +
 process/Attribute_lib/process.js              | 173 +++++++++++++-----
 16 files changed, 172 insertions(+), 86 deletions(-)
 create mode 100644 entity/AttributeRelation_entity/documentation.adoc
 delete mode 100644 entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_name.value/expression.js
 delete mode 100644 entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_type.value/expression.js
 create mode 100644 entity/AttributeUsage_entity/documentation.adoc
 create mode 100644 entity/Attribute_entity/documentation.adoc

diff --git a/entity/AttributeRelation_entity/AttributeRelation_entity.aod b/entity/AttributeRelation_entity/AttributeRelation_entity.aod
index 1e4c91f04c..d92ad249c9 100644
--- a/entity/AttributeRelation_entity/AttributeRelation_entity.aod
+++ b/entity/AttributeRelation_entity/AttributeRelation_entity.aod
@@ -1,8 +1,9 @@
 <?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>AttributeRelation_entity</name>
-  <title>Attributes</title>
+  <title>Attribute Relation</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <documentation>%aditoprj%/entity/AttributeRelation_entity/documentation.adoc</documentation>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityIncomingField>
@@ -50,7 +51,6 @@
     </entityField>
     <entityField>
       <name>CHAR_VALUE</name>
-      <state>EDITABLE</state>
     </entityField>
     <entityIncomingField>
       <name>OrgAttr_dfi</name>
@@ -65,9 +65,6 @@
         </entityDependency>
       </dependencies>
     </entityIncomingField>
-    <entityField>
-      <name>ATTRIBUTE_NAME</name>
-    </entityField>
     <entityParameter>
       <name>objectRowId_param</name>
       <expose v="true" />
@@ -83,9 +80,6 @@
       <contentType>NUMBER</contentType>
       <state>EDITABLE</state>
     </entityField>
-    <entityField>
-      <name>ATTRIBUTE_TYPE</name>
-    </entityField>
     <entityParameter>
       <name>objectType_param</name>
       <expose v="true" />
@@ -159,14 +153,6 @@
           <name>NUMBER_VALUE.value</name>
           <recordfield>AB_ATTRIBUTERELATION.NUMBER_VALUE</recordfield>
         </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>ATTRIBUTE_NAME.value</name>
-          <expression>%aditoprj%/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_name.value/expression.js</expression>
-        </dbRecordFieldMapping>
-        <dbRecordFieldMapping>
-          <name>ATTRIBUTE_TYPE.value</name>
-          <expression>%aditoprj%/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_type.value/expression.js</expression>
-        </dbRecordFieldMapping>
         <dbRecordFieldMapping>
           <name>BOOL_VALUE.value</name>
           <recordfield>AB_ATTRIBUTERELATION.BOOL_VALUE</recordfield>
diff --git a/entity/AttributeRelation_entity/documentation.adoc b/entity/AttributeRelation_entity/documentation.adoc
new file mode 100644
index 0000000000..0f6d6bbdb1
--- /dev/null
+++ b/entity/AttributeRelation_entity/documentation.adoc
@@ -0,0 +1,6 @@
+Attribute Relation
+==================
+
+----
+an entity for managing values that are set for an attribute
+----
\ No newline at end of file
diff --git a/entity/AttributeRelation_entity/entityfields/ab_attribute_id/stateProcess.js b/entity/AttributeRelation_entity/entityfields/ab_attribute_id/stateProcess.js
index 749c17f240..53cae9c41b 100644
--- a/entity/AttributeRelation_entity/entityfields/ab_attribute_id/stateProcess.js
+++ b/entity/AttributeRelation_entity/entityfields/ab_attribute_id/stateProcess.js
@@ -1,5 +1 @@
-//import("system.vars");
-//import("system.result");
-//
-//if (vars.get("$field.ATTRIBUTERELATION_VALUE"))
-//    result.string("READONLY");
\ No newline at end of file
+//TODO: the attribute id should be readonly if a value is set
\ No newline at end of file
diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js
index 0dcab8e25a..0058ef20ab 100644
--- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js
+++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("system.vars");
 import("Entity_lib");
 import("Attribute_lib");
@@ -7,6 +6,4 @@ var attrValue = vars.exists("$field.ATTRIBUTERELATION_VALUE") ? vars.get("$field
 attrValue = ProcessHandlingUtils.getOnValidationValue(attrValue);
 var attribute = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID"));
 
-attribute.setAttributeValue(attrValue);
-
-//logging.log("field is " + field + " and attrvalue is " + attrValue)
\ No newline at end of file
+attribute.setAttributeValue(attrValue);
\ No newline at end of file
diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js
index dc4b3c47ba..1328a770b8 100644
--- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js
+++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js
@@ -1,14 +1,8 @@
-import("system.logging");
 import("system.result");
 import("system.vars");
 import("Attribute_lib");
 
-//var attrValue = vars.getString("$field.ATTRIBUTERELATION_VALUE");
 var attrField = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField();
 
-if (attrField != null)
-{
-    logging.log("value of " + vars.get("$field.AB_ATTRIBUTERELATIONID") + " (" + vars.get("$field.ATTRIBUTE_NAME") + ") = " + attrField)
-    result.string(vars.get(attrField));
-}
-
+if (attrField != null) //load the value from the correct field for the type
+    result.string(vars.get(attrField));
\ No newline at end of file
diff --git a/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_name.value/expression.js b/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_name.value/expression.js
deleted file mode 100644
index e4aa4657a2..0000000000
--- a/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_name.value/expression.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import("system.result");
-
-result.string("select ATTRIBUTE_NAME from AB_ATTRIBUTE where AB_ATTRIBUTE.AB_ATTRIBUTEID = AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID");
\ No newline at end of file
diff --git a/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_type.value/expression.js b/entity/AttributeRelation_entity/recordcontainers/db/recordfieldmappings/attribute_type.value/expression.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/entity/AttributeUsage_entity/AttributeUsage_entity.aod b/entity/AttributeUsage_entity/AttributeUsage_entity.aod
index 02591fac2b..0f58f4ae95 100644
--- a/entity/AttributeUsage_entity/AttributeUsage_entity.aod
+++ b/entity/AttributeUsage_entity/AttributeUsage_entity.aod
@@ -1,7 +1,9 @@
 <?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>AttributeUsage_entity</name>
+  <title>Attribute Usage</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <documentation>%aditoprj%/entity/AttributeUsage_entity/documentation.adoc</documentation>
   <recordContainer>db</recordContainer>
   <entityFields>
     <entityIncomingField>
@@ -9,7 +11,7 @@
     </entityIncomingField>
     <entityField>
       <name>OBJECT_TYPE</name>
-      <title>Entity</title>
+      <title>Context</title>
       <possibleItemsProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/object_type/possibleItemsProcess.js</possibleItemsProcess>
     </entityField>
     <entityField>
@@ -34,6 +36,7 @@
     </entityField>
     <entityField>
       <name>AB_ATTRIBUTE_ID</name>
+      <searchable v="false" />
       <valueProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/ab_attribute_id/valueProcess.js</valueProcess>
     </entityField>
     <entityIncomingField>
diff --git a/entity/AttributeUsage_entity/documentation.adoc b/entity/AttributeUsage_entity/documentation.adoc
new file mode 100644
index 0000000000..21f956b435
--- /dev/null
+++ b/entity/AttributeUsage_entity/documentation.adoc
@@ -0,0 +1,6 @@
+Attribute Usage
+===============
+
+----
+an entity for defining in what contexts an attribute can be used
+----
\ No newline at end of file
diff --git a/entity/AttributeUsage_entity/entityfields/object_type/possibleItemsProcess.js b/entity/AttributeUsage_entity/entityfields/object_type/possibleItemsProcess.js
index ad231346ea..c23cd2f0ba 100644
--- a/entity/AttributeUsage_entity/entityfields/object_type/possibleItemsProcess.js
+++ b/entity/AttributeUsage_entity/entityfields/object_type/possibleItemsProcess.js
@@ -1,3 +1,4 @@
 import("system.result");
 
+//TODO: when available, use a function to get the possible contexts
 result.object([["Org_context", "Org"]]);
\ No newline at end of file
diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod
index 2a9637e1bd..cab02b0f3e 100644
--- a/entity/Attribute_entity/Attribute_entity.aod
+++ b/entity/Attribute_entity/Attribute_entity.aod
@@ -3,6 +3,7 @@
   <name>Attribute_entity</name>
   <title>Attributes</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <documentation>%aditoprj%/entity/Attribute_entity/documentation.adoc</documentation>
   <iconId>VAADIN:TAG</iconId>
   <recordContainer>db</recordContainer>
   <entityFields>
@@ -22,28 +23,34 @@
     </entityField>
     <entityField>
       <name>AB_ATTRIBUTEID</name>
+      <searchable v="false" />
       <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/ab_attributeid/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>ATTRIBUTE_PARENT_ID</name>
+      <title>Parent Attribute</title>
     </entityField>
     <entityField>
       <name>DATE_NEW</name>
+      <title>{$DATE_NEW}</title>
       <contentType>DATE</contentType>
       <state>READONLY</state>
       <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/date_new/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>DATE_EDIT</name>
+      <title>{$DATE_EDIT}</title>
       <contentType>DATE</contentType>
     </entityField>
     <entityField>
       <name>USER_NEW</name>
+      <title>{$USER_NEW}</title>
       <state>READONLY</state>
       <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/user_new/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>USER_EDIT</name>
+      <title>{$USER_EDIT}</title>
     </entityField>
     <entityOutgoingField>
       <name>AttributeChild_dfo</name>
diff --git a/entity/Attribute_entity/documentation.adoc b/entity/Attribute_entity/documentation.adoc
new file mode 100644
index 0000000000..645cba4e8c
--- /dev/null
+++ b/entity/Attribute_entity/documentation.adoc
@@ -0,0 +1,8 @@
+Attribute
+=========
+
+----
+an entity for the definition of attributes
+----
+
+The Attribute entity is for creating new attributes that can be used in different other entitys.
\ No newline at end of file
diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
index 18311db9c9..a34ffa0539 100644
--- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
+++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
@@ -1487,7 +1487,6 @@
     </entry>
     <entry>
       <key>${FORECAST_ENGLISH}</key>
-      <key>${ADDRESS_STATE}</key>
     </entry>
     <entry>
       <key>${NUMBER}</key>
@@ -1501,6 +1500,9 @@
     <entry>
       <key>Minimal Count</key>
     </entry>
+    <entry>
+      <key>${ADDRESS_STATE}</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
   <sqlModels>
diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
index 15d7363585..ac6c84f0a0 100644
--- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
+++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
@@ -1517,8 +1517,6 @@
     <entry>
       <key>${FORECAST_ENGLISH}</key>
       <value>Forecast</value>
-      <key>${ADDRESS_STATE}</key>
-      <value>state</value>
     </entry>
     <entry>
       <key>${NUMBER}</key>
@@ -1533,6 +1531,9 @@
     <entry>
       <key>Minimal Count</key>
     </entry>
+    <entry>
+      <key>${ADDRESS_STATE}</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
 </language>
diff --git a/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod b/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod
index 78e83f9ef0..ebd9d7f89a 100644
--- a/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod
+++ b/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod
@@ -1,6 +1,7 @@
 <?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>AttributeUsageFilter_view</name>
+  <description>View for listing all contexts where a attribute can be used in the attribute entity</description>
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <layout>
     <boxLayout>
diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js
index 8c541df0b1..a696893d3a 100644
--- a/process/Attribute_lib/process.js
+++ b/process/Attribute_lib/process.js
@@ -5,13 +5,22 @@ import("system.db");
 import("Sql_lib");
 
 /**
- * Provides functions for the work with attributes.
+ * Provides functions for the work with attributes, like setting or getting the value of an attribute
+ * or listing the available attributes for a context.
  * Don't instanciate this!
  * 
  * @class
  */
 function AttributeUtil () {}
 
+/**
+ * Gives a list of all available attributes for a context. This is used in the possibleItems
+ * process for the attribute id in AttributeRelation
+ * 
+ * @param {String} pObjectType the object type (= context)
+ * 
+ * @return {String[][]} two-dimensional array of attributeIds and names
+ */
 AttributeUtil.getPossibleAttributes = function (pObjectType)
 {
     if (pObjectType == null)
@@ -21,31 +30,41 @@ AttributeUtil.getPossibleAttributes = function (pObjectType)
         + " join AB_ATTRIBUTEUSAGE  on AB_ATTRIBUTEID = AB_ATTRIBUTE_ID";
     attrSql = SqlCondition.begin()
         .andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType)
+        .and("ATTRIBUTE_ACTIVE = 1")
         .buildSql(attrSql);
 
     return db.table(attrSql);
 }
 
-AttributeUtil.getAttribute = function ()
+/**
+ * gets the value of an attribute for one dataset (e. g. a person)
+ */
+AttributeUtil.getAttribute = function (pAttributeId, pObjectType, pObjectRowId, pGetIdValue)
 {
-    
+    //TODO: implement
 }
 
 AttributeUtil.getAttributes = function ()
 {
-    
+    //TODO: implement maybe
 }
 
+/**
+ * sets the value of an attribute for one dataset (e. g. a person)
+ */
 AttributeUtil.setAttribute = function ()
 {
-    
+    //TODO: implement
 }
 
 
 /**
- * object for handling values of the AttributeRelation entity
+ * This is used in the AttributeRelation enitiy to make the work with attributes there
+ * easier. You probaly won't need this for anything else.
+ * 
+ * @param {String} pAttrId the id of the attribute
  */
-function AttributeHandler (pAttrId) 
+function AttributeHandler (pAttrId)   //TODO: find out if this class is necessary, maybe there is a more elegant solution, this could also be static
 {
     this.attributeId = pAttrId;
     this._attributeType = null;
@@ -62,7 +81,7 @@ AttributeHandler.begin = function (pAttrId)
  * 
  * @return {String} attribute type
  */
-AttributeHandler.prototype._getAttributeType = function () 
+AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the type should be an own field in the entity instead of getting the type from the attribute id
 {
     if (this._attributeType == null && this.attributeId != null)
     {
@@ -82,9 +101,14 @@ AttributeHandler.prototype._getAttributeType = function ()
  */
 AttributeHandler.prototype.getAttributeField = function ()
 {
-    return AttributeTypes.getAttributeField(this._getAttributeType());
+    return AttributeTypes.getEntityField(this._getAttributeType());
 }
 
+/**
+ * returns the content type that belongs to the type of the attribute
+ * 
+ * @return {String} attribute field
+ */
 AttributeHandler.prototype.getAttributeContentType = function ()
 {
     return AttributeTypes.getContentType(this._getAttributeType());
@@ -99,16 +123,66 @@ AttributeHandler.prototype.setAttributeValue = function (pValue)
 }
 
 /**
- * Object for the enumeration of all attribute types.
+ * Object for the enumeration and management of all attribute types.
+ * This Object is only for the general definition of attribute types and for getting
+ * data about every type, anything that has to do with a specific attribute (= the function requires an attribute id)
+ * should be done in AttributeUtils.
  */
 var AttributeTypes = {
+    _attributeTypeConfig : {},
     TEXT : "TEXT",
     DATE : "DATE",
     NUMBER : "NUMBER",
     BOOLEAN : "BOOLEAN",
     COMBO : "COMBO",
     GROUP : "GROUP"
-}
+};
+
+/**
+ * These objects hold important data for the attribute types. 
+ * The values for each type are:
+ * 
+ * name = the displayed name when selecting the type of an attribute
+ * contentType = the value that is returned in the contentType process for the attribute
+ * databaseField = the database field that holds values of attributes with the type
+ * entityField = the field in the AttributeRelation enity that holds the value of the attribute for that type
+ */
+AttributeTypes._attributeTypeConfig[AttributeTypes.TEXT] = { //TODO: it would probably be better if the name was a keyword
+    name : "Text",
+    contentType : "TEXT", 
+    databaseField : "CHAR_VALUE", 
+    entityField : "$field.CHAR_VALUE"
+};
+AttributeTypes._attributeTypeConfig[AttributeTypes.DATE] = {
+    name : "Date",
+    contentType : "DATE", 
+    databaseField : "DATE_VALUE", 
+    entityField : "$field.DATE_VALUE"
+};
+AttributeTypes._attributeTypeConfig[AttributeTypes.NUMBER] = {
+    name : "${NUMBER}",
+    contentType : "NUMBER", 
+    databaseField : "NUMBER_VALUE", 
+    entityField : "$field.NUMBER_VALUE"
+};
+AttributeTypes._attributeTypeConfig[AttributeTypes.BOOLEAN] = {
+    name : "Checkbox",
+    contentType : "BOOLEAN", 
+    databaseField : "BOOL_VALUE", 
+    entityField : "$field.BOOL_VALUE"
+};
+AttributeTypes._attributeTypeConfig[AttributeTypes.COMBO] = {
+    name : "Combobox",
+    contentType : "TEXT", 
+    databaseField : "ID_VALUE", 
+    entityField : "$field.ID_VALUE"
+};
+AttributeTypes._attributeTypeConfig[AttributeTypes.GROUP] = {
+    name : "Group",
+    contentType : null, 
+    databaseField : null, 
+    entityField : null
+};
 
 /**
  * returns the required contentType for the given attribute type
@@ -119,44 +193,51 @@ var AttributeTypes = {
  */
 AttributeTypes.getContentType = function (pAttributeType)
 {
-    switch (pAttributeType)
-    {
-        case AttributeTypes.TEXT:
-        case AttributeTypes.DATE:
-        case AttributeTypes.NUMBER:
-        case AttributeTypes.BOOLEAN:
-            return pAttributeType;
-        case AttributeTypes.COMBO:
-            return AttributeTypes.TEXT;
-        default:
-            return null; //TODO: change default value maybe
-    }
+    if (pAttributeType in AttributeTypes._attributeTypeConfig)
+        return AttributeTypes._attributeTypeConfig[pAttributeType].contentType;
+    return null;
 }
 
 /**
- * returns the required field for the given attribute type that holds the value of the attribute
+ * returns the entity field for the given attribute type that holds the value of the attribute
  * 
  * @param {String} pAttributeType the attribute type 
  *                  (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT)
  * @return {String} the field for the attribute
  */
-AttributeTypes.getAttributeField = function (pAttributeType)
+AttributeTypes.getEntityField = function (pAttributeType)
 {
-    switch (pAttributeType)
-    {
-        case AttributeTypes.TEXT:
-            return "$field.CHAR_VALUE";
-        case AttributeTypes.DATE:
-            return "$field.DATE_VALUE";
-        case AttributeTypes.NUMBER:
-            return "$field.NUMBER_VALUE";
-        case AttributeTypes.BOOLEAN:
-            return "$field.BOOL_VALUE";
-        case AttributeTypes.COMBO:
-            return "$field.ID_VALUE";
-        default:
-            return null; //TODO: change default value maybe
-    }
+    if (pAttributeType in AttributeTypes._attributeTypeConfig)
+        return AttributeTypes._attributeTypeConfig[pAttributeType].entityField;
+    return null;
+}
+
+/**
+ * returns the database field for the given attribute type that holds the value of the attribute
+ * 
+ * @param {String} pAttributeType the attribute type 
+ *                  (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT)
+ * @return {String} the database field for the attribute
+ */
+AttributeTypes.getDatabaseField = function (pAttributeType)
+{
+    if (pAttributeType in AttributeTypes._attributeTypeConfig)
+        return AttributeTypes._attributeTypeConfig[pAttributeType].databaseField;
+    return null;
+}
+
+/**
+ * returns the name of the given attribute type
+ * 
+ * @param {String} pAttributeType the attribute type 
+ *                  (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT)
+ * @return {String} the name the attribute
+ */
+AttributeTypes.getName = function (pAttributeType)
+{
+    if (pAttributeType in AttributeTypes._attributeTypeConfig)
+        return translate.text(AttributeTypes._attributeTypeConfig[pAttributeType].name);
+    return null;
 }
 
 /**
@@ -168,11 +249,11 @@ AttributeTypes.getAttributeField = function (pAttributeType)
 AttributeTypes.getTypeList = function ()
 {
     return [
-        [AttributeTypes.TEXT, translate.text("Text")],
-        [AttributeTypes.DATE, translate.text("Date")],
-        [AttributeTypes.NUMBER, translate.text("${NUMBER}")],
-        [AttributeTypes.BOOLEAN, translate.text("Checkbox")],
-        [AttributeTypes.COMBO, translate.text("Combobox")],
-        [AttributeTypes.GROUP, translate.text("Group")]
+        [AttributeTypes.TEXT, AttributeTypes.getName(AttributeTypes.TEXT)],
+        [AttributeTypes.COMBO, AttributeTypes.getName(AttributeTypes.COMBO)],
+        [AttributeTypes.NUMBER, AttributeTypes.getName(AttributeTypes.NUMBER)],
+        [AttributeTypes.DATE, AttributeTypes.getName(AttributeTypes.DATE)],
+        [AttributeTypes.BOOLEAN, AttributeTypes.getName(AttributeTypes.BOOLEAN)],
+        [AttributeTypes.GROUP, AttributeTypes.getName(AttributeTypes.GROUP)]
     ];
 }
-- 
GitLab