diff --git a/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod b/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod index b487049e932dcab0245c5b3d5f8ad2b2a3a3f7e3..cdf27e635efb1de8e88f86a48dde7ddb36615a06 100644 --- a/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod +++ b/entity/ClassificationAdmin_entity/ClassificationAdmin_entity.aod @@ -8,12 +8,21 @@ <grantCreate v="false" /> <grantUpdate v="false" /> <grantDelete v="false" /> + <contentTitleProcess>%aditoprj%/entity/ClassificationAdmin_entity/contentTitleProcess.js</contentTitleProcess> <usePermissions v="true" /> <titlePlural>Classifications</titlePlural> <recordContainer>jdito</recordContainer> <entityFields> <entityProvider> <name>#PROVIDER</name> + <dependencies> + <entityDependency> + <name>75825cca-fbff-45a0-9a46-b1b0f639ae6a</name> + <entityName>Classification_entity</entityName> + <fieldName>ClassificationTypes</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> </entityProvider> <entityField> <name>UID</name> diff --git a/entity/ClassificationAdmin_entity/contentTitleProcess.js b/entity/ClassificationAdmin_entity/contentTitleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..552a186ab33275b9d36c32b996dfca794988584c --- /dev/null +++ b/entity/ClassificationAdmin_entity/contentTitleProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.UID.displayValue")) \ No newline at end of file diff --git a/entity/Classification_entity/Classification_entity.aod b/entity/Classification_entity/Classification_entity.aod index f0bf63ede50207d5dddcb8de2ed133e0d48a2708..e2d4e933f214d4240c7aabf9f2e5246c9134b09d 100644 --- a/entity/Classification_entity/Classification_entity.aod +++ b/entity/Classification_entity/Classification_entity.aod @@ -3,6 +3,7 @@ <name>Classification_entity</name> <majorModelMode>DISTRIBUTED</majorModelMode> <title>Classification</title> + <grantDeleteProcess>%aditoprj%/entity/Classification_entity/grantDeleteProcess.js</grantDeleteProcess> <afterOperatingState>%aditoprj%/entity/Classification_entity/afterOperatingState.js</afterOperatingState> <titlePlural>Classifications</titlePlural> <recordContainer>jdito</recordContainer> @@ -78,14 +79,14 @@ </entityField> <entityField> <name>CLASSIFICATIONGROUP</name> - <title>Classification group</title> <contentType>TEXT</contentType> <mandatoryProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/mandatoryProcess.js</mandatoryProcess> <dropDownProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js</dropDownProcess> <textInputAllowed v="true" /> <groupable v="true" /> - <stateProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/stateProcess.js</stateProcess> + <titleProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/titleProcess.js</titleProcess> <displayValueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/displayValueProcess.js</displayValueProcess> + <onValidation>%aditoprj%/entity/Classification_entity/entityfields/classificationgroup/onValidation.js</onValidation> </entityField> <entityField> <name>CLASSIFICATIONTYPE_ID</name> @@ -137,6 +138,9 @@ </entityParameter> <entityField> <name>CLASSIFICATIONTYPE</name> + <consumer>ClassificationTypes</consumer> + <groupable v="true" /> + <state>EDITABLE</state> <valueProcess>%aditoprj%/entity/Classification_entity/entityfields/classificationtype/valueProcess.js</valueProcess> </entityField> <entityProvider> @@ -178,6 +182,15 @@ <entityField> <name>SCORE_RESULTS</name> </entityField> + <entityConsumer> + <name>ClassificationTypes</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>ClassificationAdmin_entity</entityName> + <fieldName>#PROVIDER</fieldName> + </dependency> + </entityConsumer> </entityFields> <recordContainers> <jDitoRecordContainer> diff --git a/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js b/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js index bd94927bdabc373750fe4a3d8ac9c20bfa932ffc..9151a529e96fde54b2f6c3b688f1b51f262befc6 100644 --- a/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js +++ b/entity/Classification_entity/entityfields/classificationgroup/dropDownProcess.js @@ -1,4 +1,13 @@ +import("system.logging"); +import("Classification_lib"); +import("system.neon"); +import("system.vars"); import("system.db"); import("system.result"); - -result.object(db.table("select distinct CLASSIFICATIONGROUP, CLASSIFICATIONGROUP from CLASSIFICATIONTYPE order by CLASSIFICATIONGROUP")); \ No newline at end of file +logging.log(vars.get("$param.IsAdminMode_param")) +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.IsAdminMode_param") && vars.get("$param.IsAdminMode_param") == "1") +{ + logging.log(vars.get("$param.ClassificationType_param")) + logging.log(ClassificationUtils.getAllGroups(vars.get("$param.ClassificationType_param"), true).toSource()) + result.object(ClassificationUtils.getAllGroups(vars.get("$param.ClassificationType_param"), true)); +} \ No newline at end of file diff --git a/entity/Classification_entity/entityfields/classificationgroup/onValidation.js b/entity/Classification_entity/entityfields/classificationgroup/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..4bce0a846ef25ea871b1cae3fc748657caa0b4c5 --- /dev/null +++ b/entity/Classification_entity/entityfields/classificationgroup/onValidation.js @@ -0,0 +1,17 @@ +import("system.neon"); +import("system.translate"); +import("system.result"); +import("system.vars"); +import("Classification_lib"); +import("Entity_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT && vars.exists("$param.IsAdminMode_param") && vars.get("$param.IsAdminMode_param") == "1") +{ + var newGroup = ProcessHandlingUtils.getOnValidationValue(); + var groups = ClassificationUtils.getAllGroups(vars.get("$param.ClassificationType_param"), false) + + if (groups.indexOf(newGroup, 0) != -1 && ClassificationUtils.getGroupFromDb(vars.get("$field.CLASSIFICATIONTYPEID")) != newGroup) + { + result.string(translate.text("The new Classification name already exists.")); + } +} diff --git a/entity/Classification_entity/entityfields/classificationgroup/stateProcess.js b/entity/Classification_entity/entityfields/classificationgroup/stateProcess.js deleted file mode 100644 index 626da788b0307aee25ce6ab8849e3e9357ba0645..0000000000000000000000000000000000000000 --- a/entity/Classification_entity/entityfields/classificationgroup/stateProcess.js +++ /dev/null @@ -1,12 +0,0 @@ -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/entityfields/classificationgroup/titleProcess.js b/entity/Classification_entity/entityfields/classificationgroup/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..69092d7e4eb7d0499152f2b6c7f91cc0d3352e2b --- /dev/null +++ b/entity/Classification_entity/entityfields/classificationgroup/titleProcess.js @@ -0,0 +1,13 @@ +import("system.neon"); +import("system.translate"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.IsAdminMode_param") && vars.exists("$param.IsAdminMode_param") == "1") +{ + result.string(translate.text("Group")); +} +else +{ + result.string(translate.text("Group name")); +} \ 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 8d018fd74f148d59d904106aacd47f1877ad01d5..84060934fa289bee4a46a25942809558de10bbc6 100644 --- a/entity/Classification_entity/entityfields/edit/onActionProcess.js +++ b/entity/Classification_entity/entityfields/edit/onActionProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.vars"); import("system.neon"); import("KeywordRegistry_basic"); @@ -5,6 +6,7 @@ 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/grantDeleteProcess.js b/entity/Classification_entity/grantDeleteProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..9a1336d5cf503c64baa7cd083855545265a12901 --- /dev/null +++ b/entity/Classification_entity/grantDeleteProcess.js @@ -0,0 +1,23 @@ +import("system.logging"); +import("system.result"); +import("system.db"); +import("system.vars"); +import("Sql_lib"); + +/*logging.log(db.cell(SqlCondition.begin() + .andPrepare("CLASSIFICATION.CLASSIFICATIONTYPE_ID", vars.get("$field.CLASSIFICATIONTYPEID")) + .buildSql("select count(*) from CLASSIFICATION", "1=2"))) +/*result.object(parseInt(db.cell(SqlCondition.begin() + .andPrepare("CLASSIFICATION.CLASSIFICATIONTYPE_ID", vars.get("$field.CLASSIFICATIONTYPEID")) + .buildSql("select count(*) from CLASSIFICATION", "1=2"))) <= 0);*/ + +//{ + /*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(); \ No newline at end of file diff --git a/entity/Classification_entity/recordcontainers/jdito/contentProcess.js b/entity/Classification_entity/recordcontainers/jdito/contentProcess.js index 9e4691657fbc6c6ca71044107d9e707f824a849f..d0d8001f500e887a572a630a2ead5ebe09d93b72 100644 --- a/entity/Classification_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Classification_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("Classification_lib"); import("system.vars"); import("Sql_lib"); @@ -46,9 +47,18 @@ if (!classificationId) .andSqlCondition(SqlCondition.begin().orPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param") .or("CLASSIFICATION.OBJECT_ROWID is null")) } - + +logging.log(db.translateStatement(cond.buildSql("select case when CLASSIFICATIONID is not null then 'C,' || CLASSIFICATIONID else 'T,' || CLASSIFICATIONTYPEID end, CLASSIFICATIONID, CLASSIFICATIONGROUP, CLASSIFICATIONSCORE_ID, CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE_ID, OBJECT_TYPE, OBJECT_ROWID, SCORETYPE, CLASSIFICATIONTYPE.CLASSIFICATIONTYPE from CLASSIFICATION \n\ + right join CLASSIFICATIONTYPE on " + db.translateCondition(SqlCondition.begin() + .and("CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID") + .andPrepareVars("CLASSIFICATION.OBJECT_TYPE", "$param.ObjectType_param") + .andPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param").build()), (admin ? "1=1" : "1=2"), "order by CLASSIFICATIONGROUP asc"))) + result.object(db.table(cond.buildSql("select case when CLASSIFICATIONID is not null then 'C,' || CLASSIFICATIONID else 'T,' || CLASSIFICATIONTYPEID end, CLASSIFICATIONID, CLASSIFICATIONGROUP, CLASSIFICATIONSCORE_ID, CLASSIFICATIONTYPEID, CLASSIFICATIONTYPE_ID, OBJECT_TYPE, OBJECT_ROWID, SCORETYPE, CLASSIFICATIONTYPE.CLASSIFICATIONTYPE from CLASSIFICATION \n\ - right join CLASSIFICATIONTYPE on CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID", "1=2", "order by CLASSIFICATIONGROUP asc")) + right join CLASSIFICATIONTYPE on " + db.translateCondition(SqlCondition.begin() + .and("CLASSIFICATIONTYPE_ID = CLASSIFICATIONTYPEID") + .andPrepareVars("CLASSIFICATION.OBJECT_TYPE", "$param.ObjectType_param") + .andPrepareVars("CLASSIFICATION.OBJECT_ROWID", "$param.ObjectRowid_param").build()), (admin ? "1=1" : "1=2"), "order by CLASSIFICATIONGROUP asc")) .map(function(pRow) { pRow.push(scores); diff --git a/entity/Classification_entity/recordcontainers/jdito/onUpdate.js b/entity/Classification_entity/recordcontainers/jdito/onUpdate.js index f66b5fc3295c1c95871d838d2dd6ef3fd93a9a46..9a5b1a4a158ca3645df0f4caecc819c666cc37bd 100644 --- a/entity/Classification_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/Classification_entity/recordcontainers/jdito/onUpdate.js @@ -1,3 +1,5 @@ +import("Classification_lib"); +import("system.logging"); import("system.neon"); import("system.util"); import("Sql_lib"); @@ -6,6 +8,7 @@ import("system.vars"); var changed = vars.get("$local.changed"); +logging.log(vars.get("$field.CLASSIFICATIONID")) // check if it already exists. Else it only exists as ScoreType but has no Classification-Entry if (vars.get("$field.CLASSIFICATIONID")) { @@ -32,4 +35,22 @@ else if (vars.get("$field.CLASSIFICATIONSCORE_ID")) ]); neon.setFieldValue("$field.CLASSIFICATIONID", newId); +} + +// update classificationgroup-name if it was changed (only in admin) +if (vars.exists("$param.IsAdminMode_param") && vars.exists("$param.IsAdminMode_param") == "1") +{ + changed.forEach(function(change) + { + logging.log(change) + switch (change) + { + case "CLASSIFICATIONGROUP.value": + var oldGroupName = ClassificationUtils.getGroupFromDb(vars.get("$field.CLASSIFICATIONTYPEID")); + var newGroupName = vars.get("$field.CLASSIFICATIONGROUP"); + + ClassificationUtils.changeGroupName(oldGroupName, newGroupName, vars.get("$field.CLASSIFICATIONTYPE")) + } + }) + } \ No newline at end of file diff --git a/neonView/ClassificationAdminTree_view/ClassificationAdminTree_view.aod b/neonView/ClassificationAdminTree_view/ClassificationAdminTree_view.aod index 297fa04cf2a555ceebf18e9a9bb30dc6b721e1cd..2d44f2e088d71aa9d7e145adfef16733a2efe8c0 100644 --- a/neonView/ClassificationAdminTree_view/ClassificationAdminTree_view.aod +++ b/neonView/ClassificationAdminTree_view/ClassificationAdminTree_view.aod @@ -14,6 +14,7 @@ <defaultGroupFields> <element>CLASSIFICATIONGROUP</element> </defaultGroupFields> + <hideContentSearch v="true" /> <showChildrenCount v="false" /> <entryAction>edit</entryAction> <entityField>#ENTITY</entityField> diff --git a/neonView/ClassificationScoreMultipleEdit_view/ClassificationScoreMultipleEdit_view.aod b/neonView/ClassificationScoreMultipleEdit_view/ClassificationScoreMultipleEdit_view.aod index 6a1e41c260e10ecafb368e099cb261c13c10d2a4..b8c8b7594b6189ef25f0a104b8a4e8288e3d60b6 100644 --- a/neonView/ClassificationScoreMultipleEdit_view/ClassificationScoreMultipleEdit_view.aod +++ b/neonView/ClassificationScoreMultipleEdit_view/ClassificationScoreMultipleEdit_view.aod @@ -4,9 +4,10 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <isSmall v="true" /> <layout> - <noneLayout> + <drawerLayout> <name>layout</name> - </noneLayout> + <layoutCaption>Possible Values</layoutCaption> + </drawerLayout> </layout> <children> <genericMultipleViewTemplate> diff --git a/process/Classification_lib/process.js b/process/Classification_lib/process.js index 7e9c2d89fabc34e4261acef7a829868c4037e4a1..a790e3fa72c155f1d36ee218ddad91a1a68b8d75 100644 --- a/process/Classification_lib/process.js +++ b/process/Classification_lib/process.js @@ -1,3 +1,5 @@ +import("system.logging"); +import("system.vars"); import("system.db"); import("Sql_lib"); @@ -62,4 +64,33 @@ ClassificationUtils.mapToClass = function(pScore) return "A"; return "_"; +} + +ClassificationUtils.getAllGroups = function(pClassificationtype, twoCol) +{ + var sql = SqlCondition.begin() + .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", pClassificationtype) + .buildSql("select distinct CLASSIFICATIONGROUP" + (twoCol ? ", CLASSIFICATIONGROUP" : "") + " from CLASSIFICATIONTYPE", "", " order by CLASSIFICATIONGROUP") + + if (twoCol) + return db.table(sql); + else + return db.array(db.COLUMN, sql); +} + +ClassificationUtils.getGroupFromDb = function(pClassificationtypeId) +{ + return db.cell(SqlCondition.begin() + .andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", pClassificationtypeId) + .buildSql("select CLASSIFICATIONGROUP from CLASSIFICATIONTYPE", "", " order by CLASSIFICATIONGROUP")) +} + +ClassificationUtils.changeGroupName = function(pOldName, pNewName, pClassificationType) +{ + var groups = ClassificationUtils.getAllGroups(pClassificationType, false) + + if (groups.indexOf(pNewName, 0) == -1) + { + db.updateData("CLASSIFICATIONTYPE", ["CLASSIFICATIONGROUP"], null, [pNewName], SqlCondition.equals("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", pOldName, "1=2")); + } } \ No newline at end of file