Skip to content

Commit

Permalink
certification work items count label
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed May 29, 2017
1 parent f8dbeaa commit e7f5a4d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.common.SystemConfigurationHolder;
import com.evolveum.midpoint.gui.api.SubscriptionType;
import com.evolveum.midpoint.model.api.*;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.web.component.menu.*;
import com.evolveum.midpoint.web.page.admin.configuration.*;
import com.evolveum.midpoint.web.page.admin.reports.*;
Expand Down Expand Up @@ -96,8 +97,6 @@
import com.evolveum.midpoint.task.api.TaskManager;
import com.evolveum.midpoint.util.Holder;
import com.evolveum.midpoint.util.Producer;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -164,6 +163,7 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private static final String DOT_CLASS = PageBase.class.getName() + ".";
private static final String OPERATION_LOAD_USER = DOT_CLASS + "loadUser";
private static final String OPERATION_LOAD_WORK_ITEM_COUNT = DOT_CLASS + "loadWorkItemCount";
private static final String OPERATION_LOAD_CERT_WORK_ITEM_COUNT = DOT_CLASS + "loadCertificationWorkItemCount";

private static final String ID_TITLE = "title";
private static final String ID_MAIN_HEADER = "mainHeader";
Expand Down Expand Up @@ -264,6 +264,7 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private boolean initialized = false;

private LoadableModel<Integer> workItemCountModel;
private LoadableModel<Integer> certWorkItemCountModel;
private LoadableModel<DeploymentInformationType> deploymentInfoModel;

public PageBase(PageParameters parameters) {
Expand Down Expand Up @@ -315,6 +316,26 @@ protected Integer load() {
}
}
};
certWorkItemCountModel = new LoadableModel<Integer>() {
private static final long serialVersionUID = 1L;

@Override
protected Integer load() {
try {
AccessCertificationService acs = getCertificationService();
Task task = createSimpleTask(OPERATION_LOAD_CERT_WORK_ITEM_COUNT);
OperationResult result = task.getResult();
List<AccessCertificationWorkItemType> certWorkItems = acs.searchOpenWorkItems(new ObjectQuery(),
true, null, task, result);

return certWorkItems == null ? 0 : certWorkItems.size();
} catch (SchemaException|SecurityViolationException|ObjectNotFoundException
|ConfigurationException|CommunicationException e) {
LoggingUtils.logExceptionAsWarning(LOGGER, "Couldn't load certification work item count", e);
return null;
}
}
};
deploymentInfoModel = new LoadableModel<DeploymentInformationType>() {
private static final long serialVersionUID = 1L;

Expand All @@ -331,6 +352,12 @@ public void resetWorkItemCountModel() {
}
}

public void resetCertWorkItemCountModel() {
if (certWorkItemCountModel != null) {
certWorkItemCountModel.reset();
}
}

protected void createBreadcrumb() {
BreadcrumbPageClass bc = new BreadcrumbPageClass(new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -1261,7 +1288,19 @@ private MainMenuItem createReportsItems() {
private MainMenuItem createCertificationItems() {

MainMenuItem item = new MainMenuItem("fa fa-certificate",
createStringResource("PageAdmin.menu.top.certification"), null);
createStringResource("PageAdmin.menu.top.certification"), null){
private static final long serialVersionUID = 1L;

@Override
public String getBubbleLabel() {
Integer certWorkItemCount = certWorkItemCountModel.getObject();
if (certWorkItemCount == null || certWorkItemCount == 0) {
return null;
} else {
return certWorkItemCount.toString();
}
}
};

List<MenuItem> submenu = item.getItems();

Expand Down
Expand Up @@ -475,8 +475,8 @@ private void recordActionPerformed(AjaxRequestTarget target, CertWorkItemDto wor
if (!result.isSuccess()) {
showResult(result);
}
target.add(getFeedbackPanel());
target.add((Component) getDecisionsTable());
resetCertWorkItemCountModel();
target.add(this);
}

private void searchFilterPerformed(AjaxRequestTarget target) {
Expand Down

0 comments on commit e7f5a4d

Please sign in to comment.