From 16cc7008e4a4cf3cabbfd74034dc7e6225c71446 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Thu, 29 Nov 2018 13:13:11 +0100
Subject: [PATCH] salesproject: Classifications

---
 ...SalesprojectClassificationEntry_entity.aod |  19 +++
 .../contentProcess.js                         | 124 +++++++++++++-----
 .../titleProcess.js                           |   4 +
 .../value/possibleItemsProcess.js             |  10 ++
 .../onUpdate.js                               |  28 ++++
 .../titleProcess.js                           |   4 +
 .../SalesprojectClassification_entity.aod     |   2 +
 .../contentProcess.js                         |  17 ++-
 .../children/classid_param/code.js            |   2 -
 .../children/salesprojectid_param/code.js     |   3 -
 .../onUpdate.js                               |   5 +-
 .../conditionProcess.js                       |   2 -
 .../entityfields/type/possibleItemsProcess.js |   2 -
 .../value/possibleItemsProcess.js             |   2 -
 .../phase/possibleItemsProcess.js             |   5 +-
 entity/Salesproject_entity/onDBUpdate.js      |   1 -
 ...alesprojectClassificationEntry_context.aod |   7 +
 ...lesprojectClassificationEntryEdit_view.aod |  26 ++++
 ...projectClassificationEntryPreview_view.aod |  15 ++-
 ...SalesprojectClassificationPreview_view.aod |  20 ++-
 .../example_salesproject/SALESPROJECT_gfk.xml |  21 ++-
 process/Keyword_lib/process.js                |  50 ++++++-
 process/Sql_lib/process.js                    |  29 +++-
 23 files changed, 326 insertions(+), 72 deletions(-)
 create mode 100644 entity/SalesprojectClassificationEntry_entity/entityfields/salesprojectclassificatonentry_dfi/titleProcess.js
 create mode 100644 entity/SalesprojectClassificationEntry_entity/entityfields/value/possibleItemsProcess.js
 create mode 100644 entity/SalesprojectClassificationEntry_entity/onUpdate.js
 create mode 100644 entity/SalesprojectClassificationEntry_entity/titleProcess.js
 create mode 100644 neonView/SalesprojectClassificationEntryEdit_view/SalesprojectClassificationEntryEdit_view.aod

diff --git a/entity/SalesprojectClassificationEntry_entity/SalesprojectClassificationEntry_entity.aod b/entity/SalesprojectClassificationEntry_entity/SalesprojectClassificationEntry_entity.aod
index a83e9138311..9219e338c0e 100644
--- a/entity/SalesprojectClassificationEntry_entity/SalesprojectClassificationEntry_entity.aod
+++ b/entity/SalesprojectClassificationEntry_entity/SalesprojectClassificationEntry_entity.aod
@@ -2,14 +2,19 @@
 <entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.5" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.0.5">
   <name>SalesprojectClassificationEntry_entity</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <grantCreate v="false" />
+  <grantDelete v="false" />
   <recordContainerType>JDITO</recordContainerType>
+  <titleProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/titleProcess.js</titleProcess>
   <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
   <fields>
     <element>UID</element>
+    <element>TYPE</element>
     <element>NAME</element>
     <element>VALUE</element>
   </fields>
   <contentProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/contentProcess.js</contentProcess>
+  <onUpdate>%aditoprj%/entity/SalesprojectClassificationEntry_entity/onUpdate.js</onUpdate>
   <entityFields>
     <entityIncomingField>
       <name>#INCOMING</name>
@@ -17,6 +22,8 @@
     <entityIncomingField>
       <name>SalesprojectClassificatonEntry_dfi</name>
       <fieldType>DEPENDENCY_IN</fieldType>
+      <title>kkkkkkkkkkkkkkk</title>
+      <titleProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/entityfields/salesprojectclassificatonentry_dfi/titleProcess.js</titleProcess>
       <dependencies>
         <entityDependency>
           <name>a7414022-56d3-4ca0-b15f-33601b655d78</name>
@@ -30,25 +37,37 @@
       <name>SalesprojectId_param</name>
       <expose v="true" />
       <triggerRecalculation v="true" />
+      <mandatory v="true" />
       <description>PARAMETER</description>
     </entityParameter>
     <entityParameter>
       <name>ClassId_param</name>
       <expose v="true" />
       <triggerRecalculation v="true" />
+      <mandatory v="true" />
       <description>PARAMETER</description>
     </entityParameter>
     <entityField>
       <name>UID</name>
+      <title>Uid</title>
       <fieldName>UID</fieldName>
     </entityField>
     <entityField>
       <name>NAME</name>
