Search in sources :

Example 16 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class PageRepositoryQuery method updateRequestWithMidpointQuery.

private void updateRequestWithMidpointQuery(RepositoryQueryDiagRequest request, QName objectType, String queryText, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
    PrismContext prismContext = getPrismContext();
    if (objectType == null) {
        objectType = ObjectType.COMPLEX_TYPE;
    }
    @SuppressWarnings("unchecked") Class<? extends ObjectType> clazz = (Class<? extends ObjectType>) prismContext.getSchemaRegistry().getCompileTimeClassForObjectType(objectType);
    if (clazz == null) {
        throw new SchemaException("Couldn't find compile-time class for object type of " + objectType);
    }
    QueryType queryType = prismContext.parserFor(queryText).xml().parseRealValue(QueryType.class);
    request.setType(clazz);
    ObjectQuery objectQuery = QueryJaxbConvertor.createObjectQuery(clazz, queryType, prismContext);
    ObjectQuery queryWithExprEvaluated = ExpressionUtil.evaluateQueryExpressions(objectQuery, new ExpressionVariables(), getExpressionFactory(), getPrismContext(), "evaluate query expressions", task, result);
    request.setQuery(queryWithExprEvaluated);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContext(com.evolveum.midpoint.prism.PrismContext) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 17 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType 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 18 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class QueryInterpreter2Test method getQuery.

@Nullable
private ObjectQuery getQuery(File file, Class type) throws SchemaException, IOException {
    QueryType queryType = PrismTestUtil.parseAtomicValue(file, QueryType.COMPLEX_TYPE);
    LOGGER.info("QUERY TYPE TO CONVERT : {}", ObjectQueryUtil.dump(queryType, prismContext));
    ObjectQuery query = null;
    try {
        // TODO
        query = QueryJaxbConvertor.createObjectQuery(type, queryType, prismContext);
    } catch (Exception ex) {
        LOGGER.info("error while converting query: " + ex.getMessage(), ex);
    }
    return query;
}
Also used : QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SAXException(org.xml.sax.SAXException) QueryException(com.evolveum.midpoint.repo.sql.query.QueryException) IOException(java.io.IOException) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class TestOpenDj method test202SearchObjectsCompexFilter.

@Test
public void test202SearchObjectsCompexFilter() throws Exception {
    final String TEST_NAME = "test202SearchObjectsCompexFilter";
    TestUtil.displayTestTile(TEST_NAME);
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    QueryType queryType = PrismTestUtil.parseAtomicValue(QUERY_COMPLEX_FILTER_FILE, QueryType.COMPLEX_TYPE);
    ObjectQuery query = QueryJaxbConvertor.createObjectQuery(ShadowType.class, queryType, prismContext);
    provisioningService.applyDefinition(ShadowType.class, query, task, result);
    rememberConnectorOperationCount();
    rememberConnectorSimulatedPagingSearchCount();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    List<PrismObject<ShadowType>> objListType = provisioningService.searchObjects(ShadowType.class, query, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    for (PrismObject<ShadowType> objType : objListType) {
        assertNotNull("Null search result", objType);
        display("found object", objType);
    }
    assertEquals("Unexpected number of objects found", 1, objListType.size());
    assertConnectorOperationIncrement(1, 3);
    assertConnectorSimulatedPagingSearchIncrement(0);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) 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 20 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project midpoint by Evolveum.

the class TestOpenDj method test250CountObjects.

@Test
public void test250CountObjects() throws Exception {
    final String TEST_NAME = "test250CountObjects";
    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);
    // WHEN
    Integer count = provisioningService.countObjects(ShadowType.class, query, null, task, result);
    // THEN
    result.computeStatus();
    assertSuccess(result);
    assertEquals("Unexpected number of search results", (Integer) 14, count);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) 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)

Aggregations

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)57 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)41 Test (org.junit.Test)40 QueryImpl (ddf.catalog.operation.impl.QueryImpl)37 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)36 QName (javax.xml.namespace.QName)34 Test (org.testng.annotations.Test)32 JAXBElement (javax.xml.bind.JAXBElement)27 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)24 ArrayList (java.util.ArrayList)24 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)20 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)17 Matchers.anyString (org.mockito.Matchers.anyString)14 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)13 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12 Task (com.evolveum.midpoint.task.api.Task)12 Holder (javax.xml.ws.Holder)12 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)12 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)12