From 166d8d58606b3b6cd4393eab136b3d88d71e1f00 Mon Sep 17 00:00:00 2001
From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local>
Date: Tue, 5 Mar 2019 16:23:26 +0100
Subject: [PATCH] Memo Attribute

---
 aliasDefinition/Data_alias/Data_alias.aod         | 14 ++++++++++++++
 .../AttributeRelation_entity.aod                  |  7 +++++++
 .../attributerelation_value/valueProcess.js       |  7 +++++--
 .../2019.2/AditoBasic/init_AttributeType.xml      | 15 +++++++++++++++
 .../data_alias/basic/2019.2/AttributeKeyword.xml  |  3 +++
 process/Attribute_lib/process.js                  |  8 +++++++-
 process/Offer_lib/process.js                      |  6 +++++-
 7 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod
index c82ddacd86..a9d3da0dbd 100644
--- a/aliasDefinition/Data_alias/Data_alias.aod
+++ b/aliasDefinition/Data_alias/Data_alias.aod
@@ -4212,6 +4212,20 @@
                 <title></title>
                 <description></description>
               </entityFieldDb>
+              <entityFieldDb>
+                <name>MEMO_VALUE</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="2005" />
+                <size v="2147483647" />
+                <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/AttributeRelation_entity/AttributeRelation_entity.aod b/entity/AttributeRelation_entity/AttributeRelation_entity.aod
index 1f7e5274dd..b2ca6240ff 100644
--- a/entity/AttributeRelation_entity/AttributeRelation_entity.aod
+++ b/entity/AttributeRelation_entity/AttributeRelation_entity.aod
@@ -140,6 +140,9 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityField>
+      <name>MEMO_VALUE</name>
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
@@ -204,6 +207,10 @@
           <name>ATTRIBUTE_PARENT_ID.value</name>
           <recordfield>AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID</recordfield>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>MEMO_VALUE.value</name>
+          <recordfield>AB_ATTRIBUTERELATION.MEMO_VALUE</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js
index 02b623bee2..4895956380 100644
--- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js
+++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js
@@ -5,7 +5,7 @@ import("Attribute_lib");
 
 if(vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW)
 {
-    var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField();
+    var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType();
     var value = null;
     if (attrType != null) //load the value from the correct field for the type
     {
@@ -26,7 +26,10 @@ if(vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW)
             case $AttributeTypes.COMBO.toString():
             case $AttributeTypes.KEYWORD.toString():
                 value = vars.get("$field.ID_VALUE");
-                break;            
+                break;
+            case $AttributeTypes.MEMO.toString():
+                value = vars.get("$field.MEMO_VALUE");
+                break;
         }
     } 
     //var attrField = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField();
diff --git a/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml b/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml
index b3d3d1c074..3dc7188a6d 100644
--- a/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml
+++ b/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeType.xml
@@ -10,6 +10,15 @@
             <column name="ISACTIVE" valueNumeric="1"/>
             <column name="ISESSENTIAL" valueNumeric="1"/>
         </insert>
+        <insert tableName="AB_KEYWORD_ENTRY">
+            <column name="AB_KEYWORD_ENTRYID" value="1fa94dc3-b875-4e95-9ec1-8cb714f058fb"/>
+            <column name="KEYID" value="MEMO"/>
+            <column name="TITLE" value="Memo"/>
+            <column name="CONTAINER" value="AttributeType"/>
+            <column name="SORTING" valueNumeric="8"/>
+            <column name="ISACTIVE" valueNumeric="1"/>
+            <column name="ISESSENTIAL" valueNumeric="1"/>
+        </insert>
         <rollback>
             <delete tableName="AB_KEYWORD_ENTRY">
                 <where>AB_KEYWORD_ENTRYID = ?</where>
@@ -17,6 +26,12 @@
                     <param value="9d2f9605-1a5e-47d3-8920-168f5637e37f"/>
                 </whereParams>
             </delete>
+            <delete tableName="AB_KEYWORD_ENTRY">
+                <where>AB_KEYWORD_ENTRYID = ?</where>
+                <whereParams>
+                    <param value="1fa94dc3-b875-4e95-9ec1-8cb714f058fb"/>
+                </whereParams>
+            </delete>
         </rollback>
     </changeSet>
 </databaseChangeLog>
\ No newline at end of file
diff --git a/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml b/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml
index 4fe1d78f5b..a66ac3b370 100644
--- a/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml
+++ b/others/db_changes/data_alias/basic/2019.2/AttributeKeyword.xml
@@ -4,5 +4,8 @@
 	<addColumn tableName="AB_ATTRIBUTE">
             <column name="KEYWORD_CONTAINER" type="VARCHAR(80)"/>
 	</addColumn>
+	<addColumn tableName="AB_ATTRIBUTERELATION">
+            <column name="MEMO_VALUE" type="NCLOB"/>
+	</addColumn>
     </changeSet>
 </databaseChangeLog>
\ No newline at end of file
diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js
index b961c69330..6648cbb580 100644
--- a/process/Attribute_lib/process.js
+++ b/process/Attribute_lib/process.js
@@ -355,7 +355,13 @@ $AttributeTypes.KEYWORD = {
     databaseField : "ID_VALUE", 
     entityField : "ID_VALUE"
 };
-
+$AttributeTypes.MEMO = { 
+    toString : function () {return this.keyword},
+    keyword : "MEMO",
+    contentType : "TEXT", 
+    databaseField : "MEMO_VALUE", 
+    entityField : "MEMO_VALUE"
+};
 
 /**
  * returns the required contentType for the given attribute type
diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js
index bbb515daf3..ef2ffc8cce 100644
--- a/process/Offer_lib/process.js
+++ b/process/Offer_lib/process.js
@@ -357,10 +357,14 @@ OfferUtils.copyToOrder = function (pOfferId, pSalesprojectId, pContactId, pLangu
  */
 OfferUtils.getOfferTitleById = function (pOfferId)
 {
+    if (!pOfferId)
+        return "";
     var offerNumber = db.array(db.ROW, SqlCondition.begin()
         .andPrepare("OFFER.OFFERID", pOfferId)
         .buildSql("select OFFERCODE, VERSNR from OFFER"));
-    return translate.text("Offer") + " " + offerNumber.join("-");
+    return offerNumber.length > 0 
+        ? translate.text("Offer") + " " + offerNumber.join("-") 
+        : "";
 }
 
 
-- 
GitLab