+      <title>Name</title>
       <fieldName>NAME</fieldName>
     </entityField>
     <entityField>
       <name>VALUE</name>
+      <title>Value</title>
       <fieldName>VALUE</fieldName>
+      <possibleItemsProcess>%aditoprj%/entity/SalesprojectClassificationEntry_entity/entityfields/value/possibleItemsProcess.js</possibleItemsProcess>
+    </entityField>
+    <entityField>
+      <name>TYPE</name>
+      <title>Type</title>
+      <fieldName>TYPE</fieldName>
+      <state>INVISIBLE</state>
     </entityField>
   </entityFields>
 </entity>
diff --git a/entity/SalesprojectClassificationEntry_entity/contentProcess.js b/entity/SalesprojectClassificationEntry_entity/contentProcess.js
index 1d2439cfe7f..c66d2c551d7 100644
--- a/entity/SalesprojectClassificationEntry_entity/contentProcess.js
+++ b/entity/SalesprojectClassificationEntry_entity/contentProcess.js
@@ -4,49 +4,103 @@ import("system.db");
 import("Keyword_lib");
 import("Sql_lib");
 
-var allOldTypesCondition, allOldTypes, typesCondition, classId, salesprojectId, entryKeywords;
-    
+
+var allOldTypesCondition, allOldTypes, classificationsCondition, classifications, classId, salesprojectId, entryKeywords;
+
+classifications = [];
+
 if (vars.exists("$param.ClassId_param") && vars.exists("$param.SalesprojectId_param")) {
     classId = vars.getString("$param.ClassId_param");
     salesprojectId = vars.getString("$param.SalesprojectId_param");
-    entryKeywords = KeywordUtils.get("SALESPROJECT.CLASS", classId)[2].keywords;
-
-    if (entryKeywords && classId && salesprojectId) {
-        // correct db if kewords changed
-        allOldTypesCondition = new SqlCondition();
-        allOldTypesCondition.andPrepare("SALESPROJECT_CLASSIFICATION.SALESPROJECT_ID", salesprojectId)
-            .andPrepare("SALESPROJECT_CLASSIFICATION.CLASS", classId);
-
-        entryKeywords.forEach(function(entry) { 
-            allOldTypesCondition.andPrepare("SALESPROJECT_CLASSIFICATION.TYPE", entry, "# <> ?")
-        });
-        
-        allOldTypes = db.array(db.COLUMN, allOldTypesCondition.buildSelect("select TYPE from SALESPROJECT_CLASSIFICATION", "1 = 0", "group by TYPE"));
-        
-        if (allOldTypes.length > 0) {
-            // TODO maybe ask user????!!!!!
-            db.deleteData("SALESPROJECT_CLASSIFICATION", allOldTypesCondition.build("1 = 0"))
-        }
-        
-        //typesCondition = 
-        /*
-    <column name="CLASS" type="CHAR(1)"/>
-                <column name="TYPE" type="VARCHAR(50)"/>
-                <column name="VALUE" type="INTEGER"/>*/
-    }
+    
+    if (classId && salesprojectId) {    
+    
 
-/*
-    entries = [];
-    entryKeywords.forEach(function(entryKeyword) {
-        entry = kwUtils.getStandardArray(entryKeyword)
-        entries.push([entry[0], entry[1]])
-    });*/
+        entryKeywords = KeywordUtils.get("SALESPROJECT.CLASS", classId)[2].keywords;
 
-}
+        if (entryKeywords && classId && salesprojectId) {
+            // correct db if kewords changed
+            allOldTypesCondition = _getClassificationCondition(false);
+            allOldTypes = db.array(db.COLUMN, allOldTypesCondition.buildSelect("select TYPE from SALESPROJECT_CLASSIFICATION", "1 = 0", "group by TYPE"));
 
+            if (allOldTypes.length > 0) {
+                // TODO maybe ask user????!!!!!
+                db.deleteData("SALESPROJECT_CLASSIFICATION", allOldTypesCondition.build("1 = 0"))
+            }
 
+            // load classifications for the class
+            classificationsCondition = _getClassificationCondition(true);
+            classifications = db.table(classificationsCondition.buildSelect("select SALESPROJECT_CLASSIFICATIONID, TYPE, VALUE from SALESPROJECT_CLASSIFICATION", "1 = 0"));        
 
+            logging.log(entryKeywords.toSource())
+            classifications = entryKeywords.map(function(entryKeyword) {
+                for (i = 0; i < classifications.length; i++) {
+                    if (classifications[i][1] == entryKeyword[0]) {
+                        return [classifications[i][0], entryKeyword[0], entryKeyword[1], classifications[i][2]]
+                    }
+                }
+                
+                // if not found create new:
+                var values = [
+                                util.getNewUUID(),
+                                salesprojectId,
+                                classId,
+                                entryKeyword[0],
+                                "1",
+                                vars.get("$sys.user"),
+                                vars.get("$sys.date")
+                            ];
+                
+                db.insertData(
+                    "SALESPROJECT_CLASSIFICATION",
+                    [
+                        "SALESPROJECT_CLASSIFICATIONID",
+                        "SALESPROJECT_ID",
+                        "CLASS",
+                        "TYPE",
+                        "VALUE",
+                        "USER_NEW",
+                        "DATE_NEW"
+                    ],
+                    null,
+                    values
+                );
+                
+                return [values[0], values[3], values[3] , values[4]]
+            });
+/*
+            classifications = classifications.map(function(entry) {
+                let entryKeyword = KeywordUtils.get(entry[1], entry[2]);
+                return [entry[0], entry[1], entryKeyword[1] , entry[2]]
+            });
+*/
+        }
+    }
+}
+logging.log(classifications.toSource())
+result.object(classifications);
 
