From b6e0a5221921d57ef7cf97eeddcd57d85564d888 Mon Sep 17 00:00:00 2001
From: "m.kuhn" <m.kuhn@mkuhn.aditosoftware.local>
Date: Fri, 22 Mar 2019 12:31:34 +0100
Subject: [PATCH] LogHistory Entity

---
 aliasDefinition/Data_alias/Data_alias.aod     | 174 ++++++++++++++++++
 .../LogHistory_entity/LogHistory_entity.aod   |  18 +-
 .../entityfields/icon/valueProcess.js         |   3 +
 entity/LogHistory_entity/imageProcess.js      |   4 +
 .../recordcontainers/db/conditionProcess.js   |  11 +-
 .../recordcontainers/db/fromClauseProcess.js  |   3 -
 .../db_changes/data_alias/basic/init/init.xml |   3 +-
 .../indexsearch_patternextension.aod          |   1 +
 .../indexsearch_patternextension/process.js   |   0
 9 files changed, 197 insertions(+), 20 deletions(-)
 create mode 100644 entity/LogHistory_entity/entityfields/icon/valueProcess.js
 create mode 100644 entity/LogHistory_entity/imageProcess.js
 delete mode 100644 entity/LogHistory_entity/recordcontainers/db/fromClauseProcess.js
 create mode 100644 process/indexsearch_patternextension/process.js

diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod
index 6bc32d7d9da..129f13c5f97 100644
--- a/aliasDefinition/Data_alias/Data_alias.aod
+++ b/aliasDefinition/Data_alias/Data_alias.aod
@@ -5088,6 +5088,180 @@
               </entityFieldDb>
             </entityFields>
           </entityDb>
+          <entityDb>
+            <name>AB_LOGHISTORY</name>
+            <dbName></dbName>
+            <idColumn>AB_LOGHISTORYID</idColumn>
+            <idGeneratorType v="0" />
+            <idGeneratorInterval v="1" />
+            <documentation></documentation>
+            <title></title>
+            <description></description>
+            <auditSyncConfig>
+              <name>auditSyncConfig</name>
+              <auditMode v="0" />
+              <syncActive v="false" />
+              <syncComplete v="true" />
+              <syncDirection v="1" />
+              <syncIds></syncIds>
+            </auditSyncConfig>
+            <entityFields>
+              <entityFieldDb>
+                <name>TABLENAME</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="30" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>DATE_EDIT</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="93" />
+                <size v="29" />
+                <scale v="9" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>DESCRIPTION</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>
+              <entityFieldDb>
+                <name>SOURCE_TABLENAMEID</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>LOGTYPE</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="1" />
+                <size v="1" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>SOURCE_TABLENAME</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="30" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>AB_LOGHISTORYID</name>
+                <dbName></dbName>
+                <primaryKey v="true" />
+                <columnType v="1" />
+                <size v="36" />
+                <scale v="0" />
+                <notNull v="true" />
+                <isUnique v="true" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>TABLENAMEID</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>DATE_NEW</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="93" />
+                <size v="29" />
+                <scale v="9" />
+                <notNull v="true" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>USER_NEW</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="50" />
+                <scale v="0" />
+                <notNull v="true" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+              <entityFieldDb>
+                <name>USER_EDIT</name>
+                <dbName></dbName>
+                <primaryKey v="false" />
+                <columnType v="12" />
+                <size v="50" />
+                <scale v="0" />
+                <notNull v="false" />
+                <isUnique v="false" />
+                <index v="false" />
+                <documentation></documentation>
+                <title></title>
+                <description></description>
+              </entityFieldDb>
+            </entityFields>
+          </entityDb>
         </entities>
       </entityGroup>
     </aliasDefDb>
diff --git a/entity/LogHistory_entity/LogHistory_entity.aod b/entity/LogHistory_entity/LogHistory_entity.aod
index d9e9f9bfb00..b1ef5987822 100644
--- a/entity/LogHistory_entity/LogHistory_entity.aod
+++ b/entity/LogHistory_entity/LogHistory_entity.aod
@@ -12,6 +12,7 @@
     <entityField>
       <name>DATE_NEW</name>
       <contentType>DATE</contentType>
+      <resolution>SECOND</resolution>
       <mandatory v="true" />
     </entityField>
     <entityField>
@@ -23,14 +24,6 @@
       <contentType>TEXT</contentType>
       <mandatory v="true" />
     </entityField>
-    <entityField>
-      <name>TABLENAME</name>
-      <mandatory v="true" />
-    </entityField>
-    <entityField>
-      <name>TABLENAMEID</name>
-      <mandatory v="true" />
-    </entityField>
     <entityParameter>
       <name>tablenameId_param</name>
       <expose v="true" />
@@ -71,13 +64,16 @@
       <mandatory v="true" />
       <description>PARAMETER</description>
     </entityParameter>
+    <entityField>
+      <name>LOGHISTORYID</name>
+      <mandatory v="true" />
+    </entityField>
   </entityFields>
   <recordContainers>
     <dbRecordContainer>
       <name>db</name>
       <title>LogHistory</title>
       <alias>Data_alias</alias>
