Search in sources :

Example 36 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class AbstractLdapConnTest method test174SeachFirst222AccountsOffset20.

/**
	 * Blocksize is 100, so this gets more than two blocks.
	 * There is offset, so VLV should be used.
	 * No explicit sorting.
	 */
@Test
public void test174SeachFirst222AccountsOffset20() throws Exception {
    final String TEST_NAME = "test174SeachFirst222AccountsOffset20";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(getResourceOid(), getAccountObjectClass(), prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(20, 222);
    query.setPaging(paging);
    SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, 222, task, result);
    assertConnectorOperationIncrement(1, 223);
    assertConnectorSimulatedPagingSearchIncrement(0);
    SearchResultMetadata metadata = searchResultList.getMetadata();
    if (metadata != null) {
        assertFalse(metadata.isPartialResults());
    }
    assertLdapConnectorInstances(1, 2);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 37 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class ObjectDataProvider method internalIterator.

@Override
public Iterator<W> internalIterator(long first, long count) {
    LOGGER.trace("begin::iterator() from {} count {}.", new Object[] { first, count });
    for (W available : getAvailableData()) {
        if (available instanceof SelectableBean) {
            SelectableBean<T> selectableBean = (SelectableBean<T>) available;
            if (selectableBean.isSelected() && selectableBean.getValue() != null) {
                selected.add(selectableBean.getValue());
            }
        }
    }
    for (W available : getAvailableData()) {
        if (available instanceof SelectableBean) {
            SelectableBean<T> selectableBean = (SelectableBean<T>) available;
            if (!selectableBean.isSelected()) {
                if (selected.contains(selectableBean.getValue())) {
                    selected.remove(selectableBean.getValue());
                }
            }
        }
    }
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
    try {
        ObjectPaging paging = createPaging(first, count);
        Task task = getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Query {} with {}", type.getSimpleName(), query.debugDump());
        }
        List<PrismObject<T>> list = getModel().searchObjects(type, query, options, task, result);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Query {} resulted in {} objects", type.getSimpleName(), list.size());
        }
        for (PrismObject<T> object : list) {
            getAvailableData().add(createDataObjectWrapper(object));
        }
    } catch (Exception ex) {
        result.recordFatalError("Couldn't list objects.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't list objects", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        handleNotSuccessOrHandledErrorInIterator(result);
    }
    LOGGER.trace("end::iterator()");
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) Task(com.evolveum.midpoint.task.api.Task) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 38 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class RepositoryObjectDataProvider method internalIterator.

@Override
public Iterator<DebugObjectItem> internalIterator(long first, long count) {
    LOGGER.trace("begin::iterator() from {} count {}.", new Object[] { first, count });
    getAvailableData().clear();
    OperationResult result = new OperationResult(OPERATION_SEARCH_OBJECTS);
    try {
        ObjectPaging paging = createPaging(first, count);
        ObjectQuery query = getQuery();
        if (query == null) {
            query = new ObjectQuery();
        }
        query.setPaging(paging);
        //RAW and DEFAULT retrieve option selected
        Collection<SelectorOptions<GetOperationOptions>> options = new ArrayList<SelectorOptions<GetOperationOptions>>();
        GetOperationOptions opt = GetOperationOptions.createRaw();
        opt.setRetrieve(RetrieveOption.DEFAULT);
        options.add(SelectorOptions.create(ItemPath.EMPTY_PATH, opt));
        List<PrismObject<? extends ObjectType>> list = getModel().searchObjects((Class) type, query, options, getPage().createSimpleTask(OPERATION_SEARCH_OBJECTS), result);
        for (PrismObject<? extends ObjectType> object : list) {
            getAvailableData().add(createItem(object, result));
        }
    } catch (Exception ex) {
        result.recordFatalError("Couldn't list objects.", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    getPage().showResult(result, false);
    LOGGER.trace("end::iterator()");
    return getAvailableData().iterator();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 39 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class ObjectListPanel method initProvider.

protected BaseSortableDataProvider<SelectableBean<O>> initProvider() {
    Set<O> selectedObjectsSet = selectedObjects == null ? null : new HashSet<O>(selectedObjects);
    SelectableBeanObjectDataProvider<O> provider = new SelectableBeanObjectDataProvider<O>(parentPage, type, selectedObjectsSet) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            String storageKey = getStorageKey();
            if (StringUtils.isNotEmpty(storageKey)) {
                PageStorage storage = getPageStorage(storageKey);
                if (storage != null) {
                    storage.setPaging(paging);
                }
            }
        }

        @Override
        public SelectableBean<O> createDataObjectWrapper(O obj) {
            SelectableBean<O> bean = super.createDataObjectWrapper(obj);
            List<InlineMenuItem> inlineMenu = createInlineMenu();
            if (inlineMenu != null) {
                bean.getMenuItems().addAll(inlineMenu);
            }
            return bean;
        }
    };
    if (options == null) {
        if (ResourceType.class.equals(type)) {
            options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
        }
    } else {
        if (ResourceType.class.equals(type)) {
            GetOperationOptions root = SelectorOptions.findRootOptions(options);
            root.setNoFetch(Boolean.TRUE);
        }
        provider.setOptions(options);
    }
    provider.setQuery(getQuery());
    return provider;
}
Also used : SelectableBeanObjectDataProvider(com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) PageStorage(com.evolveum.midpoint.web.session.PageStorage)

Example 40 with ObjectPaging

use of com.evolveum.midpoint.prism.query.ObjectPaging in project midpoint by Evolveum.

the class PageDebugList method initLayout.

private void initLayout() {
    Form main = new Form(ID_MAIN_FORM);
    add(main);
    DebugSearchDto dto = searchModel.getObject();
    Class type = dto.getType().getClassDefinition();
    RepositoryObjectDataProvider provider = new RepositoryObjectDataProvider(this, type) {

        @Override
        protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
            ConfigurationStorage storage = getSessionStorage().getConfiguration();
            storage.setPaging(paging);
        }
    };
    DebugSearchDto search = searchModel.getObject();
    ObjectQuery query = search.getSearch().createObjectQuery(getPrismContext());
    provider.setQuery(createQuery(query));
    addOrReplaceTable(provider);
    PageDebugDownloadBehaviour ajaxDownloadBehavior = new PageDebugDownloadBehaviour();
    main.add(ajaxDownloadBehavior);
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) RepositoryObjectDataProvider(com.evolveum.midpoint.web.component.data.RepositoryObjectDataProvider) ConfigurationStorage(com.evolveum.midpoint.web.session.ConfigurationStorage) Form(org.apache.wicket.markup.html.form.Form) PageDebugDownloadBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.PageDebugDownloadBehaviour) DebugSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.DebugSearchDto) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)40 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)32 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)32 PrismObject (com.evolveum.midpoint.prism.PrismObject)28 Task (com.evolveum.midpoint.task.api.Task)28 Test (org.testng.annotations.Test)25 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)17 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)6 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)6 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)6 QName (javax.xml.namespace.QName)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)3 RelationalValueSearchQuery (com.evolveum.midpoint.schema.RelationalValueSearchQuery)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 LookupTableType (com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType)3 RestartResponseException (org.apache.wicket.RestartResponseException)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2