+/**
+ * creates a SqlCondition() to get the classification items
+ * 
+ * @param include if true the condition includes all types of the class else it excludes them and selects all other types
+ * @return the condition object
+ */
+function _getClassificationCondition(include) {
+    var resultingCondition = new SqlCondition();
+    resultingCondition.andPrepare("SALESPROJECT_CLASSIFICATION.SALESPROJECT_ID", salesprojectId)
+        .andPrepare("SALESPROJECT_CLASSIFICATION.CLASS", classId);
 
+    var typeCondition = new SqlCondition();
 
-result.object([]);
\ No newline at end of file
+    entryKeywords.forEach(function(entry) {
+        if (include) {
+            typeCondition.orPrepare("SALESPROJECT_CLASSIFICATION.TYPE", entry[0], "# = ?");
+        } else {
+            typeCondition.andPrepare("SALESPROJECT_CLASSIFICATION.TYPE", entry[0], "# <> ?");
+        }
+    });
+    
+    resultingCondition.andSqlCondition(typeCondition, "1 = 0");
+    return resultingCondition;
+}
\ No newline at end of file
diff --git a/entity/SalesprojectClassificationEntry_entity/entityfields/salesprojectclassificatonentry_dfi/titleProcess.js b/entity/SalesprojectClassificationEntry_entity/entityfields/salesprojectclassificatonentry_dfi/titleProcess.js
new file mode 100644
index 00000000000..15ccfbd4538
--- /dev/null
+++ b/entity/SalesprojectClassificationEntry_entity/entityfields/salesprojectclassificatonentry_dfi/titleProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.NAME") + "123")
\ No newline at end of file
diff --git a/entity/SalesprojectClassificationEntry_entity/entityfields/value/possibleItemsProcess.js b/entity/SalesprojectClassificationEntry_entity/entityfields/value/possibleItemsProcess.js
new file mode 100644
index 00000000000..3ac05121761
--- /dev/null
+++ b/entity/SalesprojectClassificationEntry_entity/entityfields/value/possibleItemsProcess.js
@@ -0,0 +1,10 @@
+import("system.result");
+import("system.logging");
+import("system.vars");
+import("Keyword_lib");
+
+logging.log(vars.get("$field.TYPE"))
+var type = vars.get("$field.TYPE");
+if (type) {
+    result.object(KeywordUtils.getStandardArray(type));
+}
\ No newline at end of file
diff --git a/entity/SalesprojectClassificationEntry_entity/onUpdate.js b/entity/SalesprojectClassificationEntry_entity/onUpdate.js
new file mode 100644
index 00000000000..18be8137a5a
--- /dev/null
+++ b/entity/SalesprojectClassificationEntry_entity/onUpdate.js
@@ -0,0 +1,28 @@
+import("system.db");
+import("system.vars");
+import("system.logging");
+import("Sql_lib");
+
+logging.log(vars.get("$local.changed").toSource())
+
+
+var condition = new SqlCondition();
+condition.andPrepare("SALESPROJECT_CLASSIFICATION.SALESPROJECT_CLASSIFICATIONID", vars.getString("$field.UID"));
+        
+var values = [
+    vars.getString("$field.VALUE"),
+    vars.get("$sys.user"),
+    vars.get("$sys.date")
+];
+
+db.updateData(
+    "SALESPROJECT_CLASSIFICATION",
+    [
+        "VALUE",
+        "USER_EDIT",
+        "DATE_EDIT"
+    ],
+    null,
+    values,
+    condition.build("1 = 0")
+);
\ No newline at end of file
diff --git a/entity/SalesprojectClassificationEntry_entity/titleProcess.js b/entity/SalesprojectClassificationEntry_entity/titleProcess.js
new file mode 100644
index 00000000000..dffd0bd73b9
--- /dev/null
+++ b/entity/SalesprojectClassificationEntry_entity/titleProcess.js
@@ -0,0 +1,4 @@
+import("system.vars");
+import("system.result");
+
+result.string(vars.get("$field.NAME"))
\ No newline at end of file
diff --git a/entity/SalesprojectClassification_entity/SalesprojectClassification_entity.aod b/entity/SalesprojectClassification_entity/SalesprojectClassification_entity.aod
index abb49eb621d..b501f4cebb8 100644
--- a/entity/SalesprojectClassification_entity/SalesprojectClassification_entity.aod
+++ b/entity/SalesprojectClassification_entity/SalesprojectClassification_entity.aod
@@ -31,10 +31,12 @@
         <entityParameter>
           <name>ClassId_param</name>
           <code>%aditoprj%/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/classid_param/code.js</code>