-      <fromClauseProcess>%aditoprj%/entity/LogHistory_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
       <conditionProcess>%aditoprj%/entity/LogHistory_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
       <linkInformation>
         <linkInformation>
@@ -110,6 +106,10 @@
           <name>USER_NEW.value</name>
           <recordfield>AB_LOGHISTORY.USER_NEW</recordfield>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>LOGHISTORYID.value</name>
+          <recordfield>AB_LOGHISTORY.AB_LOGHISTORYID</recordfield>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/LogHistory_entity/entityfields/icon/valueProcess.js b/entity/LogHistory_entity/entityfields/icon/valueProcess.js
new file mode 100644
index 00000000000..99ead80ca86
--- /dev/null
+++ b/entity/LogHistory_entity/entityfields/icon/valueProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.string("NEON:HISTORY");
\ No newline at end of file
diff --git a/entity/LogHistory_entity/imageProcess.js b/entity/LogHistory_entity/imageProcess.js
new file mode 100644
index 00000000000..1206221d6b2
--- /dev/null
+++ b/entity/LogHistory_entity/imageProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.getString("$field.ICON"));
\ No newline at end of file
diff --git a/entity/LogHistory_entity/recordcontainers/db/conditionProcess.js b/entity/LogHistory_entity/recordcontainers/db/conditionProcess.js
index ce43c94ef6e..64d80196aba 100644
--- a/entity/LogHistory_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/LogHistory_entity/recordcontainers/db/conditionProcess.js
@@ -1,10 +1,7 @@
 import("system.vars");
-import("system.db");
 import("system.result");
-import("Sql_lib");
 
-var cond = SqlCondition.begin().andPrepareVars("TABLENAMEID", "$param.tablenameId_param").andPrepareVars("TABLENAME", "$param.Tablename_param")
-    .orSqlCondition(SqlCondition.begin().andPrepareVars("TABLENAMEID", "$param.contactId_param")
-        .andSqlCondition(SqlCondition.begin().orPrepare("TABLENAME", "CONTACT").orPrepare("TABLENAME", "COMMUNICATION")
-        .orPepare("TABLENAME", "ADDRESS").orPrepare("TABLENAME", "AB_ATTRIBUTERELATION")));
-result.string(db.translateCondition(cond.build("1 = 1"))); 
+var sql = "(TABLENAMEID = '" + vars.get("$param.tablenameId_param") + "' and TABLENAME = '" + vars.get("$param.tablename_param") + "') "
+    + "or (TABLENAMEID = '" + vars.get("$param.contactId_param") + "' "
+    + "and (TABLENAME='CONTACT' or TABLENAME='COMMUNICATION' or TABLENAME='ADDRESS' or TABLENAME='AB_ATTRIBUTERELATION'))";
+result.string(sql);
\ No newline at end of file
diff --git a/entity/LogHistory_entity/recordcontainers/db/fromClauseProcess.js b/entity/LogHistory_entity/recordcontainers/db/fromClauseProcess.js
deleted file mode 100644
index 71013597007..00000000000
--- a/entity/LogHistory_entity/recordcontainers/db/fromClauseProcess.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import("system.result");
-
-result.string("AB_LOGHISTORY");
\ No newline at end of file
diff --git a/others/db_changes/data_alias/basic/init/init.xml b/others/db_changes/data_alias/basic/init/init.xml
index c4653839c7b..815fe63a943 100644
--- a/others/db_changes/data_alias/basic/init/init.xml
+++ b/others/db_changes/data_alias/basic/init/init.xml
@@ -9,7 +9,8 @@
     <include relativeToChangelogFile="true" file="struct/AditoBasic/create_ab_keyword_attributerelation.xml"/>
     <include relativeToChangelogFile="true" file="struct/AditoBasic/create_ab_countryinfo.xml"/>
     <include relativeToChangelogFile="true" file="struct/AditoBasic/create_ab_language.xml"/>
-    
+    <include relativeToChangelogFile="true" file="struct/AditoBasic/create_ab_loghistory.xml"/>
+</databaseChangeLog>
     <include relativeToChangelogFile="true" file="struct/create_person.xml"/>
     <include relativeToChangelogFile="true" file="struct/create_organisation.xml"/>
     <include relativeToChangelogFile="true" file="struct/create_contact.xml"/>    
diff --git a/process/indexsearch_patternextension/indexsearch_patternextension.aod b/process/indexsearch_patternextension/indexsearch_patternextension.aod
index 21e2ac8d88f..88ec85ec6e5 100644
--- a/process/indexsearch_patternextension/indexsearch_patternextension.aod
+++ b/process/indexsearch_patternextension/indexsearch_patternextension.aod
@@ -2,4 +2,5 @@
 <process 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/process/1.2.0">
   <name>indexsearch_patternextension</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <process>%aditoprj%/process/indexsearch_patternextension/process.js</process>
 </process>
diff --git a/process/indexsearch_patternextension/process.js b/process/indexsearch_patternextension/process.js
new file mode 100644
index 00000000000..e69de29bb2d
-- 
GitLab