use of com.evolveum.midpoint.web.component.box.InfoBoxPanel in project midpoint by Evolveum.
the class PageDashboard method createTaskInfoBoxPanel.
private Component createTaskInfoBoxPanel(OperationResult result, Task task) {
InfoBoxType infoBoxType = new InfoBoxType("object-task-bg", GuiStyleConstants.CLASS_OBJECT_TASK_ICON, getString("PageDashboard.infobox.tasks.label"));
Integer totalCount;
try {
totalCount = getModelService().countObjects(TaskType.class, null, null, task, result);
if (totalCount == null) {
totalCount = 0;
}
ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_EXECUTION_STATUS).eq(TaskExecutionStatusType.RUNNABLE).build();
Integer activeCount = getModelService().countObjects(TaskType.class, query, null, task, result);
if (activeCount == null) {
activeCount = 0;
}
infoBoxType.setNumber(activeCount + " " + getString("PageDashboard.infobox.tasks.number"));
int progress = 0;
if (totalCount != 0) {
progress = activeCount * 100 / totalCount;
}
infoBoxType.setProgress(progress);
infoBoxType.setDescription(totalCount + " " + getString("PageDashboard.infobox.tasks.total"));
} catch (Exception e) {
infoBoxType.setNumber("ERROR: " + e.getMessage());
}
Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
return new InfoBoxPanel(ID_INFO_BOX_TASKS, boxModel, PageTasks.class);
}
Aggregations