From c76ba7239c873604b96639556bfe96312a350ee7 Mon Sep 17 00:00:00 2001
From: Johannes Hoermann <j.hoermann@adito.de>
Date: Mon, 13 May 2019 11:33:14 +0200
Subject: [PATCH] Classification refactorings / fixes

---
 .../delete_salesprocejctClassification.xml    |   6 +
 .../insert_classification_scores.xml          |   2 +-
 .../insert_classification_types.xml           |  11 ++
 .../Data_alias/basic/2019.2/changelog.xml     |   1 +
 aliasDefinition/Data_alias/Data_alias.aod     | 117 ------------------
 .../ClassificationAdmin_entity.aod            |  17 +++
 .../containername_param/valueProcess.js       |   4 +
 .../entityfields/uid/displayValueProcess.js   |   6 +
 .../ClassificationScore_entity.aod            |   3 +
 .../recordcontainers/db/onDBDelete.js         |   7 ++
 .../Classification_entity.aod                 |   3 +
 .../isadminmode_param/valueProcess.js         |   3 +-
 .../entityfields/edit/onActionProcess.js      |   3 +-
 .../isadminmode_param/valueProcess.js         |   1 +
 .../entityfields/scoretype/onValidation.js    |  25 ++++
 .../entityfields/scoretype/stateProcess.js    |  12 ++
 .../recordcontainers/jdito/onDelete.js        |  26 ++++
 .../recordcontainers/jdito/onUpdate.js        |   5 +-
 .../KeywordEntry_entity.aod                   |   6 +
 .../classificationresult/valueProcess.js      |   3 +-
 .../classificationtype_param/valueProcess.js  |   3 +-
 .../recordcontainers/db/onDBDelete.js         |   5 +-
 .../_____LANGUAGE_EXTRA.aod                   |  39 ++++++
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     |  14 ++-
 .../_____LANGUAGE_en/_____LANGUAGE_en.aod     |  10 ++
 process/KeywordRegistry_basic/process.js      |   4 +-
 26 files changed, 208 insertions(+), 128 deletions(-)
 create mode 100644 .liquibase/Data_alias/basic/2019.2/Classification/delete_salesprocejctClassification.xml
 create mode 100644 entity/ClassificationAdmin_entity/entityfields/keywordclassificationtypes/children/containername_param/valueProcess.js
 create mode 100644 entity/ClassificationAdmin_entity/entityfields/uid/displayValueProcess.js
 create mode 100644 entity/ClassificationScore_entity/recordcontainers/db/onDBDelete.js
 create mode 100644 entity/Classification_entity/entityfields/scoretype/onValidation.js
 create mode 100644 entity/Classification_entity/entityfields/scoretype/stateProcess.js
 create mode 100644 entity/Classification_entity/recordcontainers/jdito/onDelete.js

diff --git a/.liquibase/Data_alias/basic/2019.2/Classification/delete_salesprocejctClassification.xml b/.liquibase/Data_alias/basic/2019.2/Classification/delete_salesprocejctClassification.xml
new file mode 100644
index 00000000000..7172aed0131
--- /dev/null
+++ b/.liquibase/Data_alias/basic/2019.2/Classification/delete_salesprocejctClassification.xml
@@ -0,0 +1,6 @@
+<?xml version="1.1" encoding="UTF-8" standalone="no"?>
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
+    <changeSet author="j.hoermann" id="85efe5d3-8032-4277-9177-3daa11951bb0">
+        <dropTable tableName="SALESPROJECT_CLASSIFICATION"/>
+    </changeSet>
+</databaseChangeLog>
\ No newline at end of file
diff --git a/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_scores.xml b/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_scores.xml
index c540fee5688..c3fa2cdbcd1 100644
--- a/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_scores.xml
+++ b/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_scores.xml
@@ -94,7 +94,7 @@
     <insert tableName="CLASSIFICATIONSCORE">
       <column name="CLASSIFICATIONSCOREID" value="3c9ceefa-5c98-4629-9c6d-d46b6cad8b78"/>
       <column name="SCORETYPE" value="ScoreUsers"/>
-      <column name="TITLE" value="251 to 1000"/>
+      <column name="TITLE" value="251 to 1,000"/>
       <column name="SCORE" valueNumeric="30.00"/>
       <column name="SORT" valueNumeric="20"/>
     </insert>
diff --git a/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_types.xml b/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_types.xml
index 04269b04e63..9b41f5b635a 100644
--- a/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_types.xml
+++ b/.liquibase/Data_alias/basic/2019.2/Classification/insert_classification_types.xml
@@ -1,5 +1,16 @@
 <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
   <changeSet author="j.hoermann" id="f904e9fd-d5e1-4f9b-b334-5621132449ce">
+      
+    <insert tableName="AB_KEYWORD_ENTRY">
+        <column name="AB_KEYWORD_ENTRYID" value="789667fe-519f-4dea-b691-62c14447d694"/>
+        <column name="KEYID" value="968eafa3-3e76-4afa-8999-878e51cc3bab"/>
+        <column name="TITLE" value="Salesproject"/>
+        <column name="CONTAINER" value="ClassificationType"/>
+        <column name="SORTING" valueNumeric="1"/>
+        <column name="ISACTIVE" valueNumeric="1"/>
+        <column name="ISESSENTIAL" valueNumeric="1"/>
+    </insert>
+      
     <insert tableName="CLASSIFICATIONTYPE">
       <column name="CLASSIFICATIONTYPEID" value="54128957-c80b-4b5a-ad1b-cfce665dfb10"/>
       <column name="CLASSIFICATIONTYPE" value="968eafa3-3e76-4afa-8999-878e51cc3bab"/>
diff --git a/.liquibase/Data_alias/basic/2019.2/changelog.xml b/.liquibase/Data_alias/basic/2019.2/changelog.xml
index c667163ec91..afd617ba0b4 100644
--- a/.liquibase/Data_alias/basic/2019.2/changelog.xml
+++ b/.liquibase/Data_alias/basic/2019.2/changelog.xml
@@ -167,6 +167,7 @@
     <include relativeToChangelogFile="true" file="Classification/create_classification_tables.xml"/>
     <include relativeToChangelogFile="true" file="Classification/insert_classification_scores.xml"/>
     <include relativeToChangelogFile="true" file="Classification/insert_classification_types.xml"/>
+    <include relativeToChangelogFile="true" file="Classification/delete_salesprocejctClassification.xml"/>
 
     <include relativeToChangelogFile="true" file="AditoBasic/extendKeywordOrganisationType.xml"/>
     <include relativeToChangelogFile="true" file="AditoBasic/removeAttributeKeywordTargetGroup.xml"/>
diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod
index 8de09d704e7..60a0e9ce0c4 100644
--- a/aliasDefinition/Data_alias/Data_alias.aod
+++ b/aliasDefinition/Data_alias/Data_alias.aod
@@ -4315,123 +4315,6 @@
               </entityFieldDb>
             </entityFields>
           </entityDb>
-          <entityDb>
-            <name>SALESPROJECT_CLASSIFICATION</name>
-            <dbName></dbName>
-            <idColumn>SALESPROJECT_CLASSIFICATIONID</idColumn>
-            <idGeneratorType v="0" />
-            <idGeneratorInterval v="1" />
-            <title></title>
-            <description></description>
-            <auditSyncConfig>
-              <name>auditSyncConfig</name>
-              <auditMode v="1" />
-              <syncActive v="false" />
-              <syncComplete v="true" />
-              <syncDirection v="1" />
-              <syncIds></syncIds>
-            </auditSyncConfig>
-            <entityFields>
-              <entityFieldDb>
-                <name>SALESPROJECT_CLASSIFICATIONID</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>Salesproject classification Id</title>
-                <description></description>
-              </entityFieldDb>
-              <entityFieldDb>
-                <name>CLASS</name>
-                <dbName></dbName>
-                <primaryKey v="false" />
-                <columnType v="4" />
-                <size v="10" />
-                <scale v="0" />
-                <notNull v="false" />
-                <isUnique v="false" />
-                <index v="false" />
-                <documentation></documentation>
-                <title>Class</title>
-                <description></description>
-                <customProperties>
-                  <customBooleanProperty>
-                    <name>log</name>
-                    <global v="false" />
-                    <property v="true" />
-                  </customBooleanProperty>
-                </customProperties>
-              </entityFieldDb>
-              <entityFieldDb>
-                <name>VALUE</name>
-                <dbName></dbName>
-                <primaryKey v="false" />
-                <columnType v="4" />
-                <size v="10" />
-                <scale v="0" />
-                <notNull v="false" />
-                <isUnique v="false" />
-                <index v="false" />
-                <documentation></documentation>
-                <title>Value</title>
-                <description></description>
-                <customProperties>
-                  <customBooleanProperty>
-                    <name>log</name>
-                    <global v="false" />
-                    <property v="true" />
-                  </customBooleanProperty>
-                </customProperties>
-              </entityFieldDb>
-              <entityFieldDb>
-                <name>SALESPROJECT_ID</name>
-                <dbName></dbName>
-                <primaryKey v="false" />
-                <columnType v="1" />
-                <size v="36" />
-                <scale v="0" />
-                <notNull v="true" />
-                <isUnique v="false" />
-                <index v="false" />
-                <documentation></documentation>
-                <title>Salesproject Id</title>
-                <description></description>
-                <customProperties>
-                  <customBooleanProperty>
-                    <name>log</name>
-                    <global v="false" />
-                    <property v="true" />
-                  </customBooleanProperty>
-                </customProperties>
-              </entityFieldDb>
-              <entityFieldDb>
-                <name>TYPE</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>Type</title>
-                <description></description>
-                <customProperties>
-                  <customBooleanProperty>
-                    <name>log</name>
-                    <global v="false" />
-                    <property v="true" />
-                  </customBooleanProperty>
-                </customProperties>
-              </entityFieldDb>
-            </entityFields>
-          </entityDb>
           <entityDb>
             <name>TIMETRACKING</name>
             <dbName></dbName>
