From 6819666ea9cc441b43759c9af5211fe5a6088c27 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Fri, 24 May 2019 15:40:55 +0200 Subject: [PATCH] Classification fixes --- .../ClassificationScore_entity.aod | 14 ++++++++++++++ .../classificationtype_id/valueProcess.js | 4 ++++ .../entityfields/maxvalue/valueProcess.js | 11 +++++++++++ .../recordcontainers/db/onDBInsert.js | 2 ++ .../Classification_entity.aod | 19 ++++++------------- .../classificationgroup/dropDownProcess.js | 3 --- .../classificationgroup/mandatoryProcess.js | 2 +- .../classificationtype_param/valueProcess.js | 4 ++++ .../classificationtype_id/valueProcess.js | 2 +- .../classificationtypeid/valueProcess.js | 3 ++- .../entityfields/edit/onActionProcess.js | 2 -- .../recordcontainers/jdito/contentProcess.js | 1 - .../recordcontainers/jdito/onInsert.js | 3 +-- .../recordcontainers/jdito/onUpdate.js | 3 +-- 14 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 entity/ClassificationScore_entity/recordcontainers/db/onDBInsert.js create mode 100644 entity/Classification_entity/entityfields/classificationscores/children/classificationtype_param/valueProcess.js diff --git a/entity/ClassificationScore_entity/ClassificationScore_entity.aod b/entity/ClassificationScore_entity/ClassificationScore_entity.aod index 3bd2db1f82..748971c333 100644 --- a/entity/ClassificationScore_entity/ClassificationScore_entity.aod +++ b/entity/ClassificationScore_entity/ClassificationScore_entity.aod @@ -54,11 +54,19 @@ <name>ClassificationGroup_param</name> <expose v="true" /> <triggerRecalculation v="true" /> + <mandatory v="true" /> </entityParameter> <entityParameter> <name>ClassificationTypeId_param</name> <expose v="true" /> <triggerRecalculation v="true" /> + <mandatory v="true" /> + </entityParameter> + <entityParameter> + <name>ClassificationType_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="true" /> </entityParameter> </children> </entityProvider> @@ -78,6 +86,11 @@ <triggerRecalculation v="true" /> <description>PARAMETER</description> </entityParameter> + <entityParameter> + <name>ClassificationType_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> @@ -85,6 +98,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> + <onDBInsert>%aditoprj%/entity/ClassificationScore_entity/recordcontainers/db/onDBInsert.js</onDBInsert> <onDBDelete>%aditoprj%/entity/ClassificationScore_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> diff --git a/entity/ClassificationScore_entity/entityfields/classificationtype_id/valueProcess.js b/entity/ClassificationScore_entity/entityfields/classificationtype_id/valueProcess.js index 419fe78a30..750e480506 100644 --- a/entity/ClassificationScore_entity/entityfields/classificationtype_id/valueProcess.js +++ b/entity/ClassificationScore_entity/entityfields/classificationtype_id/valueProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.result"); import("system.neon"); import("system.vars"); @@ -5,4 +6,7 @@ import("system.vars"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { result.string(vars.get("$param.ClassificationTypeId_param")); + logging.log("group: " + vars.get("$param.ClassificationGroup_param")) + logging.log("typeid: " + vars.get("$param.ClassificationTypeId_param")) + logging.log("pype: " + vars.get("$param.ClassificationType_param")) } \ No newline at end of file diff --git a/entity/ClassificationScore_entity/entityfields/maxvalue/valueProcess.js b/entity/ClassificationScore_entity/entityfields/maxvalue/valueProcess.js index f8c6c86bc4..a368d02dab 100644 --- a/entity/ClassificationScore_entity/entityfields/maxvalue/valueProcess.js +++ b/entity/ClassificationScore_entity/entityfields/maxvalue/valueProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.vars"); import("system.result"); import("system.db"); @@ -10,10 +11,20 @@ if (!vars.get("$this.value")) SqlCondition.begin() .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", classificationTypeId, "# <> ?") .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", vars.get("$param.ClassificationGroup_param")) + .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", vars.get("$param.ClassificationType_param")) .buildSql("select 100.0 - sum(maxScore) from ( \n\ select max(SCORE) maxScore from CLASSIFICATIONTYPE \n\ join CLASSIFICATIONSCORE on CLASSIFICATIONSCORE.CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", "1=2", "group by CLASSIFICATIONTYPE.SCORETYPE) maxScores")); + logging.log(db.translateStatement(SqlCondition.begin() + .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", classificationTypeId, "# <> ?") + .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", vars.get("$param.ClassificationGroup_param")) + .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", vars.get("$param.ClassificationType_param")) + .buildSql("select 100.0 - sum(maxScore) from ( \n\ + select max(SCORE) maxScore from CLASSIFICATIONTYPE \n\ + join CLASSIFICATIONSCORE on CLASSIFICATIONSCORE.CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", "1=2", "group by CLASSIFICATIONTYPE.SCORETYPE) maxScores"))) + logging.log(maxValue) + if (maxValue == "") maxValue = 100; diff --git a/entity/ClassificationScore_entity/recordcontainers/db/onDBInsert.js b/entity/ClassificationScore_entity/recordcontainers/db/onDBInsert.js new file mode 100644 index 0000000000..b0b4d112ac --- /dev/null +++ b/entity/ClassificationScore_entity/recordcontainers/db/onDBInsert.js @@ -0,0 +1,2 @@ +import("system.logging"); +logging.log("huii") \ No newline at end of file diff --git a/entity/Classification_entity/Classification_entity.aod b/entity/Classification_entity/Classification_entity.aod index e827da07cf..bd478be5cb 100644 --- a/entity/Classification_entity/Classification_entity.aod +++ b/entity/Classification_entity/Classification_entity.aod @@ -54,10 +54,6 @@ </entityDependency> </dependencies> <children> - <entityParameter> - <name>ScoreType_param</name> - <expose v="false" /> - </entityParameter> <entityParameter> <name>IsAdminMode_param</name> <valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classifications/children/isadminmode_param/valueProcess.js</valueProcess> @@ -121,6 +117,10 @@ <name>ClassificationTypeId_param</name> <valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationscores/children/classificationtypeid_param/valueProcess.js</valueProcess> </entityParameter> + <entityParameter> + <name>ClassificationType_param</name> + <valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationscores/children/classificationtype_param/valueProcess.js</valueProcess> + </entityParameter> </children> </entityConsumer> <entityActionField> @@ -128,15 +128,11 @@ <fieldType>ACTION</fieldType> <onActionProcess>%aditoprj%/entity/Classification_entity/entityfields/edit/onActionProcess.js</onActionProcess> </entityActionField> - <entityParameter> - <name>ScoreType_param</name> - <expose v="true" /> - <description>PARAMETER</description> - </entityParameter> <entityField> <name>CLASSIFICATIONTYPE</name> <title>Usage</title> <consumer>KeywordClassificationTypes</consumer> + <mandatory v="true" /> <searchable v="true" /> <groupable v="true" /> <stateProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationtype/stateProcess.js</stateProcess> @@ -160,10 +156,6 @@ <valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationsadministration/children/isadminmode_param/valueProcess.js</valueProcess> <expose v="false" /> </entityParameter> - <entityParameter> - <name>ScoreType_param</name> - <expose v="false" /> - </entityParameter> </children> </entityProvider> <entityParameter> @@ -202,6 +194,7 @@ <entityField> <name>SCORETYPE</name> <title>Score type</title> + <mandatory v="true" /> <displayValueProcess>%aditoprj%/entity/Classification_entity/entityfields/scoretype/displayValueProcess.js</displayValueProcess> </entityField> </entityFields> diff --git a/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js b/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js index dba2ecaa51..455cfc292b 100644 --- a/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js +++ b/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("Classification_lib"); import("system.neon"); import("system.vars"); @@ -8,8 +7,6 @@ if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$par { // use param if available or current selectionRows var classificationType = vars.get("$field.CLASSIFICATIONTYPE") - logging.log("asdf " + vars.get("$field.CLASSIFICATIONTYPE")) - if (classificationType) result.object(ClassificationUtils.getAllGroups(classificationType, true)); } \ No newline at end of file diff --git a/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js b/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js index 52b7a0751a..2fff19b770 100644 --- a/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js +++ b/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js @@ -2,4 +2,4 @@ import("system.neon"); import("system.result"); import("system.vars"); -result.object(vars.get("$param.IsAdminMode_param") == 1 && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW); \ No newline at end of file +result.object(vars.get("$param.IsAdminMode_param") == 1 && (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)); \ No newline at end of file diff --git a/entity/Classification_entity/entityfields/classificationscores/children/classificationtype_param/valueProcess.js b/entity/Classification_entity/entityfields/classificationscores/children/classificationtype_param/valueProcess.js new file mode 100644 index 0000000000..d3275a8eaa --- /dev/null +++ b/entity/Classification_entity/entityfields/classificationscores/children/classificationtype_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.CLASSIFICATIONTYPE")) \ No newline at end of file diff --git a/entity/Classification_entity/entityfields/classificationtype_id/valueProcess.js b/entity/Classification_entity/entityfields/classificationtype_id/valueProcess.js index e49c8fad1a..3886bb2dbe 100644 --- a/entity/Classification_entity/entityfields/classificationtype_id/valueProcess.js +++ b/entity/Classification_entity/entityfields/classificationtype_id/valueProcess.js @@ -2,7 +2,7 @@ import("system.result"); import("system.neon"); import("system.vars"); -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT && !vars.get("$this.value")) +if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) && !vars.get("$this.value")) { result.string(vars.get("$field.CLASSIFICATIONTYPEID")); } \ No newline at end of file diff --git a/entity/Classification_entity/entityfields/classificationtypeid/valueProcess.js b/entity/Classification_entity/entityfields/classificationtypeid/valueProcess.js index 20cd670648..16c47d8b58 100644 --- a/entity/Classification_entity/entityfields/classificationtypeid/valueProcess.js +++ b/entity/Classification_entity/entityfields/classificationtypeid/valueProcess.js @@ -5,5 +5,6 @@ import("system.vars"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) { - result.string(util.getNewUUID()); + var newId = util.getNewUUID(); + result.string(newId); } \ 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 84060934fa..8d018fd74f 100644 --- a/entity/Classification_entity/entityfields/edit/onActionProcess.js +++ b/entity/Classification_entity/entityfields/edit/onActionProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.vars"); import("system.neon"); import("KeywordRegistry_basic"); @@ -6,7 +5,6 @@ import("KeywordRegistry_basic"); var selection = vars.get("$sys.selectionRows"); if (selection.length > 0) { - logging.log(selection.toSource()) var params = { "ClassificationType_param" : vars.get("$param.ClassificationType_param"), "ObjectType_param" : vars.get("$param.ObjectType_param"), diff --git a/entity/Classification_entity/recordcontainers/jdito/contentProcess.js b/entity/Classification_entity/recordcontainers/jdito/contentProcess.js index 71b3cab9ca..0fe1bb3c81 100644 --- a/entity/Classification_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Classification_entity/recordcontainers/jdito/contentProcess.js @@ -1,5 +1,4 @@ import("JditoFilter_lib"); -import("system.logging"); import("Classification_lib"); import("system.vars"); import("Sql_lib"); diff --git a/entity/Classification_entity/recordcontainers/jdito/onInsert.js b/entity/Classification_entity/recordcontainers/jdito/onInsert.js index 5bd556063e..5abae8836d 100644 --- a/entity/Classification_entity/recordcontainers/jdito/onInsert.js +++ b/entity/Classification_entity/recordcontainers/jdito/onInsert.js @@ -2,9 +2,8 @@ import("system.db"); import("system.util"); import("system.vars"); -var newId = util.getNewUUID(); db.insertData("CLASSIFICATIONTYPE", ["CLASSIFICATIONTYPEID", "CLASSIFICATIONTYPE", "SCORETYPE", "CLASSIFICATIONGROUP"], null, [ - newId, + vars.get("$field.CLASSIFICATIONTYPEID"), vars.get("$field.CLASSIFICATIONTYPE"), vars.get("$field.SCORETYPE"), vars.get("$field.CLASSIFICATIONGROUP"), diff --git a/entity/Classification_entity/recordcontainers/jdito/onUpdate.js b/entity/Classification_entity/recordcontainers/jdito/onUpdate.js index af0584bcb5..3bd1eec534 100644 --- a/entity/Classification_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/Classification_entity/recordcontainers/jdito/onUpdate.js @@ -1,5 +1,4 @@ import("Classification_lib"); -import("system.logging"); import("system.neon"); import("system.util"); import("Sql_lib"); @@ -36,7 +35,7 @@ else if (vars.get("$field.CLASSIFICATIONSCORE_ID")) neon.setFieldValue("$field.CLASSIFICATIONID", newId); } -// update classificationgroup-name if it was changed (only in admin) +// update classificationgroup-name and scoretype-name if they were changed (only in admin) if (vars.exists("$param.IsAdminMode_param") && vars.exists("$param.IsAdminMode_param") == "1") { changed.forEach(function(change) -- GitLab