+          <triggerRecalculation v="true" />
         </entityParameter>
         <entityParameter>
           <name>SalesprojectId_param</name>
           <code>%aditoprj%/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/salesprojectid_param/code.js</code>
+          <triggerRecalculation v="true" />
         </entityParameter>
       </children>
     </entityOutgoingField>
diff --git a/entity/SalesprojectClassification_entity/contentProcess.js b/entity/SalesprojectClassification_entity/contentProcess.js
index bea2285dbb0..ac02906b902 100644
--- a/entity/SalesprojectClassification_entity/contentProcess.js
+++ b/entity/SalesprojectClassification_entity/contentProcess.js
@@ -1,7 +1,20 @@
 import("system.result");
 import("system.logging");
+import("system.vars");
 import("Keyword_lib");
 
-result.object(KeywordUtils.getStandardArray("SALESPROJECT.CLASS"));
+var keyword = KeywordUtils.createKeyword("SALESPROJECT.CLASS");
 
-//TODO correct db if kewords changed
\ No newline at end of file
+if (vars.exists("$local.idvalues")) {
+    var idValues = vars.get("$local.idvalues");
+    
+    if (idValues.length > 0) {
+        keyword.filter(function(id) {
+            return id == idValues[0];
+        });
+    }
+}
+result.object(keyword.toArray(["id", "name"]));
+
+
+//TODO correct db if kewords changed
diff --git a/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/classid_param/code.js b/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/classid_param/code.js
index 6df5509e9bf..a5632992f1e 100644
--- a/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/classid_param/code.js
+++ b/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/classid_param/code.js
@@ -1,6 +1,4 @@
 import("system.result");
 import("system.vars");
-import("system.logging");
 
-logging.log("Parameter 1 gesetzt")
 result.string(vars.getString("$field.UID"));
\ No newline at end of file
diff --git a/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/salesprojectid_param/code.js b/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/salesprojectid_param/code.js
index 81e77557b8c..098d87cfa55 100644
--- a/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/salesprojectid_param/code.js
+++ b/entity/SalesprojectClassification_entity/entityfields/salesprojectclassificationentry_dfo/children/salesprojectid_param/code.js
@@ -1,7 +1,4 @@
 import("system.result");
 import("system.vars");
-import("system.logging");
-
-logging.log("Parameter 2 gesetzt")
 
 result.string(vars.getString("$param.SalesprojectId_param"));
\ No newline at end of file
diff --git a/entity/SalesprojectClassification_entity/onUpdate.js b/entity/SalesprojectClassification_entity/onUpdate.js
index 784a7e00752..c0b643664fa 100644
--- a/entity/SalesprojectClassification_entity/onUpdate.js
+++ b/entity/SalesprojectClassification_entity/onUpdate.js
@@ -1 +1,4 @@
-//f
\ No newline at end of file
+import("system.vars")
+import("system.logging")
+
+logging.log(vars.get("$local.changed").toSource())
\ No newline at end of file
diff --git a/entity/SalesprojectCycle_entity/conditionProcess.js b/entity/SalesprojectCycle_entity/conditionProcess.js
index 4048fcb70b0..be87512e0c9 100644
--- a/entity/SalesprojectCycle_entity/conditionProcess.js
+++ b/entity/SalesprojectCycle_entity/conditionProcess.js
@@ -1,11 +1,9 @@
 import("system.db");
 import("system.result");
 import("system.vars");