diff --git a/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod b/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod
index c5b3232e4f3..6979575e6bb 100644
--- a/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod
+++ b/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod
@@ -11,6 +11,8 @@
     </entityProvider>
     <entityField>
       <name>UID</name>
+      <consumer>KeywordClassificationTypes</consumer>
+      <displayValueProcess>%aditoprj%/entity/ClassificationAdmin_entity/entityfields/uid/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityConsumer>
       <name>ClassificationsAdmin</name>
@@ -27,6 +29,21 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityConsumer>
+      <name>KeywordClassificationTypes</name>
+      <fieldType>DEPENDENCY_OUT</fieldType>
+      <dependency>
+        <name>dependency</name>
+        <entityName>KeywordEntry_entity</entityName>
+        <fieldName>SpecificContainerKeywords</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>ContainerName_param</name>
+          <valueProcess>%aditoprj%/entity/ClassificationAdmin_entity/entityfields/keywordclassificationtypes/children/containername_param/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <jDitoRecordContainer>
diff --git a/entity/ClassificationAdmin_entity/entityfields/keywordclassificationtypes/children/containername_param/valueProcess.js b/entity/ClassificationAdmin_entity/entityfields/keywordclassificationtypes/children/containername_param/valueProcess.js
new file mode 100644
index 00000000000..b5e82ac3839
--- /dev/null
+++ b/entity/ClassificationAdmin_entity/entityfields/keywordclassificationtypes/children/containername_param/valueProcess.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("KeywordRegistry_basic")
+
+result.string($KeywordRegistry.classificationType())
\ No newline at end of file
diff --git a/entity/ClassificationAdmin_entity/entityfields/uid/displayValueProcess.js b/entity/ClassificationAdmin_entity/entityfields/uid/displayValueProcess.js
new file mode 100644
index 00000000000..b92bfbc2e35
--- /dev/null
+++ b/entity/ClassificationAdmin_entity/entityfields/uid/displayValueProcess.js
@@ -0,0 +1,6 @@
+import("system.result");
+import("system.vars");
+import("Keyword_lib");
+import("KeywordRegistry_basic");
+
+result.string(KeywordUtils.getViewValue($KeywordRegistry.classificationType(), vars.get("$this.value")))
\ No newline at end of file
diff --git a/entity/ClassificationScore_entity/ClassificationScore_entity.aod b/entity/ClassificationScore_entity/ClassificationScore_entity.aod
index 33a68efe1c6..9fbd869a9be 100644
--- a/entity/ClassificationScore_entity/ClassificationScore_entity.aod
+++ b/entity/ClassificationScore_entity/ClassificationScore_entity.aod
@@ -31,6 +31,8 @@
     <entityField>
       <name>SCORE</name>
       <title>Score</title>
