From 2b8e14bad4da780aba6657a5d55ca81961d69be2 Mon Sep 17 00:00:00 2001 From: Dany Gonzalez-Teigland Date: Thu, 7 Nov 2024 14:47:26 +0100 Subject: [PATCH] Changed Score and JaccardIndex to include users that has the access as extra, but not the role. --- RoleMining.Library/Algorithms/JaccardIndex.cs | 9 ++++----- RoleMining.Library/Classes/Score.cs | 10 ++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RoleMining.Library/Algorithms/JaccardIndex.cs b/RoleMining.Library/Algorithms/JaccardIndex.cs index 0aa0060..d3a86bc 100644 --- a/RoleMining.Library/Algorithms/JaccardIndex.cs +++ b/RoleMining.Library/Algorithms/JaccardIndex.cs @@ -21,13 +21,10 @@ public List CalculateScores(IEnumerable userAccesses, IEnumer var userAccessValidator = new UserAccessValidator(); var userInRoleValidator = new UserInRoleValidator(); + // TODO: Move validation outside of the method userAccessValidator.ValidateAndThrowArgumentExceptions(userAccesses, nameof(userAccesses)); userInRoleValidator.ValidateAndThrowArgumentExceptions(userInRoles, nameof(userInRoles)); - - // Bad data handling - // To be implented - // Access -> Users var accessesWithListOfUsers = userAccesses.GroupBy(uA => uA.AccessID) .ToDictionary(group => group.Key, group => new HashSet(group.Select(uA => uA.UserID).ToList())); @@ -100,9 +97,11 @@ public List CalculateScores(IEnumerable userAccesses, IEnumer RoleID = roleID, AccessID = accessID, UsersWithAccessAndRoleCount = usersWithRoleAndExtraAccess, + UsersWithAccessWithoutRoleCount = usersWithExtraAccess.Count() - usersWithRoleAndExtraAccess, UsersWithoutAccessWithRoleCount = usersWithRole.Count() - usersWithRoleAndExtraAccess, UsersWithAccessAndRole = usersWithRole.Intersect(usersWithExtraAccess).OrderBy(u => u).ToList(), - UsersWithoutAccessWithRole = usersWithRole.Except(usersWithExtraAccess).OrderBy(u => u).ToList() + UsersWithoutAccessWithRole = usersWithRole.Except(usersWithExtraAccess).OrderBy(u => u).ToList(), + UsersWithAccessWithoutRole = usersWithExtraAccess.Except(usersWithRole).OrderBy(u => u).ToList() }); } } diff --git a/RoleMining.Library/Classes/Score.cs b/RoleMining.Library/Classes/Score.cs index 79c3b70..3975a4a 100644 --- a/RoleMining.Library/Classes/Score.cs +++ b/RoleMining.Library/Classes/Score.cs @@ -27,6 +27,11 @@ public class Score /// public int UsersWithAccessAndRoleCount { get; set; } + /// + /// Amount of users with the access, but not with the role + /// + public int UsersWithAccessWithoutRoleCount { get; set; } + /// /// Amount of users with the role, but not with the access /// @@ -37,6 +42,11 @@ public class Score /// public List UsersWithAccessAndRole { get; set; } + /// + /// List of userIDs with the access, but not with the role + /// + public List UsersWithAccessWithoutRole { get; set; } + /// /// List of UserIDs with the role, but not with the access ///