Search in sources :

Example 21 with SelectorOptions

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) RestartResponseException(org.apache.wicket.RestartResponseException) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) StringValue(org.apache.wicket.util.string.StringValue)

Example 22 with SelectorOptions

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;
        }
    };
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 23 with SelectorOptions

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;
}
Also used : SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString)

Example 24 with SelectorOptions

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();
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) AccessCertificationService(com.evolveum.midpoint.model.api.AccessCertificationService) RestartResponseException(org.apache.wicket.RestartResponseException) AccessCertificationWorkItemType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType)

Example 25 with SelectorOptions

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) WorkItemDto(com.evolveum.midpoint.web.page.admin.workflow.dto.WorkItemDto) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)127 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)106 Task (com.evolveum.midpoint.task.api.Task)82 Test (org.testng.annotations.Test)47 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)34 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)31 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)31 PrismObject (com.evolveum.midpoint.prism.PrismObject)28 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)28 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)23 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)21 ArrayList (java.util.ArrayList)19 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 QName (javax.xml.namespace.QName)17 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)16 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)16 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)14 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)14 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)12