+      <contentType>NUMBER</contentType>
+      <outputFormat>#,##0.00</outputFormat>
       <mandatory v="true" />
       <onValidation>%aditoprj%/entity/ClassificationScore_entity/entityfields/score/onValidation.js</onValidation>
     </entityField>
@@ -69,6 +71,7 @@
       <alias>Data_alias</alias>
       <conditionProcess>%aditoprj%/entity/ClassificationScore_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
       <orderClauseProcess>%aditoprj%/entity/ClassificationScore_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
+      <onDBDelete>%aditoprj%/entity/ClassificationScore_entity/recordcontainers/db/onDBDelete.js</onDBDelete>
       <linkInformation>
         <linkInformation>
           <name>e2fecaf8-bc95-4a4d-bd96-88731568b1a4</name>
diff --git a/entity/ClassificationScore_entity/recordcontainers/db/onDBDelete.js b/entity/ClassificationScore_entity/recordcontainers/db/onDBDelete.js
new file mode 100644
index 00000000000..41b093f08de
--- /dev/null
+++ b/entity/ClassificationScore_entity/recordcontainers/db/onDBDelete.js
@@ -0,0 +1,7 @@
+import("system.vars");
+import("system.db");
+import("Sql_lib");
+
+db.deleteData("CLASSIFICATION", SqlCondition.begin()
+                                   .andPrepare("CLASSIFICATION.CLASSIFICATIONSCORE_ID", vars.get("$field.CLASSIFICATIONSCOREID"))
+                                   .build("1=2"));
\ No newline at end of file
diff --git a/entity/Classification_entity/Classification_entity.aod b/entity/Classification_entity/Classification_entity.aod
index 410357d231e..f7bcb256a8e 100644
--- a/entity/Classification_entity/Classification_entity.aod
+++ b/entity/Classification_entity/Classification_entity.aod
@@ -70,7 +70,9 @@
       <name>SCORETYPE</name>
       <title>Scoretype</title>
       <groupable v="true" />
+      <stateProcess>%aditoprj%/entity/Classification_entity/entityfields/scoretype/stateProcess.js</stateProcess>
       <displayValueProcess>%aditoprj%/entity/Classification_entity/entityfields/scoretype/displayValueProcess.js</displayValueProcess>
+      <onValidation>%aditoprj%/entity/Classification_entity/entityfields/scoretype/onValidation.js</onValidation>
     </entityField>
     <entityField>
       <name>CLASSIFICATIONNUMBER</name>
@@ -175,6 +177,7 @@
       <contentProcess>%aditoprj%/entity/Classification_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
       <onInsert>%aditoprj%/entity/Classification_entity/recordcontainers/jdito/onInsert.js</onInsert>
       <onUpdate>%aditoprj%/entity/Classification_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
+      <onDelete>%aditoprj%/entity/Classification_entity/recordcontainers/jdito/onDelete.js</onDelete>
       <recordFields>
         <element>UID.value</element>
         <element>CLASSIFICATIONID.value</element>
diff --git a/entity/Classification_entity/entityfields/classifications/children/isadminmode_param/valueProcess.js b/entity/Classification_entity/entityfields/classifications/children/isadminmode_param/valueProcess.js
index 4e869dc96de..9358b57687a 100644
--- a/entity/Classification_entity/entityfields/classifications/children/isadminmode_param/valueProcess.js
+++ b/entity/Classification_entity/entityfields/classifications/children/isadminmode_param/valueProcess.js
@@ -1,4 +1,3 @@
-import("system.logging");
 import("system.result");
-logging.log("asdf")
+
 result.string(0);
\ No newline at end of file
diff --git a/entity/Classification_entity/entityfields/edit/onActionProcess.js b/entity/Classification_entity/entityfields/edit/onActionProcess.js
index eac189a4480..e600e52ac0c 100644
--- a/entity/Classification_entity/entityfields/edit/onActionProcess.js
+++ b/entity/Classification_entity/entityfields/edit/onActionProcess.js
@@ -11,7 +11,8 @@ if (selection.length > 0)
     var params = {
         "ClassificationType_param" : vars.get("$param.ClassificationType_param"),
         "ObjectType_param" : vars.get("$param.ObjectType_param"),
-        "ObjectRowid_param" : vars.get("$param.ObjectRowid_param")
+        "ObjectRowid_param" : vars.get("$param.ObjectRowid_param"),
+        "IsAdminMode_param" : vars.get("$param.IsAdminMode_param")
     }
     
     var view = "ClassificatonEdit_view";
