use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class PageAccount method loadAccount.
private ObjectWrapper<ShadowType> loadAccount(PageParameters parameters) {
Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT);
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(ShadowType.F_RESOURCE, GetOperationOptions.createResolve());
StringValue oid = parameters != null ? parameters.get(OnePageParameterEncoder.PARAMETER) : null;
PrismObject<ShadowType> account = WebModelServiceUtils.loadObject(ShadowType.class, oid.toString(), options, PageAccount.this, task, result);
if (account == null) {
getSession().error(getString("pageAccount.message.cantEditAccount"));
showResult(result);
throw new RestartResponseException(PageResources.class);
}
ObjectWrapper wrapper = ObjectWrapperUtil.createObjectWrapper(null, null, account, ContainerStatus.MODIFYING, task, this);
OperationResultType fetchResult = account.getPropertyRealValue(ShadowType.F_FETCH_RESULT, OperationResultType.class);
wrapper.setFetchResult(OperationResult.createOperationResult(fetchResult));
wrapper.setShowEmpty(false);
return wrapper;
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class ResourceContentRepositoryPanel method createTotalsModel.
private LoadableModel<Integer> createTotalsModel(final SynchronizationSituationType situation) {
return new LoadableModel<Integer>(false) {
private static final long serialVersionUID = 1L;
@Override
protected Integer load() {
ObjectFilter resourceFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_RESOURCE_REF).ref(ResourceContentRepositoryPanel.this.getResourceModel().getObject().getOid()).buildFilter();
if (resourceFilter == null) {
return 0;
}
ObjectFilter filter = createQuery().getFilter();
if (filter == null) {
return 0;
}
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
Task task = getPageBase().createSimpleTask(OPERATION_GET_TOTALS);
OperationResult result = new OperationResult(OPERATION_GET_TOTALS);
try {
ObjectFilter situationFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_SYNCHRONIZATION_SITUATION).eq(situation).buildFilter();
ObjectQuery query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filter, situationFilter));
return getPageBase().getModelService().countObjects(ShadowType.class, query, options, task, result);
} catch (CommonException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count shadows", ex);
}
return 0;
}
};
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class WebComponentUtil method getName.
public static <O extends ObjectType> String getName(ObjectReferenceType ref, PageBase pageBase, String operation) {
String name = getName(ref);
if (StringUtils.isEmpty(name) || name.equals(ref.getOid())) {
String oid = ref.getOid();
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
Class<O> type = (Class<O>) ObjectType.class;
PrismObject<O> object = WebModelServiceUtils.loadObject(type, oid, pageBase, pageBase.createSimpleTask(operation), new OperationResult(operation));
if (object != null) {
name = object.getName().getOrig();
}
}
return name;
}
use of com.evolveum.midpoint.schema.SelectorOptions in project midpoint by Evolveum.
the class CertWorkItemDtoProvider method internalIterator.
@Override
public Iterator<CertWorkItemDto> internalIterator(long first, long count) {
LOGGER.trace("begin::iterator() from {} count {}.", first, count);
getAvailableData().clear();
OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
try {
ObjectPaging paging = createPaging(first, count);
Task task = getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS);
ObjectQuery caseQuery = getQuery();
caseQuery = caseQuery != null ? caseQuery.clone() : new ObjectQuery();
caseQuery.setPaging(paging);
Collection<SelectorOptions<GetOperationOptions>> resolveNames = createCollection(createResolveNames());
AccessCertificationService acs = getPage().getCertificationService();
List<AccessCertificationWorkItemType> workitems = acs.searchOpenWorkItems(caseQuery, notDecidedOnly, resolveNames, task, result);
for (AccessCertificationWorkItemType workItem : workitems) {
getAvailableData().add(new CertWorkItemDto(workItem, getPage()));
}
} catch (Exception ex) {
result.recordFatalError("Couldn't list decisions.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list decisions", ex);
} finally {
result.computeStatusIfUnknown();
}
if (!WebComponentUtil.isSuccessOrHandledError(result)) {
handleNotSuccessOrHandledErrorInIterator(result);
}
LOGGER.trace("end::iterator()");
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.schema.SelectorOptions 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;
}
Aggregations