Skip to content

Commit

Permalink
Improvements for role mining functionality
Browse files Browse the repository at this point in the history
1. Adding a data generator for testing role-mining algorithms
2. Data loading speed optimization and GUI modification
3. Fix known issues
  • Loading branch information
tchrapovic committed Dec 16, 2022
1 parent 9bc01bd commit 52ec010
Show file tree
Hide file tree
Showing 27 changed files with 1,932 additions and 882 deletions.
24 changes: 24 additions & 0 deletions gui/admin-gui/src/frontend/scss/midpoint.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
@import "tiles";
@import "tables";
@import "role-mining-rotated-header";
@import "role-mining-static-header";
@import "role-mining-static-header-name";
@import "role-mining-static-row-header";

body.custom-hold-transition {
.content-wrapper,
Expand Down Expand Up @@ -1787,4 +1790,25 @@ th.debug-list-buttons {
border: 1px solid #f4f4f4;
}

.role-mining-static-header {
width: 40px;
height: 150px;
}

.role-mining-static-header-name {
display: flex;
justify-content: center;
align-items: center;
transform: rotate(180deg);
writing-mode: revert;
width: 40px;
height: 150px;
border: 1px solid #f4f4f4;
}

.role-mining-static-row-header {
width: 150px;
height: 150px;
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*!
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/


.role-mining-static-header-name {
display: flex;
justify-content: center;
align-items: center;
transform: rotate(180deg);
writing-mode: revert;
width: 40px;
height: 150px;
border: 1px solid #f4f4f4;
}


14 changes: 14 additions & 0 deletions gui/admin-gui/src/frontend/scss/role-mining-static-header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*!
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/


.role-mining-static-header {
width: 40px;
height: 150px;
}


14 changes: 14 additions & 0 deletions gui/admin-gui/src/frontend/scss/role-mining-static-row-header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*!
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/


.role-mining-static-row-header {
width: 150px;
height: 150px;
}


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.api.mining;
package com.evolveum.midpoint.gui.api.component.mining;

import java.util.*;

Expand Down Expand Up @@ -38,19 +38,24 @@ public List<List<String>> combinationsResult(List<List<String>> combination, Lis
}
}

counts.add(counter);
combinationHelperLists.add(new CombinationHelperList(counter, combinationForCheck));
if(counter != 0) {
counts.add(counter);
combinationHelperLists.add(new CombinationHelperList(counter, combinationForCheck));
}
}

Integer maxCount = Collections.max(counts);
if(counts.size() > 0) {
Integer maxCount = Collections.max(counts);

List<List<String>> result = new ArrayList<>();
for (CombinationHelperList storageRow : combinationHelperLists) {
if (storageRow.getCount() == maxCount) {
result.add(storageRow.getCombinations());
List<List<String>> result = new ArrayList<>();
for (CombinationHelperList storageRow : combinationHelperLists) {
if (storageRow.getCount() == maxCount) {
result.add(storageRow.getCombinations());
}
}
return sort(result);
}
return sort(result);
return null;
}

public int findDuplicates(List<String> combination, List<List<String>> matrix) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.api.mining;
package com.evolveum.midpoint.gui.api.component.mining;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,40 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.api.mining;
package com.evolveum.midpoint.gui.api.component.mining;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

import java.io.Serializable;
import java.util.ArrayList;

public class JaccardDataStructure implements Serializable {

public static final String F_NAME = "objectName";
public static final String F_NAME = "userObject";
public static final String F_RESULT_ARRAY = "objectPartialResult";
public static final String F_SUM_RESULT = "objectTotalResult";

String objectName;
public PrismObject<UserType> getUserObject() {
return userObject;
}

public void setUserObject(PrismObject<UserType> userObject) {
this.userObject = userObject;
}

PrismObject<UserType> userObject;
ArrayList<Double> objectPartialResult;
double objectTotalResult;

public JaccardDataStructure(String objectName, double objectTotalResult, ArrayList<Double> objectPartialResult) {
this.objectName = objectName;
public JaccardDataStructure(PrismObject<UserType> userObject, double objectTotalResult, ArrayList<Double> objectPartialResult) {
this.userObject = userObject;
this.objectPartialResult = objectPartialResult;
this.objectTotalResult = objectTotalResult;
}

public String getObjectName() {
return objectName;
}

public void setObjectName(String objectName) {
this.objectName = objectName;
}


public ArrayList<Double> getObjectPartialResult() {
return objectPartialResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2010-2022 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.api.component.mining;

import java.util.HashMap;
import java.util.Map;

public class ProbabilityGenerator {

private final Map<Integer, Double> probability;
private double probabilitySum;

public ProbabilityGenerator() {
probability = new HashMap<>();
}

public void addGroupProbability(int value, double probability) {
if (this.probability.get(value) != null) {
this.probabilitySum -= this.probability.get(value);
}
this.probability.put(value, probability);
probabilitySum = probabilitySum + probability;
}

public int getRandomNumber() {
double random = Math.random();
double ratio = 1.0f / probabilitySum;
double tempProbability = 0;
for (Integer i : probability.keySet()) {
tempProbability += probability.get(i);
if (random / ratio <= tempProbability) {
return i;
}
}
return 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,68 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.api.mining;
package com.evolveum.midpoint.gui.api.component.mining;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

public class RoleAnalyseHelper implements Serializable {


public List<PrismObject<RoleType>> jaccardGetRolesGroup(RoleMiningStructureList selectedData,
List<PrismObject<UserType>> jaccardUsersAnalysed,
PageBase pageBase) {

List<PrismObject<RoleType>> jaccardResultRoles = new ArrayList<>();
if (selectedData != null) {


List<ObjectReferenceType> rolesForCompare = new RoleMiningFilter().getRoleObjectReferenceTypes(selectedData.getUserObject().asObjectable());
for (PrismObject<UserType> userTypePrismObject : jaccardUsersAnalysed) {
rolesForCompare = roleIntersected(rolesForCompare,
new RoleMiningFilter().getRoleObjectReferenceTypes(userTypePrismObject.asObjectable()));
}

for (ObjectReferenceType objectReferenceType : rolesForCompare) {
try {
jaccardResultRoles.add(new RoleMiningFilter().getRoleByOid(objectReferenceType.getOid(), pageBase));
} catch (CommonException e) {
e.printStackTrace();
}
}
}
return jaccardResultRoles;
}


public List<PrismObject<UserType>> jaccardGetUserGroup(RoleMiningStructureList selectedData,
double jaccardThreshold,
List<PrismObject<UserType>> users) {

List<PrismObject<UserType>> jaccardUsersAnalysed = new ArrayList<>();

if (selectedData != null) {

for (int j = 0; j < selectedData.getObjectPartialResult().size(); j++) {
if (selectedData.getObjectPartialResult().get(j) > jaccardThreshold) {
jaccardUsersAnalysed.add(users.get(j));
}
}
}
return jaccardUsersAnalysed;
}





public double jaccardIndex(List<String> membersRoleA, List<String> membersRoleB, int minRolesCount) {
if (membersRoleA == null || membersRoleB == null) {
return 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.model.api.mining;
package com.evolveum.midpoint.gui.api.component.mining;

import java.io.Serializable;
import java.util.List;
Expand Down

0 comments on commit 52ec010

Please sign in to comment.