Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
eaf04f71
Commit
eaf04f71
authored
5 years ago
by
Simon Leipold
Browse files
Options
Downloads
Patches
Plain Diff
[Projekt: Entwicklung - Neon][TicketNr.: 1048382][Permission - Refactoring]
parent
92250d00
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Permission_lib/process.js
+38
-38
38 additions, 38 deletions
process/Permission_lib/process.js
with
38 additions
and
38 deletions
process/Permission_lib/process.js
+
38
−
38
View file @
eaf04f71
...
...
@@ -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} [pRole
Name
] 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
,
pRole
Name
)
{
return
newSelect
(
"
COUNT(*)
"
,
alias
)
.
from
(
"
ASYS_PERMISSIONSET
"
)
.
whereIfSet
(
"
ASYS_PERMISSIONSET.ENTITY_ID
"
,
pEntityName
)
.
andIfSet
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
)
.
andIfSet
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
Name
)
.
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} pRole
Name
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
(
pRole
Name
,
pEntity
,
pAccessType
,
pField
)
{
var
query
=
newSelect
(
"
ASYS_PERMISSIONSETID
"
,
alias
)
.
from
(
"
ASYS_PERMISSIONSET
"
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
Name
)
.
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} pRole
Name
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
(
pRole
Name
,
pEntity
)
{
return
newSelect
(
"
ASYS_PERMISSIONSETID
"
,
alias
)
.
from
(
"
ASYS_PERMISSIONSET
"
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
Name
)
.
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
R
ole to which the PermissionSet is linked, mandatory
* @param {String} pRole
Name Name of the r
ole 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
,
pRole
Name
,
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
,
pRole
Name
,
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} pRole
Name
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
(
pRole
Name
,
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
"
,
pRole
Name
)
.
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 pRole
Name
.
*
* @param {String} pRole role which should be deleted, mandatory
* @param {String} pRole
Name
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
(
pRole
Name
)
{
return
newWhereIfSet
(
"
ASYS_ROLES_CHILDREN.PARENT_ROLE
"
,
pRole
Name
,
undefined
,
undefined
,
alias
)
.
deleteData
(
true
,
"
ASYS_ROLES_CHILDREN
"
);
}
/**
* Delete all links to parent roles of pRole.
* Delete all links to parent roles of pRole
Name
.
*
* @param {String} pRole role which should be deleted, mandatory
* @param {String} pRole
Name
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
(
pRole
Name
)
{
return
newWhereIfSet
(
"
ASYS_ROLES_CHILDREN.CHILD_ROLE
"
,
pRole
Name
,
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} pRole
Name
role which should be deleted, mandatory
*
* @result {Integer} returns number of deleted records
*/
PermissionUtil
.
removeHirarchyRoleLinks
=
function
(
pRole
)
{
PermissionUtil
.
removeHirarchyRoleLinks
=
function
(
pRole
Name
)
{
var
affectedEntrys
=
0
;
affectedEntrys
+=
this
.
removeParentRoleLinks
(
pRole
);
affectedEntrys
+=
this
.
removeChildRoleLinks
(
pRole
);
affectedEntrys
+=
this
.
removeParentRoleLinks
(
pRole
Name
);
affectedEntrys
+=
this
.
removeChildRoleLinks
(
pRole
Name
);
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} pRole
Name
name of the role, mandatory
*
* @result {String} returns number of deleted entrys
*/
PermissionUtil
.
deleteEverythingLinkedToRole
=
function
(
pRole
)
{
PermissionUtil
.
deleteEverythingLinkedToRole
=
function
(
pRole
Name
)
{
var
sets
=
newSelect
(
"
ASYS_PERMISSIONSETID
"
,
alias
)
.
from
(
"
ASYS_PERMISSIONSET
"
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
).
arrayColumn
(
true
);
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
Name
).
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
(
pRole
Name
);
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} pRole
Name
name of the role, mandatory
*
* @result {Boolean} returns true if role is deletable, otherwise false
*/
PermissionUtil
.
roleIsDeletable
=
function
(
pRole
)
{
PermissionUtil
.
roleIsDeletable
=
function
(
pRole
Name
)
{
// check for linked permissions
var
sets
=
newSelect
(
"
ASYS_PERMISSIONSETID
"
,
alias
)
.
from
(
"
ASYS_PERMISSIONSET
"
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
)
.
where
(
"
ASYS_PERMISSIONSET.ROLE_ID
"
,
pRole
Name
)
.
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 pRole
Name
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
"
,
pRole
Name
)
.
arrayColumn
(
true
);
// hierarchies where pRole is parent
// hierarchies where pRole
Name
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
"
,
pRole
Name
)
.
arrayColumn
(
true
);
if
(
parentHierarchies
.
length
!=
0
||
childHierarchies
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment