Search in sources :

Example 31 with QueryType

use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project ddf by codice.

the class TestWfsSource method testSortingAscendingSortingNotSupported.

/**
     * Verify that the SortBy is NOT set.  In this case, sorting is not supported in the capabilities.
     */
@Test
public void testSortingAscendingSortingNotSupported() throws Exception {
    // Setup
    final String searchPhrase = "*";
    final String mockTemporalFeatureProperty = "myTemporalFeatureProperty";
    final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
    final int pageSize = 1;
    // Set ImplementsSorting to FALSE (sorting not supported)
    FilterCapabilities mockCapabilitiesSortingNotSupported = MockWfsServer.getFilterCapabilities();
    ConformanceType conformance = mockCapabilitiesSortingNotSupported.getConformance();
    List<DomainType> domainTypes = conformance.getConstraint();
    for (DomainType domainType : domainTypes) {
        if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
            ValueType valueType = new ValueType();
            valueType.setValue("FALSE");
            domainType.setDefaultValue(valueType);
            break;
        }
    }
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, mockCapabilitiesSortingNotSupported, GeospatialUtil.EPSG_4326_URN, 1, false, false, 0);
    MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
    when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
    when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
    List<MetacardMapper> mappers = new ArrayList<MetacardMapper>(1);
    mappers.add(mockMetacardMapper);
    source.setMetacardToFeatureMapper(mappers);
    QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
    query.setPageSize(pageSize);
    SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
    query.setSortBy(sortBy);
    // Perform Test
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    // Verify
    QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
    assertFalse(queryType.isSetAbstractSortingClause());
}
Also used : ValueType(net.opengis.ows.v_1_1_0.ValueType) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) QueryImpl(ddf.catalog.operation.impl.QueryImpl) DomainType(net.opengis.ows.v_1_1_0.DomainType) SortByImpl(ddf.catalog.filter.impl.SortByImpl) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) QueryType(net.opengis.wfs.v_2_0_0.QueryType) MetacardMapper(org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType) Test(org.junit.Test)

Example 32 with QueryType

use of ogc.schema.opengis.wfs.v_1_0_0.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 33 with QueryType

use of ogc.schema.opengis.wfs.v_1_0_0.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 34 with QueryType

use of ogc.schema.opengis.wfs.v_1_0_0.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)

Example 35 with QueryType

use of ogc.schema.opengis.wfs.v_1_0_0.QueryType in project midpoint by Evolveum.

the class TestWSSanity method test015SearchLdapConnector.

// TODO: fetch&parse schema http://..?WSDL
@Test
public void test015SearchLdapConnector() throws Exception {
    final String TEST_NAME = "test015SearchLdapConnector";
    displayTestTitle(TEST_NAME);
    QueryType query = new QueryType();
    query.setFilter(ModelClientUtil.parseSearchFilterType("<equal xmlns='http://prism.evolveum.com/xml/ns/public/query-3' xmlns:c='http://midpoint.evolveum.com/xml/ns/public/common/common-3' >" + "<path>c:connectorType</path>" + "<value>" + CONNECTOR_LDAP_TYPE + "</value>" + "</equal>"));
    Holder<ObjectListType> objectListHolder = new Holder<>();
    Holder<OperationResultType> resultHolder = new Holder<>();
    // WHEN
    modelPort.searchObjects(ModelClientUtil.getTypeQName(ConnectorType.class), query, null, objectListHolder, resultHolder);
    // THEN
    assertSuccess(resultHolder);
    ObjectListType objectList = objectListHolder.value;
    assertEquals("Unexpected number of LDAP connectors", 1, objectList.getObject().size());
    ConnectorType ldapConnector = (ConnectorType) objectList.getObject().get(0);
    assertNotNull("Null LDAP connector", ldapConnector);
    connectorLdapOid = ldapConnector.getOid();
    assertNotNull("Null LDAP connector OID", connectorLdapOid);
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) Test(org.testng.annotations.Test)

Aggregations

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)91 Test (org.junit.Test)89 QueryImpl (ddf.catalog.operation.impl.QueryImpl)71 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)67 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)58 Test (org.testng.annotations.Test)52 QName (javax.xml.namespace.QName)50 JAXBElement (javax.xml.bind.JAXBElement)44 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)38 ArrayList (java.util.ArrayList)37 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)34 Filter (org.opengis.filter.Filter)32 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 SortBy (org.opengis.filter.sort.SortBy)22 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)21 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)21 SortByImpl (ddf.catalog.filter.impl.SortByImpl)20 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)19 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)19 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)18