-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/master'
- Loading branch information
Showing
58 changed files
with
703 additions
and
656 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...in/java/com/evolveum/midpoint/schema/statistics/ActivityProgressAndStatisticsPrinter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2010-2021 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.schema.statistics; | ||
|
||
import com.evolveum.midpoint.schema.util.task.ActivityPath; | ||
import com.evolveum.midpoint.schema.util.task.ActivityProgressUtil; | ||
import com.evolveum.midpoint.schema.util.task.ActivityTreeUtil; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivityStateType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** TODO better name */ | ||
public class ActivityProgressAndStatisticsPrinter { | ||
|
||
/** | ||
* Prints all relevant statistics (including progress) for all activities in the given task. | ||
*/ | ||
public static String print(@NotNull TaskType task) { | ||
StringBuilder sb = new StringBuilder(); | ||
ActivityTreeUtil.processLocalStates(task, (path, state) -> print(sb, path, state)); | ||
return sb.toString(); | ||
} | ||
|
||
private static void print(StringBuilder sb, @NotNull ActivityPath path, @NotNull ActivityStateType activityState) { | ||
sb.append("Activity: ") | ||
.append(path.toDebugName()) | ||
.append("\n\n"); | ||
|
||
if (activityState.getProgress() != null) { | ||
sb.append("Progress:\n\n"); | ||
sb.append(ActivityProgressUtil.format(activityState.getProgress())); | ||
sb.append("\n"); | ||
} | ||
|
||
sb.append(ActivityStatisticsUtil.format(activityState.getStatistics())); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...schema/src/main/java/com/evolveum/midpoint/schema/statistics/ActivityProgressPrinter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2020 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.schema.statistics; | ||
|
||
import com.evolveum.midpoint.prism.path.ItemName; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static com.evolveum.midpoint.schema.statistics.Formatting.Alignment.LEFT; | ||
import static com.evolveum.midpoint.schema.statistics.Formatting.Alignment.RIGHT; | ||
|
||
/** | ||
* Prints activity progress information. | ||
* | ||
* Does not support sorting by time, as this is not relevant for activity progress. | ||
* Also does not support sorting by counters. This could be done in the future. | ||
* Also does not support expected totals (yet). It does not fit into the table. | ||
*/ | ||
public class ActivityProgressPrinter extends AbstractStatisticsPrinter<ActivityProgressType> { | ||
|
||
public ActivityProgressPrinter(@NotNull ActivityProgressType information, Options options) { | ||
super(information, options, null, null); | ||
} | ||
|
||
@Override | ||
public void prepare() { | ||
createData(); | ||
createFormatting(); | ||
} | ||
|
||
private void createData() { | ||
initData(); | ||
createData(information); | ||
} | ||
|
||
private void createData(@NotNull ActivityProgressType component) { | ||
addData(ActivityProgressType.F_UNCOMMITTED, component.getUncommitted()); | ||
addData(ActivityProgressType.F_COMMITTED, component.getCommitted()); | ||
} | ||
|
||
private void addData(@NotNull ItemName state, @NotNull List<OutcomeKeyedCounterType> counters) { | ||
|
||
List<OutcomeKeyedCounterType> sortedCounters = new ArrayList<>(counters); | ||
sortedCounters.sort(OutcomeKeyedCounterTypeUtil.createOutcomeKeyedCounterComparator()); | ||
|
||
for (OutcomeKeyedCounterType counter : sortedCounters) { | ||
Data.Record record = data.createRecord(); | ||
record.add(state.getLocalPart()); | ||
record.add(OutcomeKeyedCounterTypeUtil.getOutcome(counter)); | ||
record.add(OutcomeKeyedCounterTypeUtil.getOutcomeQualifierUri(counter)); | ||
record.add(counter.getCount()); | ||
} | ||
} | ||
|
||
private void createFormatting() { | ||
initFormatting(); | ||
addColumn("State", LEFT, formatString()); | ||
addColumn("Outcome", LEFT, formatString()); | ||
addColumn("Qualifier", LEFT, formatString()); | ||
addColumn("Count", RIGHT, formatInt()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.