From eaf04f71a010b53bd648e8bb21f1c14102b326c0 Mon Sep 17 00:00:00 2001 From: Simon Leipold <s.leipold@adito.de> Date: Tue, 3 Mar 2020 15:56:18 +0100 Subject: [PATCH] [Projekt: Entwicklung - Neon][TicketNr.: 1048382][Permission - Refactoring] --- process/Permission_lib/process.js | 76 +++++++++++++++---------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/process/Permission_lib/process.js b/process/Permission_lib/process.js index c4ced9f28cc..b68e28700a8 100644 --- a/process/Permission_lib/process.js +++ b/process/Permission_lib/process.js @@ -206,15 +206,15 @@ function PermissionUtil () {} * * @param {String} [pEntityName] name of the entity, can be null * - * @param {String} [pRole] name of the role, can be null + * @param {String} [pRoleName] name of the role, can be null * * @result {Integer} returns number of permissions linked to the entity-role-combination. */ - PermissionUtil.getNumberOfPermissions = function(pEntityName, pRole) { + PermissionUtil.getNumberOfPermissions = function(pEntityName, pRoleName) { return newSelect("COUNT(*)", alias) .from("ASYS_PERMISSIONSET") .whereIfSet("ASYS_PERMISSIONSET.ENTITY_ID", pEntityName) - .andIfSet("ASYS_PERMISSIONSET.ROLE_ID", pRole) + .andIfSet("ASYS_PERMISSIONSET.ROLE_ID", pRoleName) .cell(true, "0"); } @@ -295,7 +295,7 @@ function PermissionUtil () {} /** * Gets the permission set id of a given role-entity-accesstype-combination. * - * @param {String} pRole name of the role + * @param {String} pRoleName name of the role * * @param {String} pEntity name of the entity * @@ -305,11 +305,11 @@ function PermissionUtil () {} * * @result {String} returns id of the matching permission set. The result can never be null. */ - PermissionUtil.getSet = function(pRole, pEntity, pAccessType, pField) { + PermissionUtil.getSet = function(pRoleName, pEntity, pAccessType, pField) { var query = newSelect("ASYS_PERMISSIONSETID", alias) .from("ASYS_PERMISSIONSET") - .where("ASYS_PERMISSIONSET.ROLE_ID", pRole) + .where("ASYS_PERMISSIONSET.ROLE_ID", pRoleName) .and("ASYS_PERMISSIONSET.ENTITY_ID", pEntity) .and("ASYS_PERMISSIONSET.ACCESSTYPE", pAccessType); @@ -322,16 +322,16 @@ function PermissionUtil () {} /** * Gets the root permission set of a entity-role-combination. * - * @param {String} pRole id of a role + * @param {String} pRoleName id of a role * * @param {String} pEntity id of an entity * * @result {String} returns id of the root permission set of the given entity-role-combination. Never 'null', empty string if there is no result. */ - PermissionUtil.getSetRoot = function(pRole, pEntity) { + PermissionUtil.getSetRoot = function(pRoleName, pEntity) { return newSelect("ASYS_PERMISSIONSETID", alias) .from("ASYS_PERMISSIONSET") - .where("ASYS_PERMISSIONSET.ROLE_ID", pRole) + .where("ASYS_PERMISSIONSET.ROLE_ID", pRoleName) .and("ASYS_PERMISSIONSET.ENTITY_ID", pEntity) .and("ASYS_PERMISSIONSET.ACCESSTYPE", "E") .cell(); @@ -417,7 +417,7 @@ function PermissionUtil () {} * * @param {String} pEntity entity to which the PermissionSet is linked, mandatory * - * @param {String} pRole Role to which the PermissionSet is linked, mandatory + * @param {String} pRoleName Name of the role to which the PermissionSet is linked, mandatory * * @param {String} pField Field to which the PermissionSet is linked, empty if no field permission * @@ -425,7 +425,7 @@ function PermissionUtil () {} * * @result {Integer} returns id of the inserted permission set */ - PermissionUtil.insertSet = function(pParentPermSetId, pEntity, pRole, pField, pAccessType) { + PermissionUtil.insertSet = function(pParentPermSetId, pEntity, pRoleName, pField, pAccessType) { var table = "ASYS_PERMISSIONSET"; var cols = [ "FIELD_ID", @@ -436,7 +436,7 @@ function PermissionUtil () {} "ENTITY_ID" ]; var setId = util.getNewUUID(); - var vals = [pField, pAccessType, pRole, setId, pParentPermSetId, pEntity]; + var vals = [pField, pAccessType, pRoleName, setId, pParentPermSetId, pEntity]; db.insertData(table, cols, null, vals, alias); return setId; } @@ -562,7 +562,7 @@ function PermissionUtil () {} /** * Returns permissionid of the permission with fitting parameters, otherwise returns empty string * - * @param {String} pRole name of the role + * @param {String} pRoleName name of the role * * @param {String} pEntity name of the entity * @@ -577,12 +577,12 @@ function PermissionUtil () {} * @result {String} Returns the id of the permission with fitting parameters, otherwise returns empty string, can never be null * */ - PermissionUtil.getPermission = function(pRole, pEntity, pField, pAccesstype, pCondition, pCondtype) { + PermissionUtil.getPermission = function(pRoleName, pEntity, pField, pAccesstype, pCondition, pCondtype) { var permissionSelect = newSelect("ASYS_PERMISSION.ASYS_PERMISSIONID", alias) .from("ASYS_PERMISSIONSET") .join("ASYS_PERMISSION", "ASYS_PERMISSION.ASYS_PERMISSIONSET_ID = ASYS_PERMISSIONSET.ASYS_PERMISSIONSETID") .where("ASYS_PERMISSIONSET.ENTITY_ID", pEntity) - .and("ASYS_PERMISSIONSET.ROLE_ID", pRole) + .and("ASYS_PERMISSIONSET.ROLE_ID", pRoleName) .and("ASYS_PERMISSIONSET.ACCESSTYPE", pAccesstype) var emptyCond = PermissionUtil.getEmptyCondString(pEntity); @@ -702,40 +702,40 @@ function PermissionUtil () {} } /** - * Delete all links to child roles of pRole. + * Delete all links to child roles of pRoleName. * - * @param {String} pRole role which should be deleted, mandatory + * @param {String} pRoleName role which should be deleted, mandatory * * @result {Integer} returns number of deleted records */ - PermissionUtil.removeParentRoleLinks = function(pRole) { - return newWhereIfSet("ASYS_ROLES_CHILDREN.PARENT_ROLE", pRole, undefined, undefined, alias) + PermissionUtil.removeParentRoleLinks = function(pRoleName) { + return newWhereIfSet("ASYS_ROLES_CHILDREN.PARENT_ROLE", pRoleName, undefined, undefined, alias) .deleteData(true, "ASYS_ROLES_CHILDREN"); } /** - * Delete all links to parent roles of pRole. + * Delete all links to parent roles of pRoleName. * - * @param {String} pRole role which should be deleted, mandatory + * @param {String} pRoleName role which should be deleted, mandatory * * @result {Integer} returns number of deleted records */ - PermissionUtil.removeChildRoleLinks = function(pRole) { - return newWhereIfSet("ASYS_ROLES_CHILDREN.CHILD_ROLE", pRole, undefined, undefined, alias) + PermissionUtil.removeChildRoleLinks = function(pRoleName) { + return newWhereIfSet("ASYS_ROLES_CHILDREN.CHILD_ROLE", pRoleName, undefined, undefined, alias) .deleteData(true, "ASYS_ROLES_CHILDREN"); } /** * Removing all all links to parent roles. * - * @param {String} pRole role which should be deleted, mandatory + * @param {String} pRoleName role which should be deleted, mandatory * * @result {Integer} returns number of deleted records */ - PermissionUtil.removeHirarchyRoleLinks = function(pRole) { + PermissionUtil.removeHirarchyRoleLinks = function(pRoleName) { var affectedEntrys = 0; - affectedEntrys += this.removeParentRoleLinks(pRole); - affectedEntrys += this.removeChildRoleLinks(pRole); + affectedEntrys += this.removeParentRoleLinks(pRoleName); + affectedEntrys += this.removeChildRoleLinks(pRoleName); return affectedEntrys; } @@ -767,14 +767,14 @@ function PermissionUtil () {} /** * Deletes all permissions sets, permissions and permission actions linked to a role. * - * @param {String} pRole name of the role, mandatory + * @param {String} pRoleName name of the role, mandatory * * @result {String} returns number of deleted entrys */ - PermissionUtil.deleteEverythingLinkedToRole = function(pRole) { + PermissionUtil.deleteEverythingLinkedToRole = function(pRoleName) { var sets = newSelect("ASYS_PERMISSIONSETID", alias) .from("ASYS_PERMISSIONSET") - .where("ASYS_PERMISSIONSET.ROLE_ID", pRole).arrayColumn(true); + .where("ASYS_PERMISSIONSET.ROLE_ID", pRoleName).arrayColumn(true); var perms = this.getPermissions(sets); var actions = this.getActions(perms); var affectedEntrys = 0; @@ -791,7 +791,7 @@ function PermissionUtil () {} affectedEntrys += this.deleteSet(set); } - affectedEntrys += this.removeHirarchyRoleLinks(pRole); + affectedEntrys += this.removeHirarchyRoleLinks(pRoleName); return affectedEntrys; } @@ -799,15 +799,15 @@ function PermissionUtil () {} /** * Checks if the given role is deletable. This includes checks for linked permissions and hierarchies. * - * @param {String} pRole name of the role, mandatory + * @param {String} pRoleName name of the role, mandatory * * @result {Boolean} returns true if role is deletable, otherwise false */ - PermissionUtil.roleIsDeletable = function(pRole) { + PermissionUtil.roleIsDeletable = function(pRoleName) { // check for linked permissions var sets = newSelect("ASYS_PERMISSIONSETID", alias) .from("ASYS_PERMISSIONSET") - .where("ASYS_PERMISSIONSET.ROLE_ID", pRole) + .where("ASYS_PERMISSIONSET.ROLE_ID", pRoleName) .arrayColumn(true); var perms = this.getPermissions(sets); var actions = this.getActions(perms); @@ -817,16 +817,16 @@ function PermissionUtil () {} } // check for linked hierarchies - // hierarchies where pRole is child + // hierarchies where pRoleName is child var parentHierarchies = newSelect("PARENT_ROLE", alias) .from("ASYS_ROLES_CHILDREN") - .where("ASYS_ROLES_CHILDREN.CHILD_ROLE", pRole) + .where("ASYS_ROLES_CHILDREN.CHILD_ROLE", pRoleName) .arrayColumn(true); - // hierarchies where pRole is parent + // hierarchies where pRoleName is parent var childHierarchies = newSelect("CHILD_ROLE", alias) .from("ASYS_ROLES_CHILDREN") - .where("ASYS_ROLES_CHILDREN.PARENT_ROLE", pRole) + .where("ASYS_ROLES_CHILDREN.PARENT_ROLE", pRoleName) .arrayColumn(true); if (parentHierarchies.length != 0 || childHierarchies != 0) { -- GitLab