use of com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult in project midpoint by Evolveum.
the class PageSelfDashboard method loadWorkItems.
private CallableResult<List<WorkItemDto>> loadWorkItems() {
LOGGER.debug("Loading work items.");
AccountCallableResult callableResult = new AccountCallableResult();
List<WorkItemDto> list = new ArrayList<>();
callableResult.setValue(list);
if (!getWorkflowManager().isEnabled()) {
return callableResult;
}
PrismObject<UserType> user = principalModel.getObject();
if (user == null) {
return callableResult;
}
Task task = createSimpleTask(OPERATION_LOAD_WORK_ITEMS);
OperationResult result = task.getResult();
callableResult.setResult(result);
try {
ObjectQuery query = QueryBuilder.queryFor(WorkItemType.class, getPrismContext()).item(WorkItemType.F_ASSIGNEE_REF).ref(user.getOid()).desc(F_CREATE_TIMESTAMP).build();
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF), new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
List<WorkItemType> workItems = getModelService().searchContainers(WorkItemType.class, query, options, task, result);
for (WorkItemType workItem : workItems) {
list.add(new WorkItemDto(workItem));
}
} catch (Exception e) {
result.recordFatalError("Couldn't get list of work items.", e);
}
result.recordSuccessIfUnknown();
result.recomputeStatus();
LOGGER.debug("Finished work items loading.");
return callableResult;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult in project midpoint by Evolveum.
the class PageSelfDashboard method initMyAccounts.
private void initMyAccounts() {
AsyncDashboardPanel<Object, List<SimpleAccountDto>> accounts = new AsyncDashboardPanel<Object, List<SimpleAccountDto>>(ID_ACCOUNTS, createStringResource("PageDashboard.accounts"), GuiStyleConstants.CLASS_SHADOW_ICON_ACCOUNT, GuiStyleConstants.CLASS_OBJECT_SHADOW_BOX_CSS_CLASSES, true) {
private static final long serialVersionUID = 1L;
@Override
protected SecurityContextAwareCallable<CallableResult<List<SimpleAccountDto>>> createCallable(Authentication auth, IModel<Object> callableParameterModel) {
return new SecurityContextAwareCallable<CallableResult<List<SimpleAccountDto>>>(getSecurityEnforcer(), auth) {
@Override
public AccountCallableResult<List<SimpleAccountDto>> callWithContextPrepared() throws Exception {
return loadAccounts();
}
};
}
@Override
protected Component getMainComponent(String markupId) {
return new MyAccountsPanel(markupId, new PropertyModel<List<SimpleAccountDto>>(getModel(), CallableResult.F_VALUE));
}
@Override
protected void onPostSuccess(AjaxRequestTarget target) {
showFetchResult();
super.onPostSuccess(target);
}
@Override
protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
showFetchResult();
super.onUpdateError(target, ex);
}
private void showFetchResult() {
AccountCallableResult<List<SimpleAccountDto>> result = (AccountCallableResult<List<SimpleAccountDto>>) getModel().getObject();
PageBase page = (PageBase) getPage();
for (OperationResult res : result.getFetchResults()) {
if (!WebComponentUtil.isSuccessOrHandledError(res)) {
page.showResult(res);
}
}
}
};
accounts.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_ACCOUNTS);
return WebComponentUtil.getElementVisibility(visibilityType);
}
});
add(accounts);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult in project midpoint by Evolveum.
the class PageSelfDashboard method loadMyRequests.
private CallableResult<List<ProcessInstanceDto>> loadMyRequests() {
LOGGER.debug("Loading requests.");
AccountCallableResult<List<ProcessInstanceDto>> callableResult = new AccountCallableResult<>();
List<ProcessInstanceDto> list = new ArrayList<ProcessInstanceDto>();
callableResult.setValue(list);
if (!getWorkflowManager().isEnabled()) {
return callableResult;
}
ProcessInstanceDtoProvider provider = new ProcessInstanceDtoProvider(this, true, false);
provider.iterator(0, Integer.MAX_VALUE);
callableResult.setValue(provider.getAvailableData());
LOGGER.debug("Finished requests loading.");
return callableResult;
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult in project midpoint by Evolveum.
the class PageSelfDashboard method initMyAccounts.
private void initMyAccounts(Session session) {
AsyncDashboardPanel<Object, List<SimpleAccountDto>> accounts = new AsyncDashboardPanel<>(ID_ACCOUNTS, createStringResource("PageDashboard.accounts"), GuiStyleConstants.CLASS_SHADOW_ICON_ACCOUNT, GuiStyleConstants.CLASS_OBJECT_SHADOW_BOX_CSS_CLASSES, true) {
private static final long serialVersionUID = 1L;
@Override
protected SecurityContextAwareCallable<CallableResult<List<SimpleAccountDto>>> createCallable(Authentication auth, IModel<Object> callableParameterModel) {
return new SecurityContextAwareCallable<>(getSecurityContextManager(), auth) {
@Override
public AccountCallableResult<List<SimpleAccountDto>> callWithContextPrepared() {
// TODO is this correct? [med]
setupContext(application, session);
return loadAccounts();
}
};
}
@Override
protected Component getMainComponent(String markupId) {
return new MyAccountsPanel(markupId, new PropertyModel<>(getModel(), CallableResult.F_VALUE));
}
@Override
protected void onPostSuccess(AjaxRequestTarget target) {
showFetchResult();
super.onPostSuccess(target);
}
@Override
protected void onUpdateError(AjaxRequestTarget target, Exception ex) {
showFetchResult();
super.onUpdateError(target, ex);
}
private void showFetchResult() {
AccountCallableResult<List<SimpleAccountDto>> result = (AccountCallableResult<List<SimpleAccountDto>>) getModel().getObject();
PageBase page = (PageBase) getPage();
for (OperationResult res : result.getFetchResults()) {
if (!WebComponentUtil.isSuccessOrHandledError(res)) {
page.showResult(res);
}
}
}
};
accounts.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_ACCOUNTS);
return WebComponentUtil.getElementVisibility(visibilityType);
}
});
add(accounts);
}
use of com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult in project midpoint by Evolveum.
the class PageSelfDashboard method loadAccounts.
private AccountCallableResult<List<SimpleAccountDto>> loadAccounts() {
LOGGER.debug("Loading accounts.");
AccountCallableResult callableResult = new AccountCallableResult();
List<SimpleAccountDto> list = new ArrayList<>();
callableResult.setValue(list);
FocusType focus = AuthUtil.getPrincipalUser().getFocus();
Task task = createSimpleTask(OPERATION_LOAD_ACCOUNTS);
OperationResult result = task.getResult();
callableResult.setResult(result);
Collection<SelectorOptions<GetOperationOptions>> options = getOperationOptionsBuilder().root().resolveNames().noFetch().item(ShadowType.F_RESOURCE_REF).resolve().noFetch().build();
List<ObjectReferenceType> references = focus.getLinkRef();
for (ObjectReferenceType reference : references) {
PrismObject<ShadowType> account = WebModelServiceUtils.loadObject(ShadowType.class, reference.getOid(), options, this, task, result);
if (account == null) {
continue;
}
ShadowType accountType = account.asObjectable();
OperationResultType fetchResult = accountType.getFetchResult();
if (fetchResult != null) {
callableResult.getFetchResults().add(OperationResult.createOperationResult(fetchResult));
}
String resourceName = WebComponentUtil.getName(accountType.getResourceRef());
list.add(new SimpleAccountDto(WebComponentUtil.getOrigStringFromPoly(accountType.getName()), resourceName));
}
result.recordSuccessIfUnknown();
result.recomputeStatus();
LOGGER.debug("Finished accounts loading.");
return callableResult;
}
Aggregations