Skip to content

Commit

Permalink
Update role mining feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tchrapovic committed Jul 11, 2023
1 parent d13047b commit 85b504f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import com.evolveum.midpoint.gui.impl.page.admin.role.mining.objects.IntersectionObject;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.utils.ClusterObjectUtils;

import com.evolveum.midpoint.gui.impl.page.admin.role.mining.utils.MiningOperationChunk;

import com.evolveum.midpoint.schema.result.OperationResult;

import com.github.openjson.JSONArray;
import com.github.openjson.JSONObject;
import com.google.common.collect.ListMultimap;
Expand All @@ -31,7 +24,11 @@

import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.algorithm.utils.UUIDToDoubleConverter;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.objects.IntersectionObject;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.utils.ClusterObjectUtils;
import com.evolveum.midpoint.gui.impl.page.admin.role.mining.utils.MiningOperationChunk;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ClusterType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
Expand Down Expand Up @@ -154,7 +151,7 @@ public ClusterStatistic statisticIdenticalLoad(DataPoint clusterDataPoints,

PolyStringType name = PolyStringType.fromOrig("cluster_" + clusterIndex);

return new ClusterStatistic(name, identifier, elementsOids, elementsCount, pointsCount, minVectorPoint,
return new ClusterStatistic(name, identifier, occupiedPoints, elementsOids, elementsCount, pointsCount, minVectorPoint,
maxVectorPoint, clusterGroupSize, pointsCount, density);
}

Expand Down Expand Up @@ -238,10 +235,23 @@ public PrismObject<ClusterType> prepareOutlierClusters(PageBase pageBase, List<D
clusterType.setIdentifier(clusterStatistic.getIdentifier());

List<String> jsonObjectList = new ArrayList<>();
List<IntersectionObject> possibleBusinessRole = new ArrayList<>();
OperationResult operationResult = new OperationResult("Prepare data for intersection");
resolveDefaultIntersection(pageBase, clusterType, jsonObjectList, possibleBusinessRole,
operationResult, clusterOptions);
if (clusterOptions != null && clusterOptions.getSimilarity() == 1) {
JSONObject jsonObject = new JSONObject();
//TODO change points elements logic
jsonObject.put("points", new JSONArray(clusterStatistic.getElementsOid()));
jsonObject.put("type", "outer");
jsonObject.put("currentElements", clusterStatistic.getTotalElements());
jsonObject.put("totalElements", clusterStatistic.getTotalElements());
jsonObject.put("metric", String.valueOf(clusterStatistic.getTotalElements() * clusterStatistic.getTotalPoints()));
jsonObject.put("elements", new JSONArray(clusterStatistic.getPointsOid()));
jsonObjectList.add(String.valueOf(jsonObject));
clusterType.getDefaultDetection().addAll(jsonObjectList);
} else {
List<IntersectionObject> possibleBusinessRole = new ArrayList<>();
OperationResult operationResult = new OperationResult("Prepare data for intersection");
resolveDefaultIntersection(pageBase, clusterType, jsonObjectList, possibleBusinessRole,
operationResult, clusterOptions);
}

return clusterTypePrismObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ClusterStatistic implements Serializable {
double density;
PolyStringType name;
String identifier;
Set<String> pointsOid;

public ClusterStatistic(PolyStringType name, String identifier, Set<String> elementsOid, int totalElements,
int totalPoints, int minVectorPoint, int maxVectorPoint, int clusterSize, double meanPoints, double density) {
Expand All @@ -34,6 +35,23 @@ public ClusterStatistic(PolyStringType name, String identifier, Set<String> elem
this.clusterSize = clusterSize;
this.meanPoints = meanPoints;
// this.frequencyMap = frequencyMap;
this.pointsOid = null;
this.density = density;
this.name = name;
this.identifier = identifier;
this.totalElements = totalElements;
}

public ClusterStatistic(PolyStringType name, String identifier, Set<String> pointsOid, Set<String> elementsOid, int totalElements,
int totalPoints, int minVectorPoint, int maxVectorPoint, int clusterSize, double meanPoints, double density) {
this.elementsOid = elementsOid;
this.totalPoints = totalPoints;
this.minVectorPoint = minVectorPoint;
this.maxVectorPoint = maxVectorPoint;
this.clusterSize = clusterSize;
this.meanPoints = meanPoints;
// this.frequencyMap = frequencyMap;
this.pointsOid = pointsOid;
this.density = density;
this.name = name;
this.identifier = identifier;
Expand All @@ -44,6 +62,10 @@ public int getTotalElements() {
return totalElements;
}

public Set<String> getPointsOid() {
return pointsOid;
}

public String getIdentifier() {
return identifier;
}
Expand Down

0 comments on commit 85b504f

Please sign in to comment.