diff --git a/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js b/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js index e8b93be4640d2e0b43feb7ea936ec38502217e59..ce9afce8a69d5aa2229d95ba127b48ce499e9ad7 100644 --- a/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/PermissionDetail_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("Sql_lib"); import("system.util"); import("system.vars"); @@ -106,21 +107,22 @@ if (selectedPermission == null) { } } +logging.log(res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes).toSource()); result.object(res.sort(sortResultsByCondition).sort(sortResultsByAccessTypes)); function prepareResultArray(pEntry, pRes) { - var rootPermission = ""; + var parentPermission = ""; + var noCond = "{\"entity\":\"" + pEntry.entity + "\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}"; + if (pEntry.accesstype != "E") { - if (pEntry.accesstype == "F" && pEntry.cond != "" && pEntry.cond != noCond) { - rootPermission = PermissionUtil.getPermissionWithoutCond(PermissionUtil.getParentSet(pEntry.permissionid)); - if (rootPermission == "") { - rootPermission = PermissionUtil.getPermissionRoot(pEntry.permissionid); - } - } else - rootPermission = PermissionUtil.getPermissionRoot(pEntry.permissionid); + if (pEntry.cond == "" || pEntry.cond == noCond) { // default permission + parentPermission = PermissionUtil.getPermissionWithoutCond(PermissionUtil.getParentSetOfSet(PermissionUtil.getParentSet(pEntry.permissionid))); + } else { // conditional permission + parentPermission = PermissionUtil.getPermissionWithoutCond(PermissionUtil.getParentSet(pEntry.permissionid)); + } } pRes.push([pEntry.permissionid, pEntry.entity, pEntry.role, pEntry.field, pEntry.cond, - sortActions(pEntry.action.split(","), pEntry.accesstype).join(","), pEntry.accesstype, pEntry.condtype, rootPermission]); + sortActions(pEntry.action.split(","), pEntry.accesstype).join(","), pEntry.accesstype, pEntry.condtype, parentPermission]); return pRes; } @@ -191,6 +193,10 @@ function sortResultsByCondition(a, b) { if (a[4] == "" || a[4] == noCond) { return -1; } else if (b[4] == "" || b[4] == noCond) { + return -1; + } else if (a[4] != "" && a[4] != noCond) { + return 1; + } else if (b[4] != "" && b[4] != noCond) { return 1; } else { return 0; diff --git a/process/Permission_lib/process.js b/process/Permission_lib/process.js index bfe618882b42cfbdb8510f15b31f3051c89116d9..998770b147d8eef3a3148b3f9d682e88851c05bf 100644 --- a/process/Permission_lib/process.js +++ b/process/Permission_lib/process.js @@ -286,6 +286,19 @@ function PermissionUtil () {} + " where ASYS_PERMISSIONID = '" + pPermId + "'"; return db.cell(sqlStr, alias); } + + /** + * Gets the parent permission set of a set. + * + * @param {String} pSetId id of the permission set + * + * @result {String} returns id of the parent permission set of the given set. Never 'null', empty string if there is no result. + */ + PermissionUtil.getParentSetOfSet = function(pSetId) { + var sqlStr = "select ASYS_PERMISSIONSET_ID from ASYS_PERMISSIONSET" + + " where ASYS_PERMISSIONSETID = '" + pSetId + "'"; + return db.cell(sqlStr, alias); + } /** * Checks if the given permission set has any children left.