Search in sources :

Example 1 with PagingType

use of com.evolveum.prism.xml.ns._public.query_3.PagingType in project midpoint by Evolveum.

the class ExportAction method createQuery.

private QueryType createQuery(int from) throws IOException, SAXException, JAXBException {
    QueryType query = new QueryType();
    query.setFilter(loadQuery());
    PagingType paging = new PagingType();
    paging.setOffset(from);
    paging.setMaxSize(SEARCH_PAGE_SIZE);
    paging.setOrderBy(ModelClientUtil.createItemPathType("name"));
    paging.setOrderDirection(OrderDirectionType.ASCENDING);
    query.setPaging(paging);
    return query;
}
Also used : PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Example 2 with PagingType

use of com.evolveum.prism.xml.ns._public.query_3.PagingType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method listUsers.

protected Collection<UserType> listUsers() throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // let's say we want to get first 3 users, sorted alphabetically by user name
    // holds search query + paging options
    QueryType queryType = new QueryType();
    PagingType pagingType = new PagingType();
    pagingType.setMaxSize(3);
    pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
    pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
    queryType.setPaging(pagingType);
    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) Collection(java.util.Collection) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 3 with PagingType

use of com.evolveum.prism.xml.ns._public.query_3.PagingType in project midpoint by Evolveum.

the class Main method listUsers.

private static Collection<UserType> listUsers(ModelPortType modelPort) throws SAXException, IOException, FaultMessage {
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // let's say we want to get first 3 users, sorted alphabetically by user name
    // holds search query + paging options
    QueryType queryType = new QueryType();
    PagingType pagingType = new PagingType();
    pagingType.setMaxSize(3);
    pagingType.setOrderBy(ModelClientUtil.createItemPathType("name"));
    pagingType.setOrderDirection(OrderDirectionType.ASCENDING);
    queryType.setPaging(pagingType);
    modelPort.searchObjects(ModelClientUtil.getTypeQName(UserType.class), queryType, options, objectListHolder, resultHolder);
    ObjectListType objectList = objectListHolder.value;
    return (Collection) objectList.getObject();
}
Also used : OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) Collection(java.util.Collection) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 4 with PagingType

use of com.evolveum.prism.xml.ns._public.query_3.PagingType in project midpoint by Evolveum.

the class ModelInteractionServiceImpl method checkOrdering.

private ObjectQuery checkOrdering(ObjectQuery query, ItemPath defaultOrderBy) {
    if (query != null) {
        if (query.getPaging() == null) {
            ObjectPaging paging = ObjectQueryUtil.convertToObjectPaging(new PagingType(), prismContext);
            paging.setOrdering(defaultOrderBy, OrderDirection.ASCENDING);
            query.setPaging(paging);
        } else if (query.getPaging().getPrimaryOrderingPath() == null) {
            query.getPaging().setOrdering(defaultOrderBy, OrderDirection.ASCENDING);
        }
        return query;
    } else {
        return prismContext.queryFactory().createQuery(prismContext.queryFactory().createPaging(defaultOrderBy, OrderDirection.ASCENDING));
    }
}
Also used : ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType)

Example 5 with PagingType

use of com.evolveum.prism.xml.ns._public.query_3.PagingType in project midpoint by Evolveum.

the class ModelWebServiceTest method badPagingSearch.

@Test(expectedExceptions = FaultMessage.class)
public void badPagingSearch() throws FaultMessage, SchemaException, IOException, JAXBException {
    PagingType paging = new PagingType();
    paging.setMaxSize(-1);
    paging.setOffset(-1);
    final UserType expectedUser = (UserType) PrismTestUtil.parseObject(new File(TEST_FOLDER_CONTROLLER, "./addObject/add-user-without-name.xml")).asObjectable();
    setSecurityContext(expectedUser);
    try {
        QueryType queryType = new QueryType();
        queryType.setPaging(paging);
        modelService.searchObjects(UserType.COMPLEX_TYPE, queryType, null, new Holder<ObjectListType>(), new Holder<OperationResultType>());
    } catch (FaultMessage ex) {
        ModelTUtil.assertIllegalArgumentFault(ex);
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
    Assert.fail("Illegal argument exception was not thrown.");
}
Also used : FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) PagingType(com.evolveum.prism.xml.ns._public.query_3.PagingType) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) File(java.io.File) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Aggregations

PagingType (com.evolveum.prism.xml.ns._public.query_3.PagingType)10 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)6 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)3 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)3 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 Test (org.testng.annotations.Test)3 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)2 Collection (java.util.Collection)2 Holder (javax.xml.ws.Holder)2 ItemName (com.evolveum.midpoint.prism.path.ItemName)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1 AbstractUnitTest (com.evolveum.midpoint.tools.testng.AbstractUnitTest)1 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)1 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)1 File (java.io.File)1 SortParam (org.apache.wicket.extensions.markup.html.repeater.util.SortParam)1 SortableDataProvider (org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider)1