-import("system.logging");
 import("Sql_lib");
 
 var cond = new SqlCondition();
-logging.log(vars.get("$param.SalesprojectId_param"))
 cond.andPrepareVars("SALESPROJECT_CYCLE.SALESPROJECT_ID", "$param.SalesprojectId_param");
 
 //TODO: use a preparedCondition when available
diff --git a/entity/SalesprojectCycle_entity/entityfields/type/possibleItemsProcess.js b/entity/SalesprojectCycle_entity/entityfields/type/possibleItemsProcess.js
index ca7ec2ba261..e6aa09f4992 100644
--- a/entity/SalesprojectCycle_entity/entityfields/type/possibleItemsProcess.js
+++ b/entity/SalesprojectCycle_entity/entityfields/type/possibleItemsProcess.js
@@ -1,8 +1,6 @@
 import("system.result");
 import("system.vars");
-import("system.logging");
 import("Keyword_lib");
 
 var items = KeywordUtils.getStandardArray("SALESPROJECT.CYCLE.TYPE");
-logging.log(items.toSource())
 result.object(items);
\ No newline at end of file
diff --git a/entity/SalesprojectCycle_entity/entityfields/value/possibleItemsProcess.js b/entity/SalesprojectCycle_entity/entityfields/value/possibleItemsProcess.js
index a3310ce62f2..43fe214e331 100644
--- a/entity/SalesprojectCycle_entity/entityfields/value/possibleItemsProcess.js
+++ b/entity/SalesprojectCycle_entity/entityfields/value/possibleItemsProcess.js
@@ -1,6 +1,5 @@
 import("system.result");
 import("system.vars");
-import("system.logging");
 import("Keyword_lib");
 
 var items, keyword, type;
@@ -8,7 +7,6 @@ var items, keyword, type;
 items = [];
 
 type = vars.getString("$field.TYPE");
