Skip to content

Commit

Permalink
Implemented detailed task state display. Work in progress.
Browse files Browse the repository at this point in the history
Fixed prism parsing bug (COMPAT mode).
  • Loading branch information
mederly committed Sep 17, 2015
1 parent bc23a83 commit 5dbcd00
Show file tree
Hide file tree
Showing 45 changed files with 2,870 additions and 490 deletions.
Expand Up @@ -19,6 +19,9 @@
import com.evolveum.midpoint.schema.statistics.GenericStatisticsData;
import com.evolveum.midpoint.schema.statistics.MappingsStatisticsKey;
import com.evolveum.midpoint.schema.statistics.OperationalInformation;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingsStatisticsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.MappingsStatisticsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalInformationType;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
Expand All @@ -39,12 +42,20 @@ public class MappingsLineDto {

private String object;
private int count;
private Integer minTime;
private Integer maxTime;
private int totalTime;

public MappingsLineDto(String object) {
this.object = object;
private Long minTime;
private Long maxTime;
private long totalTime;

// public MappingsLineDto(String object) {
// this.object = object;
// }

public MappingsLineDto(MappingsStatisticsEntryType entry) {
object = entry.getObject();
count = entry.getCount();
minTime = entry.getMinTime();
maxTime = entry.getMaxTime();
totalTime = entry.getTotalTime();
}

public String getObject() {
Expand All @@ -55,64 +66,60 @@ public int getCount() {
return count;
}

public int getAverageTime() {
public Long getAverageTime() {
if (count > 0) {
return totalTime / count;
} else {
return 0;
return null;
}
}

public int getMinTime() {
return minTime != null ? minTime : 0;
public Long getMinTime() {
return minTime;
}

public int getMaxTime() {
return maxTime != null ? maxTime : 0;
public Long getMaxTime() {
return maxTime;
}

public int getTotalTime() {
public long getTotalTime() {
return totalTime;
}

public static List<MappingsLineDto> extractFromOperationalInformation(OperationalInformation operationalInformation) {
OperationalInformationType operationalInformationType = operationalInformation.getAggregatedValue();
MappingsStatisticsType mappingsStatisticsType = operationalInformationType.getMappingsStatistics();
return extractFromOperationalInformation(mappingsStatisticsType);
}

protected static List<MappingsLineDto> extractFromOperationalInformation(MappingsStatisticsType mappingsStatisticsType) {
List<MappingsLineDto> retval = new ArrayList<>();
Map<MappingsStatisticsKey, GenericStatisticsData> dataMap = operationalInformation.getMappingsData();
if (dataMap == null) {
if (mappingsStatisticsType == null) {
return retval;
}
// this is much more generic that needs to be - but useful for future, maybe
for (Map.Entry<MappingsStatisticsKey, GenericStatisticsData> entry : dataMap.entrySet()) {
MappingsStatisticsKey key = entry.getKey();
String object = key.getObjectName() != null ? key.getObjectName() : key.getObjectOid();
MappingsLineDto lineDto = findLineDto(retval, object);
if (lineDto == null) {
lineDto = new MappingsLineDto(object);
retval.add(lineDto);
}
lineDto.setValue(entry.getValue().getCount(), entry.getValue().getMinDuration(),
entry.getValue().getMaxDuration(), entry.getValue().getTotalDuration());
for (MappingsStatisticsEntryType entry : mappingsStatisticsType.getEntry()) {
retval.add(new MappingsLineDto(entry));
}
return retval;
}

private static MappingsLineDto findLineDto(List<MappingsLineDto> list, String object) {
for (MappingsLineDto lineDto : list) {
if (StringUtils.equals(lineDto.getObject(), object)) {
return lineDto;
}
}
return null;
}

private void setValue(int count, int min, int max, long totalDuration) {
this.count += count;
if (minTime == null || min < minTime) {
minTime = min;
}
if (maxTime == null || max > maxTime) {
maxTime = max;
}
totalTime += totalDuration;
}
// private static MappingsLineDto findLineDto(List<MappingsLineDto> list, String object) {
// for (MappingsLineDto lineDto : list) {
// if (StringUtils.equals(lineDto.getObject(), object)) {
// return lineDto;
// }
// }
// return null;
// }
//
// private void setValue(int count, int min, int max, long totalDuration) {
// this.count += count;
// if (minTime == null || min < minTime) {
// minTime = min;
// }
// if (maxTime == null || max > maxTime) {
// maxTime = max;
// }
// totalTime += totalDuration;
// }
}
Expand Up @@ -19,6 +19,9 @@
import com.evolveum.midpoint.schema.statistics.GenericStatisticsData;
import com.evolveum.midpoint.schema.statistics.NotificationsStatisticsKey;
import com.evolveum.midpoint.schema.statistics.OperationalInformation;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationsStatisticsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.NotificationsStatisticsType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationalInformationType;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
Expand All @@ -41,14 +44,32 @@ public class NotificationsLineDto {
private String transport;
private int countSuccess;
private int countFailure;
private Integer minTime;
private Integer maxTime;
private int totalTime;
private Long minTime;
private Long maxTime;
private long totalTime;

public NotificationsLineDto(String transport) {
this.transport = transport;
}

public NotificationsLineDto(NotificationsStatisticsEntryType entry) {
transport = entry.getTransport();
countSuccess = entry.getCountSuccess();
countFailure = entry.getCountFailure();
minTime = entry.getMinTime();
maxTime = entry.getMaxTime();
totalTime = entry.getTotalTime();
}

public Long getAverageTime() {
int count = countSuccess + countFailure;
if (count > 0) {
return totalTime / count;
} else {
return null;
}
}

public String getTransport() {
return transport;
}
Expand All @@ -61,68 +82,57 @@ public int getCountFailure() {
return countFailure;
}

public int getAverageTime() {
int count = countSuccess + countFailure;
if (count > 0) {
return totalTime / count;
} else {
return 0;
}
public Long getMinTime() {
return minTime;
}

public int getMinTime() {
return minTime != null ? minTime : 0;
public Long getMaxTime() {
return maxTime;
}

public int getMaxTime() {
return maxTime != null ? maxTime : 0;
}

public int getTotalTime() {
public long getTotalTime() {
return totalTime;
}

public static List<NotificationsLineDto> extractFromOperationalInformation(OperationalInformation operationalInformation) {
OperationalInformationType operationalInformationType = operationalInformation.getAggregatedValue();
NotificationsStatisticsType notificationsStatisticsType = operationalInformationType.getNotificationsStatistics();
return extractFromOperationalInformation(notificationsStatisticsType);
}

protected static List<NotificationsLineDto> extractFromOperationalInformation(NotificationsStatisticsType notificationsStatisticsType) {
List<NotificationsLineDto> retval = new ArrayList<>();
Map<NotificationsStatisticsKey, GenericStatisticsData> dataMap = operationalInformation.getNotificationsData();
if (dataMap == null) {
if (notificationsStatisticsType == null) {
return retval;
}
for (Map.Entry<NotificationsStatisticsKey, GenericStatisticsData> entry : dataMap.entrySet()) {
NotificationsStatisticsKey key = entry.getKey();
String transport = key.getTransport();
NotificationsLineDto lineDto = findLineDto(retval, transport);
if (lineDto == null) {
lineDto = new NotificationsLineDto(transport);
retval.add(lineDto);
}
lineDto.setValue(key.isSuccess(), entry.getValue().getCount(), entry.getValue().getMinDuration(),
entry.getValue().getMaxDuration(), entry.getValue().getTotalDuration());
}
return retval;
}

private static NotificationsLineDto findLineDto(List<NotificationsLineDto> list, String transport) {
for (NotificationsLineDto lineDto : list) {
if (StringUtils.equals(lineDto.getTransport(), transport)) {
return lineDto;
}
for (NotificationsStatisticsEntryType entry : notificationsStatisticsType.getEntry()) {
retval.add(new NotificationsLineDto(entry));
}
return null;
return retval;
}

private void setValue(boolean success, int count, int min, int max, long totalDuration) {
if (success) {
this.countSuccess += count;
} else {
this.countFailure += count;
}
if (minTime == null || min < minTime) {
minTime = min;
}
if (maxTime == null || max > maxTime) {
maxTime = max;
}
totalTime += totalDuration;
}
// private static NotificationsLineDto findLineDto(List<NotificationsLineDto> list, String transport) {
// for (NotificationsLineDto lineDto : list) {
// if (StringUtils.equals(lineDto.getTransport(), transport)) {
// return lineDto;
// }
// }
// return null;
// }
//
// private void setValue(boolean success, int count, long min, long max, long totalDuration) {
// if (success) {
// this.countSuccess += count;
// } else {
// this.countFailure += count;
// }
// if (minTime == null || min < minTime) {
// minTime = min;
// }
// if (maxTime == null || max > maxTime) {
// maxTime = max;
// }
// totalTime += totalDuration;
// }
}
Expand Up @@ -29,7 +29,6 @@ public class ProgressDto implements Serializable {

private List<ProgressReportActivityDto> progressReportActivities = new ArrayList<>();
private List<String> logItems = new ArrayList<>();
private List<StatusMessage> logEntries = new ArrayList<>();

public List<ProgressReportActivityDto> getProgressReportActivities() {
return progressReportActivities;
Expand Down Expand Up @@ -69,7 +68,4 @@ public boolean allSuccess() {
return true;
}

public List<StatusMessage> getLogEntries() {
return logEntries;
}
}
Expand Up @@ -54,7 +54,6 @@ public class ProgressPanel extends SimplePanel<ProgressDto> {

private WebMarkupContainer contentsPanel;
private StatisticsPanel statisticsPanel;
private transient Task task;

public ProgressPanel(String id) {
super(id);
Expand Down Expand Up @@ -160,7 +159,7 @@ private Label createImageLabel(String id, IModel<String> cssClass, IModel<String
};
contentsPanel.add(statusItemsListView);

statisticsPanel = new StatisticsPanel(ID_STATISTICS, task);
statisticsPanel = new StatisticsPanel(ID_STATISTICS, new StatisticsDtoModel());
contentsPanel.add(statisticsPanel);

ListView logItemsListView = new ListView(ID_LOG_ITEMS, new AbstractReadOnlyModel<List>() {
Expand Down Expand Up @@ -212,13 +211,14 @@ public void recordExecutionStop() {
}

public void setTask(Task task) {
this.task = task;
if (statisticsPanel != null) {
statisticsPanel.setTask(task);
if (statisticsPanel != null && statisticsPanel.getModel() instanceof StatisticsDtoModel) {
((StatisticsDtoModel) statisticsPanel.getModel()).setTask(task);
}
}

public Task getTask() {
return task;
public void invalidateCache() {
if (statisticsPanel != null && statisticsPanel.getModel() instanceof StatisticsDtoModel) {
((StatisticsDtoModel) (statisticsPanel.getModel())).invalidateCache();
}
}
}
Expand Up @@ -224,6 +224,9 @@ private void startRefreshingProgressPanel(AjaxRequestTarget target) {
@Override
protected void onPostProcessTarget(AjaxRequestTarget target) {
super.onPostProcessTarget(target);
if (progressPanel != null) {
progressPanel.invalidateCache();
}
if (asyncOperationResult != null) { // by checking this we know that async operation has been finished
asyncOperationResult.recomputeStatus(); // because we set it to in-progress

Expand Down

0 comments on commit 5dbcd00

Please sign in to comment.