Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Sep 4, 2023
2 parents 40a8407 + f7514cd commit eb25c00
Show file tree
Hide file tree
Showing 19 changed files with 207 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust
Set<String> membersOidSet = new HashSet<>();

handler.setActive(true);
handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(members.size());
for (ObjectReferenceType member : members) {
handler.iterateActualStatus();
Expand All @@ -109,7 +109,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust

}

handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(members.size());
int roleMapSize = roleMap.size();
ListMultimap<List<String>, String> roleChunk = ArrayListMultimap.create();
Expand All @@ -122,7 +122,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust
}

int userChunkSize = userChunk.size();
handler.setSubTitle("Process Role Structure");
handler.enterNewStep("Process Role Structure");
handler.setOperationCountToProcess(userChunkSize);
for (List<String> users : userChunk.keySet()) {
handler.iterateActualStatus();
Expand All @@ -146,7 +146,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust

int memberCount = membersOidSet.size();
int roleChunkSize = roleChunk.size();
handler.setSubTitle("Process User Structure");
handler.enterNewStep("Process User Structure");
handler.setOperationCountToProcess(roleChunkSize);
for (List<String> key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -187,7 +187,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust
Set<String> membersOidSet = new HashSet<>();

handler.setActive(true);
handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(members.size());
for (ObjectReferenceType member : members) {
handler.iterateActualStatus();
Expand All @@ -214,7 +214,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust
}

int roleMapSize = roleMap.size();
handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(roleMapSize);
ListMultimap<List<String>, String> roleChunk = ArrayListMultimap.create();
for (String key : roleMap.keySet()) {
Expand All @@ -224,7 +224,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust
}

int userChunkSize = userChunk.size();
handler.setSubTitle("Process User Structure");
handler.enterNewStep("Process User Structure");
handler.setOperationCountToProcess(userChunkSize);
for (List<String> key : userChunk.keySet()) {
handler.iterateActualStatus();
Expand All @@ -250,7 +250,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust

int roleChunkSize = roleChunk.size();

handler.setSubTitle("Process Role Structure");
handler.enterNewStep("Process Role Structure");
handler.setOperationCountToProcess(roleChunkSize);
for (List<String> key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -291,7 +291,7 @@ public MiningOperationChunk preparePartialRoleBasedStructure(@NotNull RoleAnalys

List<ObjectReferenceType> members = cluster.getMember();
handler.setActive(true);
handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(members.size());
for (ObjectReferenceType objectReferenceType : members) {
handler.iterateActualStatus();
Expand All @@ -317,7 +317,7 @@ public MiningOperationChunk preparePartialRoleBasedStructure(@NotNull RoleAnalys
int membersCount = membersOidSet.size();
//user //role
ListMultimap<List<String>, String> roleChunk = ArrayListMultimap.create();
handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(roleMap.size());

for (String key : roleMap.keySet()) {
Expand All @@ -326,7 +326,7 @@ public MiningOperationChunk preparePartialRoleBasedStructure(@NotNull RoleAnalys
roleChunk.put(values, key);
}

handler.setSubTitle("Prepare User Structure");
handler.enterNewStep("Prepare User Structure");
handler.setOperationCountToProcess(roleChunk.size());
for (List<String> key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -363,7 +363,7 @@ public MiningOperationChunk preparePartialUserBasedStructure(@NotNull RoleAnalys

List<ObjectReferenceType> members = cluster.getMember();
handler.setActive(true);
handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(members.size());
for (ObjectReferenceType objectReferenceType : members) {
handler.iterateActualStatus();
Expand All @@ -389,7 +389,7 @@ public MiningOperationChunk preparePartialUserBasedStructure(@NotNull RoleAnalys
//user //role
ListMultimap<List<String>, String> roleChunk = ArrayListMultimap.create();

handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(roleMap.size());
for (String key : roleMap.keySet()) {
handler.iterateActualStatus();
Expand All @@ -398,7 +398,7 @@ public MiningOperationChunk preparePartialUserBasedStructure(@NotNull RoleAnalys
roleChunk.put(values, key);
}

handler.setSubTitle("Prepare Role Structure");
handler.enterNewStep("Prepare Role Structure");
handler.setOperationCountToProcess(roleChunk.size());
for (List<String> key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust

int rolesCount = rolesElements.size();
handler.setActive(true);
handler.setSubTitle("Prepare Role Structure");
handler.enterNewStep("Prepare Role Structure");
handler.setOperationCountToProcess(rolesCount);
for (ObjectReferenceType rolesElement : rolesElements) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -115,7 +115,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust

int userChunkSize = userChunk.size();

handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(miningRoleTypeChunks.size());
for (MiningRoleTypeChunk chunk : miningRoleTypeChunks) {
handler.iterateActualStatus();
Expand All @@ -125,7 +125,7 @@ public MiningOperationChunk prepareRoleBasedStructure(@NotNull RoleAnalysisClust

int memberCount = membersOidSet.size();

handler.setSubTitle("Prepare User Structure");
handler.enterNewStep("Prepare User Structure");
handler.setOperationCountToProcess(userChunk.size());
for (String key : userChunk.keySet()) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -164,7 +164,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust
int usersCount = members.size();

handler.setActive(true);
handler.setSubTitle("Prepare User Structure");
handler.enterNewStep("Prepare User Structure");
handler.setOperationCountToProcess(usersCount);
for (int i = 0; i < usersCount; i++) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -196,7 +196,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust

int roleChunkSize = roleChunk.size();

handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(usersCount);
for (MiningUserTypeChunk chunk : miningUserTypeChunks) {
handler.iterateActualStatus();
Expand All @@ -206,7 +206,7 @@ public MiningOperationChunk prepareUserBasedStructure(@NotNull RoleAnalysisClust

int memberCount = membersOidSet.size();

handler.setSubTitle("Prepare Role Structure");
handler.enterNewStep("Prepare Role Structure");
handler.setOperationCountToProcess(usersCount);
for (String key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -244,7 +244,7 @@ public MiningOperationChunk preparePartialRoleBasedStructure(@NotNull RoleAnalys
Set<String> membersOidSet = new HashSet<>();

handler.setActive(true);
handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(rolesElements.size());
for (ObjectReferenceType objectReferenceType : rolesElements) {
handler.iterateActualStatus();
Expand All @@ -267,7 +267,7 @@ public MiningOperationChunk preparePartialRoleBasedStructure(@NotNull RoleAnalys

//user //role
ListMultimap<List<String>, String> roleChunk = ArrayListMultimap.create();
handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(roleMap.size());
for (String key : roleMap.keySet()) {
handler.iterateActualStatus();
Expand All @@ -278,7 +278,7 @@ public MiningOperationChunk preparePartialRoleBasedStructure(@NotNull RoleAnalys

int memberCount = membersOidSet.size();

handler.setSubTitle("Prepare User Structure");
handler.enterNewStep("Prepare User Structure");
handler.setOperationCountToProcess(roleChunk.size());
for (List<String> key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -317,7 +317,7 @@ public MiningOperationChunk preparePartialUserBasedStructure(@NotNull RoleAnalys
List<ObjectReferenceType> members = cluster.getMember();

handler.setActive(true);
handler.setSubTitle("Map Users");
handler.enterNewStep("Map Users");
handler.setOperationCountToProcess(members.size());
for (ObjectReferenceType objectReferenceType : members) {
handler.iterateActualStatus();
Expand Down Expand Up @@ -346,7 +346,7 @@ public MiningOperationChunk preparePartialUserBasedStructure(@NotNull RoleAnalys
//user //role
ListMultimap<List<String>, String> roleChunk = ArrayListMultimap.create();

handler.setSubTitle("Map Roles");
handler.enterNewStep("Map Roles");
handler.setOperationCountToProcess(roleMap.size());
for (String key : roleMap.keySet()) {
handler.iterateActualStatus();
Expand All @@ -357,7 +357,7 @@ public MiningOperationChunk preparePartialUserBasedStructure(@NotNull RoleAnalys

int memberCount = membersOidSet.size();

handler.setSubTitle("Prepare Role Structure");
handler.enterNewStep("Prepare Role Structure");
handler.setOperationCountToProcess(roleChunk.size());
for (List<String> key : roleChunk.keySet()) {
handler.iterateActualStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</label>
<div class="input-group d-flex login-panel-control">
<input wicket:id="username" name="username" type="text" class="form-control form-control-sm">
<div class="input-group-prepend">
<div class="input-group-append">
<span class="input-group-text">
<i class="fas fa-user"></i>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@

package com.evolveum.midpoint.common.mining.objects.handler;

import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

import org.jetbrains.annotations.Nullable;

import java.io.Serializable;
import java.time.Duration;

import static com.evolveum.midpoint.util.ClassPathUtil.LOGGER;

//TODO
/**
* Keeps the state of the role-mining activity (clustering, pattern detection, etc).
*
* TODO rename
*/
public class Handler implements Serializable {

private static final Trace LOGGER = TraceManager.getTrace(Handler.class);

private String title;
private String subTitle;
private int operationCountToProcess;
private boolean isActive;
private int actualStatus;
private int stepsCount;
private final int stepsCount;
private int currentStep;
private String objectId;
private final long startTime;
private long endTime;

/**
* Called when an external progress value (currently, for tasks) has to be incremented.
*
* TODO what about serializability? Currently we assume we'll never use deserialized version of this class isntance
*/
@Nullable private transient final Runnable progressIncrementer;

public int getPercentage() {
return percentage;
}
Expand All @@ -43,29 +59,37 @@ public String getDuration() {
}

public Handler(String title, int stepsCount) {
this(title, stepsCount, null);
}

public Handler(String title, int stepsCount, @Nullable Runnable progressIncrementer) {
this.startTime = System.currentTimeMillis();
this.endTime = System.currentTimeMillis();
this.title = title;
this.stepsCount = stepsCount;
this.isActive = true;
this.actualStatus = 0;
this.currentStep = 0;
this.progressIncrementer = progressIncrementer;
}

public void iterateActualStatus() {
this.actualStatus++;
this.endTime = System.currentTimeMillis();
this.percentage = (int) ((actualStatus / (double) operationCountToProcess) * 100);
print();
log();
}

public void setSubTitle(String subTitle) {
public void enterNewStep(String subTitle) {
if (progressIncrementer != null) {
progressIncrementer.run();
}
this.currentStep++;
this.operationCountToProcess = 0;
this.actualStatus = 0;
this.subTitle = subTitle;
this.percentage = 0;
print();
log();
}

@Override
Expand All @@ -76,12 +100,12 @@ public String toString() {
isActive, actualStatus, getObjectId(), getDuration());
}

public void print() {
String handler = String.format("Step{%d/%d} - Status{%s, subOperation='%s', percentage=%d processedCount=%d, "
+ "isActive=%b, actualStatus=%d} Object Id{%s} Duration{%s}",
public void log() {
LOGGER.debug(
"Step {}/{} - Status=[{}, subOperation='{}', percentage={} processedCount={}, "
+ "isActive={}, actualStatus={}] Object Id={} Duration={}",
currentStep, stepsCount, title, subTitle, percentage, operationCountToProcess, isActive,
actualStatus, getObjectId(), getDuration());
LOGGER.info(handler);
}

public void setOperationCountToProcess(int operationCountToProcess) {
Expand Down Expand Up @@ -127,8 +151,4 @@ public void setActualStatus(int actualStatus) {
public void setObjectId(String objectId) {
this.objectId = objectId;
}

public void setStepsCount(int stepsCount) {
this.stepsCount = stepsCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class JaccardSorter {
public static List<MiningUserTypeChunk> jaccardUserBasedSorter(List<MiningUserTypeChunk> dataPoints) {

Handler handler = new Handler("Jaccard Sort", 1);
handler.setSubTitle("Sorting");
handler.enterNewStep("Sorting");
handler.setActive(true);

List<MiningUserTypeChunk> sorted = new ArrayList<>();
Expand Down Expand Up @@ -97,7 +97,7 @@ > jacquardSimilarity(sorted.get(0).getRoles(),
public static List<MiningRoleTypeChunk> jaccardRoleBasedSorter(List<MiningRoleTypeChunk> dataPoints) {

Handler handler = new Handler("Jaccard Sort", 1);
handler.setSubTitle("Sorting");
handler.enterNewStep("Sorting");
handler.setActive(true);

List<MiningRoleTypeChunk> sorted = new ArrayList<>();
Expand Down

0 comments on commit eb25c00

Please sign in to comment.