-logging.log(type.toSource())
 
 // load the possible values based on the type.
 if (type) {
diff --git a/entity/Salesproject_entity/entityfields/phase/possibleItemsProcess.js b/entity/Salesproject_entity/entityfields/phase/possibleItemsProcess.js
index 74024580c2b..fcb07176fb9 100644
--- a/entity/Salesproject_entity/entityfields/phase/possibleItemsProcess.js
+++ b/entity/Salesproject_entity/entityfields/phase/possibleItemsProcess.js
@@ -1,7 +1,4 @@
 import("system.result");
 import("Keyword_lib");
 
-var items;
-
-items = KeywordUtils.getStandardArray("SALESPROJECT.PHASE");
-result.object(items);
\ No newline at end of file
+result.object(KeywordUtils.getStandardArray("SALESPROJECT.PHASE"));
\ No newline at end of file
diff --git a/entity/Salesproject_entity/onDBUpdate.js b/entity/Salesproject_entity/onDBUpdate.js
index 927e80d477d..aeffbb32c2e 100644
--- a/entity/Salesproject_entity/onDBUpdate.js
+++ b/entity/Salesproject_entity/onDBUpdate.js
@@ -1,5 +1,4 @@
 import("system.vars");
-import("system.logging");
 import("Salesproject_lib");
 
 var typeValue, fieldVar
diff --git a/neonContext/SalesprojectClassificationEntry_context/SalesprojectClassificationEntry_context.aod b/neonContext/SalesprojectClassificationEntry_context/SalesprojectClassificationEntry_context.aod
index e8adc3fa030..513be574430 100644
--- a/neonContext/SalesprojectClassificationEntry_context/SalesprojectClassificationEntry_context.aod
+++ b/neonContext/SalesprojectClassificationEntry_context/SalesprojectClassificationEntry_context.aod
@@ -2,6 +2,9 @@
 <neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.0.0">
   <name>SalesprojectClassificationEntry_context</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <mainview>SalesprojectClassificationEntryPreview_view</mainview>
+  <filterview>SalesprojectClassificationEntryPreview_view</filterview>
+  <editview>SalesprojectClassificationEntryEdit_view</editview>
   <preview>SalesprojectClassificationEntryPreview_view</preview>
   <entity>SalesprojectClassificationEntry_entity</entity>
   <references>
@@ -9,5 +12,9 @@
       <name>7cddda68-3dcb-4daf-84a4-1546298cabb6</name>
       <view>SalesprojectClassificationEntryPreview_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>80205380-7785-43a3-af7b-73ef8112ca38</name>
+      <view>SalesprojectClassificationEntryEdit_view</view>
+    </neonViewReference>
   </references>
 </neonContext>
diff --git a/neonView/SalesprojectClassificationEntryEdit_view/SalesprojectClassificationEntryEdit_view.aod b/neonView/SalesprojectClassificationEntryEdit_view/SalesprojectClassificationEntryEdit_view.aod
new file mode 100644
index 00000000000..a5016e5a1e3
--- /dev/null
+++ b/neonView/SalesprojectClassificationEntryEdit_view/SalesprojectClassificationEntryEdit_view.aod
@@ -0,0 +1,26 @@
+<?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.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0">
+  <name>SalesprojectClassificationEntryEdit_view</name>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <genericViewTemplate>
+      <name>SalesprojectClassificationEntryData_template</name>
+      <entityField>#ENTITY</entityField>
+      <fields>
+        <entityFieldLink>
+          <name>003f3304-b8fb-4009-ba55-b56d005191e3</name>
+          <entityField>NAME</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>90630f8e-8e32-4743-9b79-a1faa6e26414</name>
+          <entityField>VALUE</entityField>
+        </entityFieldLink>
+      </fields>
+    </genericViewTemplate>
+  </children>
+</neonView>
diff --git a/neonView/SalesprojectClassificationEntryPreview_view/SalesprojectClassificationEntryPreview_view.aod b/neonView/SalesprojectClassificationEntryPreview_view/SalesprojectClassificationEntryPreview_view.aod
index 0c6e070dfb8..5504cee35e6 100644
--- a/neonView/SalesprojectClassificationEntryPreview_view/SalesprojectClassificationEntryPreview_view.aod
+++ b/neonView/SalesprojectClassificationEntryPreview_view/SalesprojectClassificationEntryPreview_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.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0">
   <name>SalesprojectClassificationEntryPreview_view</name>
+  <title>asdf</title>
   <majorModelMode>DISTRIBUTED</majorModelMode>
   <layout>
     <boxLayout>
@@ -8,23 +9,23 @@
     </boxLayout>
   </layout>
   <children>
-    <tableViewTemplate>
+    <titledListViewTemplate>
       <name>SalesprojectClassificationEntryData_template</name>
       <entityField>#ENTITY</entityField>
       <columns>
         <neonTableColumn>
-          <name>2de7d794-3c72-42a1-ab5b-1eaf7608b0f3</name>
-          <entityField>UID</entityField>
+          <name>91aa4685-98f7-40e9-87be-877583a91143</name>
+          <entityField>NAME</entityField>
         </neonTableColumn>
         <neonTableColumn>
-          <name>e4ae9891-2db2-427e-9f28-0d07ad4dcc4c</name>
-          <entityField>NAME</entityField>
+          <name>88105c9a-fdf8-4d2b-ac96-d57ef4f41aa4</name>
+          <entityField>TYPE</entityField>
         </neonTableColumn>
         <neonTableColumn>
-          <name>7a61d1ed-3359-4c74-b598-f09b69cc6f75</name>
+          <name>b862235e-6595-4ae0-8bd0-5f942d975c67</name>
           <entityField>VALUE</entityField>
         </neonTableColumn>
       </columns>
-    </tableViewTemplate>
+    </titledListViewTemplate>
   </children>
 </neonView>
diff --git a/neonView/SalesprojectClassificationPreview_view/SalesprojectClassificationPreview_view.aod b/neonView/SalesprojectClassificationPreview_view/SalesprojectClassificationPreview_view.aod
index 05147ac8652..558507fb7b9 100644
--- a/neonView/SalesprojectClassificationPreview_view/SalesprojectClassificationPreview_view.aod
+++ b/neonView/SalesprojectClassificationPreview_view/SalesprojectClassificationPreview_view.aod
@@ -8,8 +8,26 @@
     </boxLayout>
   </layout>
   <children>
+    <genericViewTemplate>
+      <name>rfff</name>
+      <entityField>#ENTITY</entityField>
+      <fields>
+        <entityFieldLink>
+          <name>51712a19-9a8c-4967-bd15-a448b5bffb77</name>
+          <entityField>CLASSNAME</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>48312725-e22d-4c13-ab92-7be9f7d477e7</name>
+          <entityField>UID</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>5f9a5d73-67e1-4dcd-b31d-70fe908fb74d</name>
+          <entityField>SalesprojectId_param</entityField>
+        </entityFieldLink>
+      </fields>
+    </genericViewTemplate>
     <neonViewReference>
-      <name>ee9b0c38-f2f9-4e5e-9ab8-2c4658ffca83</name>
+      <name>c6c26fdd-3812-495f-bd30-d3a6cdcd4eb0</name>
       <entityField>SalesprojectClassificationEntry_dfo</entityField>
       <view>SalesprojectClassificationEntryPreview_view</view>
     </neonViewReference>
diff --git a/others/db_changes/data/example_salesproject/SALESPROJECT_gfk.xml b/others/db_changes/data/example_salesproject/SALESPROJECT_gfk.xml
index db97bcf7d48..49d73913e79 100644
--- a/others/db_changes/data/example_salesproject/SALESPROJECT_gfk.xml
+++ b/others/db_changes/data/example_salesproject/SALESPROJECT_gfk.xml
@@ -57,7 +57,7 @@
     </insert>
 
     <insert tableName="SALESPROJECT_COMPETITION">
-        <column name="SALESPROJECT_COMPETITIONID" value="SALESPROJECT_COMPETITIONID"/>
+        <column name="SALESPROJECT_COMPETITIONID" value="a3ae9702-a3da-4d5f-a3ab-e386c8a0ac40"/>
         <column name="USER_NEW" value="admin"/>
         <column name="DATE_NEW" valueDate="2018-06-13T09:03:43"/>
         <column name="SALESPROJECT_ID" value="0833465c-8851-4fbb-b7e3-8c1d73c903da"/>
@@ -69,7 +69,7 @@
     </insert>
     
     <insert tableName="SALESPROJECT_MEMBER">
-        <column name="SALESPROJECT_MEMBERID" value="SALESPROJECT_MEMBERID"/>
+        <column name="SALESPROJECT_MEMBERID" value="f9dc15c0-91b8-43d3-ba98-80ca581db3a3"/>
         <column name="USER_NEW" value="admin"/>
         <column name="DATE_NEW" valueDate="2018-06-13T09:03:43"/>
         <column name="SALESPROJECT_ID" value="0833465c-8851-4fbb-b7e3-8c1d73c903da"/>
@@ -77,6 +77,17 @@
         <column name="SALESPROJECT_ROLE" valueNumeric="1"/>
     </insert>
     
+    <insert tableName="SALESPROJECT_CLASSIFICATION">
+        <column name="SALESPROJECT_CLASSIFICATIONID" value="77da9dcb-b49a-4608-9c7d-68545b0ec29b"/>
+        <column name="USER_NEW" value="admin"/>
+        <column name="DATE_NEW" valueDate="2018-06-13T09:03:43"/>
+        <column name="SALESPROJECT_ID" value="0833465c-8851-4fbb-b7e3-8c1d73c903da"/>
+        
+        <column name="CLASS" valueNumeric="1"/>
+        <column name="TYPE" value="CLASS.BRANCHE"/>
+        <column name="VALUE" valueNumeric="2"/>
+    </insert>
+    
     <rollback>			
         <delete tableName="SALESPROJECT">
             <where>SALESPROJECTID = ?</where>
@@ -114,6 +125,12 @@
                     <param value="0833465c-8851-4fbb-b7e3-8c1d73c903da" />
             </whereParams>
         </delete>
+        <delete tableName="SALESPROJECT_CLASSIFICATION">
+            <where>SALESPROJECT_ID = ?</where>
+            <whereParams>
+                    <param value="0833465c-8851-4fbb-b7e3-8c1d73c903da" />
+            </whereParams>
+        </delete>
     </rollback>
 </changeSet>
 </databaseChangeLog>
diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js
index ca80a4a47d7..a74aaf463dd 100644
--- a/process/Keyword_lib/process.js
+++ b/process/Keyword_lib/process.js
@@ -287,16 +287,54 @@ function KeywordUtils(){
                 break;
             case "SALESPROJECT.CLASS":
                 valueContainer = _createKeywordEntriesContainer([
-                     _createKeywordEntry("1", translate.text("Class A"), null, {keywords: ["CLASS.BRANCHE", "CLASS.BASED", "CLASS.USERS"]})
-                    ,_createKeywordEntry("2", translate.text("Class B"), null, {keywords: ["CLASS.BUDGET", "CLASS.STANDARD", "CLASS.CUSTOMIZING"]})
-                    ,_createKeywordEntry("3", translate.text("Class C"), null, {keywords: ["CLASS.POSITION", "CLASS.PROJSTART", "CLASS.CLOUD", "CLASSES.DEPARTMENT"]})
+                     _createKeywordEntry("1", translate.text("Class A"), null, {
+                         keywords: 
+                            [["CLASS.BRANCHE", translate.text("Branche")],
+                             ["CLASS.BASED", translate.text("Base")]]
+                    })
+                    ,_createKeywordEntry("2", translate.text("Class B"), null, {
+                         keywords: 
+                            [["CLASS.BUDGET", translate.text("Budget (Project)")],
+                             ["CLASS.STANDARD", translate.text("Standard / Individual")]]
+                     })
+                    ,_createKeywordEntry("3", translate.text("Class C"), null, {
+                         keywords: 
+                            [["CLASS.PROJSTART", translate.text("Projectstart")]]
+                     })
                 ]);
                 break;
             case "CLASS.BRANCHE":
                 valueContainer = _createKeywordEntriesContainer([
-                     _createKeywordEntry("1", translate.text("Branche 1"), null)
-                    ,_createKeywordEntry("2", translate.text("Branche 2"), null)
-                    ,_createKeywordEntry("3", translate.text("Branche 3"), null)
+                     _createKeywordEntry("1", translate.text("Branche 1"), null, {value: 50})
+                    ,_createKeywordEntry("2", translate.text("Branche 2"), null, {value: 16.6})
+                    ,_createKeywordEntry("3", translate.text("Branche 3"), null, {value: 50})
+                ]);
+                break;
+            case "CLASS.BASED":
+                valueContainer = _createKeywordEntriesContainer([
+                     _createKeywordEntry("1", translate.text("Germany"), null, {value: 20})
+                    ,_createKeywordEntry("2", translate.text("Austria"), null, {value: 7.5})
+                    ,_createKeywordEntry("3", translate.text("Other"), null, {value: 0})
+                ]);
+                break;
+            case "CLASS.BUDGET":
+                valueContainer = _createKeywordEntriesContainer([
+                     _createKeywordEntry("1", translate.text("from") + "350T€", null, {value: 50})
+                    ,_createKeywordEntry("2", "200" + translate.text("to") + "349T€", null, {value: 30})
+                    ,_createKeywordEntry("2", "0" + translate.text("to") + "3199T€", null, {value: 0})
+                ]);
+                break;
+            case "CLASS.STANDARD":
+                valueContainer = _createKeywordEntriesContainer([
+                     _createKeywordEntry("1", translate.text("Individual"), null, {value: 25})
+                    ,_createKeywordEntry("2", translate.text("Standard"), null, {value: 12.5})
+                ]);
+                break;
+            case "CLASS.PROJSTART":
+                valueContainer = _createKeywordEntriesContainer([
+                     _createKeywordEntry("1", translate.text("in 6 Months"), null, {value: 30})
+                    ,_createKeywordEntry("2", translate.text("in 12 Months"), null, {value: 20})
+                    ,_createKeywordEntry("3", translate.text("no Project planned"), null, {value: 0})
                 ]);
                 break;
             case "OFFER.PROBABILITY":
diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js
index c58c9ba1b75..a69021b68b8 100644
--- a/process/Sql_lib/process.js
+++ b/process/Sql_lib/process.js
@@ -22,6 +22,7 @@ function SqlCondition(alias){
     this._init();//the properties are initalized in an extra function because init is nearly the same as resetting (clearing) the SqlConditions
     this.alias = alias;
     this.cachedTypes = {};
+    this.lastWasOr = false;
 }
 /**
  * append with SQL-and; no paranthesize of existing conditions is done
@@ -64,10 +65,34 @@ SqlCondition.prototype.andPrepare = function(field, value, cond, fieldType){
 SqlCondition.prototype.or = function(cond){
     if (!cond)
         return this;
-    if (this._sqlStorage)
+    
+    if (this._sqlStorage && !this.lastWasOr) {
         this._sqlStorage = "(" + this._sqlStorage + ") or (" + cond + ")";
-    else
+        this.lastWasOr = true;
+        
+    } else if (this._sqlStorage && this.lastWasOr) {
+        this._sqlStorage = this._sqlStorage + " or (" + cond + ")";
+        this.lastWasOr = true;
+        
+    } else {
         this._sqlStorage = cond;
+    }
+    return this;
+}
+
+SqlCondition.prototype.orSqlCondition = function(cond, alternativeCond) {
+    this.or(" ( " + cond.toString(alternativeCond) + " ) ");
+    if (cond.preparedValues) {
+        this.preparedValues = this.preparedValues.concat(cond.preparedValues);
+    }
+    return this;
+}
+
+SqlCondition.prototype.andSqlCondition = function(cond, alternativeCond) {
+    this.and(" ( " + cond.toString(alternativeCond) + " ) ");
+    if (cond.preparedValues) {
+        this.preparedValues = this.preparedValues.concat(cond.preparedValues);
+    }
     return this;
 }
 
-- 
GitLab