Search in sources :

Example 26 with ObjectPaging

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

the class TestOpenDj method test230SearchObjectsPagedNoOffset.

@Test
public void test230SearchObjectsPagedNoOffset() throws Exception {
    final String TEST_NAME = "test230SearchObjectsPagedNoOffset";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(null, 3);
    query.setPaging(paging);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    assertSuccess(result);
    display("Search resutls", searchResults);
    assertSearchResults(searchResults, "cook", "drake", "hbarbossa");
    assertConnectorOperationIncrement(1, 7);
    assertConnectorSimulatedPagingSearchIncrement(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 27 with ObjectPaging

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

the class TestOpenDj method test232SearchObjectsPagedOffset.

@Test
public void test232SearchObjectsPagedOffset() throws Exception {
    final String TEST_NAME = "test232SearchObjectsPagedOffset";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(2, 5);
    query.setPaging(paging);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    SearchResultList<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    assertSuccess(result);
    display("Search resutls", searchResults);
    // The results should be this:
    assertSearchResults(searchResults, "hbarbossa", "idm", "jbeckett", "jbond", "jgibbs");
    assertConnectorOperationIncrement(1, 11);
    assertConnectorSimulatedPagingSearchIncrement(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Example 28 with ObjectPaging

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

the class TestOpenDj method test233SearchObjectsPagedNoOffsetSortSn.

@Test
public void test233SearchObjectsPagedNoOffsetSortSn() throws Exception {
    final String TEST_NAME = "test233SearchObjectsPagedNoOffsetSortSn";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_ALL_ACCOUNTS_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    ObjectPaging paging = ObjectPaging.createPaging(null, 4);
    paging.setOrdering(ObjectOrdering.createOrdering(new ItemPath(ShadowType.F_ATTRIBUTES, new QName(RESOURCE_NS, "sn")), OrderDirection.ASCENDING));
    query.setPaging(paging);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    List<PrismObject<ShadowType>> searchResults = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    assertSuccess(result);
    display("Search resutls", searchResults);
    assertSearchResults(searchResults, "monk", "hbarbossa", "jbeckett", "jbond");
    assertConnectorOperationIncrement(1, 9);
    assertConnectorSimulatedPagingSearchIncrement(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 29 with ObjectPaging

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

the class ObjectRetriever method searchObjectsIterativeByPaging.

public <T extends ObjectType> void searchObjectsIterativeByPaging(Class<T> type, ObjectQuery query, ResultHandler<T> handler, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
    try {
        ObjectQuery pagedQuery = query != null ? query.clone() : new ObjectQuery();
        int offset;
        int remaining;
        final int batchSize = getConfiguration().getIterativeSearchByPagingBatchSize();
        ObjectPaging paging = pagedQuery.getPaging();
        if (paging == null) {
            // counts will be filled-in later
            paging = ObjectPaging.createPaging(0, 0);
            pagedQuery.setPaging(paging);
            offset = 0;
            remaining = repositoryService.countObjects(type, query, result);
        } else {
            offset = paging.getOffset() != null ? paging.getOffset() : 0;
            remaining = paging.getMaxSize() != null ? paging.getMaxSize() : repositoryService.countObjects(type, query, result) - offset;
        }
        main: while (remaining > 0) {
            paging.setOffset(offset);
            paging.setMaxSize(remaining < batchSize ? remaining : batchSize);
            List<PrismObject<T>> objects = repositoryService.searchObjects(type, pagedQuery, options, result);
            for (PrismObject<T> object : objects) {
                if (!handler.handle(object, result)) {
                    break main;
                }
            }
            if (objects.size() == 0) {
                // should not occur, but let's check for this to avoid endless loops
                break;
            }
            offset += objects.size();
            remaining -= objects.size();
        }
    } finally {
        if (result != null && result.isUnknown()) {
            result.computeStatus();
        }
        result.setSummarizeSuccesses(true);
        result.summarize();
    }
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 30 with ObjectPaging

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

the class AbstractLdapConnTest method test158SeachBeyondEnd.

/**
	 * Make a search that goes beyond the end of the list of all accounts.
	 */
@Test
public void test158SeachBeyondEnd() throws Exception {
    final String TEST_NAME = "test158SeachBeyondEnd";
    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.createEmptyPaging();
    paging.setOffset(getNumberOfAllAccounts() + 50);
    paging.setMaxSize(123);
    query.setPaging(paging);
    int expectedEntries = 0;
    if (isVlvSearchBeyondEndResurnsLastEntry()) {
        expectedEntries = 1;
    }
    SearchResultList<PrismObject<ShadowType>> searchResultList = doSearch(TEST_NAME, query, expectedEntries, task, result);
    //		Fails for 389ds tests. For some unknown reason. And this is not that important. There are similar asserts in other tests that are passing.
    //        assertConnectorOperationIncrement(1);
    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)

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