diff --git a/entity/Classification_entity/entityfields/isadminmode_param/valueProcess.js b/entity/Classification_entity/entityfields/isadminmode_param/valueProcess.js
index 0488a23572b..55b34600836 100644
--- a/entity/Classification_entity/entityfields/isadminmode_param/valueProcess.js
+++ b/entity/Classification_entity/entityfields/isadminmode_param/valueProcess.js
@@ -1,3 +1,4 @@
+import("system.vars");
 import("system.result");
 
 result.string(1);
\ No newline at end of file
diff --git a/entity/Classification_entity/entityfields/scoretype/onValidation.js b/entity/Classification_entity/entityfields/scoretype/onValidation.js
new file mode 100644
index 00000000000..eb1b25be34a
--- /dev/null
+++ b/entity/Classification_entity/entityfields/scoretype/onValidation.js
@@ -0,0 +1,25 @@
+import("system.neon");
+import("system.translate");
+import("system.logging");
+import("system.result");
+import("system.db");
+import("Entity_lib");
+import("Sql_lib");
+import("system.vars");
+
+logging.log(vars.get("$param.IsAdminMode_param"))
+if (vars.get("$param.IsAdminMode_param") == "1" && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+{
+    // do not allow the same name a second time
+    var type = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.SCORETYPE"));
+    var count = db.cell(SqlCondition.begin()
+                        .andPrepare("CLASSIFICATIONTYPE.SCORETYPE", type)
+                        .buildSql("select count(*) from CLASSIFICATIONTYPE"));
+
+    logging.log("lol " + type)
+
+    if (count != 0)
+    {
+        result.string(translate.text("${SCORETYPE_ALREADY_EXISTS}"));
+    }
+}
\ No newline at end of file
diff --git a/entity/Classification_entity/entityfields/scoretype/stateProcess.js b/entity/Classification_entity/entityfields/scoretype/stateProcess.js
new file mode 100644
index 00000000000..626da788b03
--- /dev/null
+++ b/entity/Classification_entity/entityfields/scoretype/stateProcess.js
@@ -0,0 +1,12 @@
+import("system.neon");
+import("system.result");
+import("system.vars");
+
+if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
+{
+    result.string(neon.COMPONENTSTATE_AUTO);
+}
+else
+{
+    result.string(neon.COMPONENTSTATE_DISABLED);
+}
\ No newline at end of file
diff --git a/entity/Classification_entity/recordcontainers/jdito/onDelete.js b/entity/Classification_entity/recordcontainers/jdito/onDelete.js
new file mode 100644
index 00000000000..5e02ce7e27b
--- /dev/null
+++ b/entity/Classification_entity/recordcontainers/jdito/onDelete.js
@@ -0,0 +1,26 @@
+import("system.neon");
+import("system.question");
+import("Sql_lib");
+import("system.db");
+import("system.util");
+import("system.vars");
+
+var type = vars.get("$field.SCORETYPE");
+
+if (1 < db.cell(SqlCondition.begin()
+                        .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", vars.get("$field.CLASSIFICATIONTYPE"))
+                        .buildSql("select count(*) from CLASSIFICATIONTYPE", "1=2")))
+{
+    db.deleteData("CLASSIFICATION", "CLASSIFICATION.CLASSIFICATIONTYPE_ID in (" + db.translateStatement(
+                       SqlCondition.begin()
+                                   .andPrepare("CLASSIFICATIONTYPE.SCORETYPE", type)
+                                   .buildSql("select CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID from CLASSIFICATIONTYPE", "1=2")) + ")");
+    db.deleteData("CLASSIFICATIONTYPE", SqlCondition.equals("CLASSIFICATIONTYPE.SCORETYPE", type, "1=2"));
+    db.deleteData("CLASSIFICATIONSCORE", SqlCondition.equals("CLASSIFICATIONSCORE.SCORETYPE", type, "1=2"));
+}
+neon.refreshAll();
+//else
+//{
+    // do not delete anything, because it is the last one. If this one is deleted, there would be no way to add anything again.
+    // TODO: delete-button disable if count(*) <= 1
+//}
diff --git a/entity/Classification_entity/recordcontainers/jdito/onUpdate.js b/entity/Classification_entity/recordcontainers/jdito/onUpdate.js
index d856750d58b..060a72d4ee0 100644
--- a/entity/Classification_entity/recordcontainers/jdito/onUpdate.js
+++ b/entity/Classification_entity/recordcontainers/jdito/onUpdate.js
@@ -1,10 +1,13 @@
+import("system.logging");
 import("system.neon");
 import("system.util");
 import("Sql_lib");
 import("system.db");
 import("system.vars");
 
-// check if it already exists
+var changed = vars.get("$local.changed");
+
+// check if it already exists. Else it only exists as ScoreType but has no Classification-Entry
 if (vars.get("$field.CLASSIFICATIONID"))
 {
     if (vars.get("$field.CLASSIFICATIONSCORE_ID"))
diff --git a/entity/KeywordEntry_entity/KeywordEntry_entity.aod b/entity/KeywordEntry_entity/KeywordEntry_entity.aod
index 69b7a2f12da..e52b848c0ec 100644
--- a/entity/KeywordEntry_entity/KeywordEntry_entity.aod
+++ b/entity/KeywordEntry_entity/KeywordEntry_entity.aod
@@ -386,6 +386,12 @@
           <fieldName>KeywordCampaignManagementCostCategory</fieldName>
           <isConsumer v="false" />
         </entityDependency>
+        <entityDependency>
+          <name>63bd7284-e9a0-4576-afe8-299d412e8def</name>
+          <entityName>ClassificationAdmin_entity</entityName>
+          <fieldName>KeywordClassificationTypes</fieldName>
+          <isConsumer v="false" />
+        </entityDependency>
       </dependencies>
       <children>
         <entityParameter>
diff --git a/entity/Salesproject_entity/entityfields/classificationresult/valueProcess.js b/entity/Salesproject_entity/entityfields/classificationresult/valueProcess.js
index d120e5bb6d7..aa00d635b63 100644
--- a/entity/Salesproject_entity/entityfields/classificationresult/valueProcess.js
+++ b/entity/Salesproject_entity/entityfields/classificationresult/valueProcess.js
@@ -1,6 +1,7 @@
+import("KeywordRegistry_basic");
 import("system.vars");
 import("system.result");
 import("Classification_lib")
 import("Context_lib")
 
-result.string(ClassificationUtils.getClass("968eafa3-3e76-4afa-8999-878e51cc3bab", ContextUtils.getCurrentContextId(), vars.get("$sys.uid")));
\ No newline at end of file
+result.string(ClassificationUtils.getClass($KeywordRegistry.classificationType$salesproject(), ContextUtils.getCurrentContextId(), vars.get("$sys.uid")));
\ No newline at end of file
diff --git a/entity/Salesproject_entity/entityfields/classifications/children/classificationtype_param/valueProcess.js b/entity/Salesproject_entity/entityfields/classifications/children/classificationtype_param/valueProcess.js
index 0f664a34918..7915763a4b4 100644
--- a/entity/Salesproject_entity/entityfields/classifications/children/classificationtype_param/valueProcess.js
+++ b/entity/Salesproject_entity/entityfields/classifications/children/classificationtype_param/valueProcess.js
@@ -1,3 +1,4 @@
+import("KeywordRegistry_basic");
 import("system.result");
 
-result.string("968eafa3-3e76-4afa-8999-878e51cc3bab");
\ No newline at end of file
+result.string($KeywordRegistry.classificationType$salesproject());
\ No newline at end of file
diff --git a/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js b/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js
index 65d94ab76da..63f1823605f 100644
--- a/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js
+++ b/entity/Salesproject_entity/recordcontainers/db/onDBDelete.js
@@ -1,6 +1,7 @@
 import("system.db");
 import("system.vars");
 import("Sql_lib");
+import("Context_lib");
 
 var currentId = vars.getString("$field.SALESPROJECTID");
 
@@ -8,7 +9,6 @@ if (currentId)
 {
     var toDelete = [
         "SALESPROJECT_COMPETITION",
-        "SALESPROJECT_CLASSIFICATION",
         "SALESPROJECT_MILESTONE",
         "SALESPROJECT_FORECAST",
         "SALESPROJECT_MEMBER",
@@ -20,6 +20,9 @@ if (currentId)
         return [pTable, SqlCondition.equals(pTable + ".SALESPROJECT_ID", currentId, "1=2")]
     });
     
+    toDelete.push(["CLASSIFICATION", sqlCondition.begin()
+                                                 .andPrepare("CLASSIFICATION.OBJECT_TYPE", ContextUtils.getCurrentContextId())
+                                                 .andPrepare("CLASSIFICATION.OBJECT_ROWID", currentId).build("1=2")])
     db.deletes(toDelete);
     
     // TODO: auch Dokumente, Aktivitäten, Aufgaben, Zeiterfassungen löschen?
diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
index 25a34db25a8..c8a231619ff 100644
--- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
+++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
@@ -3810,6 +3810,45 @@
     <entry>
       <key>Possible values</key>
     </entry>
+    <entry>
+      <key>e</key>
+    </entry>
+    <entry>
+      <key>ARCHIVE</key>
+    </entry>
+    <entry>
+      <key>huhu</key>
+    </entry>
+    <entry>
+      <key>archieve</key>
+    </entry>
+    <entry>
+      <key>setUnread</key>
+    </entry>
+    <entry>
+      <key>Rating</key>
+    </entry>
+    <entry>
+      <key>sum</key>
+    </entry>
+    <entry>
+      <key>A: 75 &lt; </key>
+    </entry>
+    <entry>
+      <key>setRead</key>
+    </entry>
+    <entry>
+      <key>Possible Values</key>
+    </entry>
+    <entry>
+      <key>a</key>
+    </entry>
+    <entry>
+      <key>${SCORETYPE_ALREADY_EXISTS}</key>
+    </entry>
+    <entry>
+      <key>251 to 1,000</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
   <sqlModels>
diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
index 51533a49d4c..3f05b947c82 100644
--- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
+++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
@@ -4587,8 +4587,8 @@
       <value>Leiter IT</value>
     </entry>
     <entry>
-      <key>251 to 1000</key>
-      <value>251 bis 1000</value>
+      <key>251 to 1,000</key>
+      <value>251 bis 1.000</value>
     </entry>
     <entry>
       <key>Electric</key>
@@ -4792,6 +4792,16 @@
     <entry>
       <key>Possible Values</key>
     </entry>
+    <entry>
+      <key>a</key>
+    </entry>
+    <entry>
+      <key>${SCORETYPE_ALREADY_EXISTS}</key>
+      <value>Der eingegebene Bewertungstyp existiert bereits in irgend einer Klassifizierung.</value>
+    </entry>
+    <entry>
+      <key>251 to 1000</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
 </language>
diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
index a43bb221838..9a8ec100003 100644
--- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
+++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
@@ -3888,6 +3888,16 @@
     <entry>
       <key>Possible Values</key>
     </entry>
+    <entry>
+      <key>a</key>
+    </entry>
+    <entry>
+      <key>${SCORETYPE_ALREADY_EXISTS}</key>
+      <value>The given Scoretype already exists in any Classification.</value>
+    </entry>
+    <entry>
+      <key>251 to 1,000</key>
+    </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
 </language>
diff --git a/process/KeywordRegistry_basic/process.js b/process/KeywordRegistry_basic/process.js
index 4acc0874e2b..3a7a6a8f8ce 100644
--- a/process/KeywordRegistry_basic/process.js
+++ b/process/KeywordRegistry_basic/process.js
@@ -94,4 +94,6 @@ $KeywordRegistry.campaignStepCostCategory = function(){return "CampaignManagemen
 $KeywordRegistry.documentTemplateType = function(){return "DocumentTemplateType";};
 $KeywordRegistry.documentTemplateTypeCategory = function(){return "DocumentTemplateTypeCategory";};
 $KeywordRegistry.documentTemplateType$mail = function(){return "MAI                                 ";};
-$KeywordRegistry.documentTemplateType$attachment = function(){return "ATT                                 ";};
\ No newline at end of file
+$KeywordRegistry.documentTemplateType$attachment = function(){return "ATT                                 ";};
+$KeywordRegistry.classificationType = function(){return "ClassificationType";};
+$KeywordRegistry.classificationType$salesproject = function(){return "968eafa3-3e76-4afa-8999-878e51cc3bab";};
\ No newline at end of file
-- 
GitLab