From 89406e860c77f7ab0faf2dd88edf021b65592480 Mon Sep 17 00:00:00 2001
From: "j.goderbauer" <j.goderbauer@adito.de>
Date: Wed, 9 Sep 2020 08:45:49 +0200
Subject: [PATCH] several ScanServices

---
 entity/Countries_Entity/Countries_Entity.aod  |  2 ++
 .../entityfields/iso2name/documentation.adoc  |  4 +++
 .../ImportField_Entity/ImportField_Entity.aod |  1 +
 .../leadimportids/documentation.adoc          |  1 +
 process/Sql_lib/process.js                    | 25 +++++++++++++++----
 5 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 entity/Countries_Entity/entityfields/iso2name/documentation.adoc
 create mode 100644 entity/ImportField_Entity/entityfields/leadimportids/documentation.adoc

diff --git a/entity/Countries_Entity/Countries_Entity.aod b/entity/Countries_Entity/Countries_Entity.aod
index 9b431268c5..9a4408cb03 100644
--- a/entity/Countries_Entity/Countries_Entity.aod
+++ b/entity/Countries_Entity/Countries_Entity.aod
@@ -14,6 +14,8 @@
     </entityProvider>
     <entityProvider>
       <name>ISO2Name</name>
+      <lookupIdfield>ISO2</lookupIdfield>
+      <documentation>%aditoprj%/entity/Countries_Entity/entityfields/iso2name/documentation.adoc</documentation>
       <dependencies>
         <entityDependency>
           <name>83e8a2e6-aa80-4b35-a0ad-8dad483ed428</name>
diff --git a/entity/Countries_Entity/entityfields/iso2name/documentation.adoc b/entity/Countries_Entity/entityfields/iso2name/documentation.adoc
new file mode 100644
index 0000000000..4e2b19d84b
--- /dev/null
+++ b/entity/Countries_Entity/entityfields/iso2name/documentation.adoc
@@ -0,0 +1,4 @@
+Provides a list of countries, where the UID is the countires two character ISO-code
+ISO 3166-1 alpha-2; see: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
+
+For example: `IT` for Italy, `DE` for Germany, `NO` for Norway, etc.
\ No newline at end of file
diff --git a/entity/ImportField_Entity/ImportField_Entity.aod b/entity/ImportField_Entity/ImportField_Entity.aod
index c3c160e699..cb5bb3fb64 100644
--- a/entity/ImportField_Entity/ImportField_Entity.aod
+++ b/entity/ImportField_Entity/ImportField_Entity.aod
@@ -55,6 +55,7 @@
     </entityConsumer>
     <entityProvider>
       <name>LeadImportIds</name>
+      <documentation>%aditoprj%/entity/ImportField_Entity/entityfields/leadimportids/documentation.adoc</documentation>
       <titlePlural>Import Fields</titlePlural>
       <dependencies>
         <entityDependency>
diff --git a/entity/ImportField_Entity/entityfields/leadimportids/documentation.adoc b/entity/ImportField_Entity/entityfields/leadimportids/documentation.adoc
new file mode 100644
index 0000000000..c3e81f687c
--- /dev/null
+++ b/entity/ImportField_Entity/entityfields/leadimportids/documentation.adoc
@@ -0,0 +1 @@
+Provides configured ImportFields for one specific lead import.
\ No newline at end of file
diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index 3600f01d4a..247df44a33 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -3969,13 +3969,28 @@ SqlUtils.getResolvingCaseWhen = function(pKeyValueArray, pDbFieldName, pLocale)
 };
 
 /**
-* resolves key-value pairs (of strings) into a case when expression
+* resolves an array of key-value pairs (of strings) into a sql case when expression<br/>
+* This is useful for results of entities.getRows for example.
 * 
-* @param {String[][]} pKeyValueArray you've to pass a 2D-Array where each element has at pos0 the key and pos1 the value
-* @param {String} pDbFieldName name fo the database field where the KEY-value is stored
-* @param {String} [pLocale=current client language] specifies the locale for translating the title; can be false if nothing shalle be translated
+* @param {Array} pKeyValueObject    <p/>you've to pass a 2D-Array where each element has to be an object with at least one key: value-pair, e.g.: 
+*                                   <br/>[{uid: "uid1", value: "value1"}, {uid: "uidN", value: "valueN"}]
+* @param {String} pUid              <p/>name of the key where the rawvalue (the uid) is located in the object
+* @param {String} pTranslatedValue  <p/>name of the key where the already translated value is located in the object
+* @param {String} pDbFieldName      <p/>name fo the database field where the KEY-value is stored
 * 
-* @return {String} a SQL-expression (case-when-statement) that resolves the KEYID into the title -> as preparedSatement-elements
+* @return {String}                  <p/>a SQL-expression (case-when-statement) that resolves the KEYID into the title -> as 
+*                                       preparedSatement-elements
+*                                   <br/>The else-value is "unassigned".
+* 
+* @example
+* var exampleDataStack = [
+*       {keyVal: "PHONE", titleOriginal: "Phone", titleTranslated: "Telefon", origin: "MetaImporter"},
+*       {keyVal: "EMAIL", titleOriginal: "email", titleTranslated: "E-Mail", origin: "MetaImporter"}
+* ];
+* 
+* var sqlExpr = SqlUtils.getResolvingCaseWhenFromObject(exampleDataStack, "keyVal", "titleTranslated", "FORM.COMMUNICATION");
+* //results in a sql case when as prepared statement that is resolvedas following: 
+* //case  when FORM.COMMUNICATION = 'PHONE'  then 'Telefon'   when FORM.COMMUNICATION = 'EMAIL'  then 'E-Mail'   else 'nicht zugeordnet' end
 */
 SqlUtils.getResolvingCaseWhenFromObject = function(pKeyValueObject, pUid, pTranslatedValue, pDbFieldName) 
 {
-- 
GitLab