Search in sources :

Example 41 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class WfsFilterDelegateTest method intersectsMultiple.

private void intersectsMultiple(boolean indexed) {
    List<String> gmlProps = new ArrayList<>();
    gmlProps.add(MOCK_GEOM);
    gmlProps.add(MOCK_GEOM2);
    when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
    for (String gmlProp : gmlProps) {
        when(mockFeatureMetacardType.isQueryable(gmlProp)).thenReturn(indexed);
    }
    SpatialOperatorType operator = new SpatialOperatorType();
    operator.setName(SPATIAL_OPERATORS.INTERSECTS.toString());
    FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
    capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
    capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
    WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
    FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
    if (indexed) {
        assertNotNull(filter);
        assertTrue(filter.isSetLogicOps());
        assertNotNull(filter.getLogicOps());
    } else {
        assertNull(filter);
    }
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) FilterType(net.opengis.filter.v_2_0_0.FilterType) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) ArrayList(java.util.ArrayList)

Example 42 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class WfsFilterDelegateTest method makeDelegateForLogicalSupportTests.

private WfsFilterDelegate makeDelegateForLogicalSupportTests() {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    List<String> mockProperties = new ArrayList<>(1);
    mockProperties.add(mockProperty);
    when(mockFeatureMetacardType.getProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getGmlProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getTextualProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getTemporalProperties()).thenReturn(mockProperties);
    when(mockFeatureMetacardType.getName()).thenReturn(mockType);
    when(mockFeatureMetacardType.isQueryable(mockProperty)).thenReturn(true);
    FilterCapabilities filterCap = MockWfsServer.getFilterCapabilities();
    // Create new ScalarCapabiltiesType without Logical Operator support
    ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
    scalar.setComparisonOperators(new ComparisonOperatorsType());
    for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
        ComparisonOperatorType operator = new ComparisonOperatorType();
        operator.setName(compOp.toString());
        scalar.getComparisonOperators().getComparisonOperator().add(operator);
    }
    filterCap.setScalarCapabilities(scalar);
    return new WfsFilterDelegate(mockFeatureMetacardType, filterCap, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_2_0_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_2_0_0.ScalarCapabilitiesType) ArrayList(java.util.ArrayList) ComparisonOperatorType(net.opengis.filter.v_2_0_0.ComparisonOperatorType) COMPARISON_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS)

Example 43 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class WfsFilterDelegateTest method testNoSpatialOps.

@Test
public void testNoSpatialOps() {
    FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
    capabilities.setSpatialCapabilities(null);
    WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
    assertThat(delegate.isLogicalOps(), is(true));
    assertThat(delegate.isEpsg4326(), is(true));
    assertThat(delegate.isSortingSupported(), is(true));
    assertThat(delegate.getSrsName(), is(GeospatialUtil.EPSG_4326_URN));
    assertThat(delegate.getComparisonOps().size(), is(COMPARISON_OPERATORS.values().length));
    assertThat(delegate.getGeometryOperands().size(), is(0));
    assertThat(delegate.getSpatialOps().size(), is(0));
    assertThat(delegate.getTemporalOps().size(), is(TEMPORAL_OPERATORS.values().length));
    assertThat(delegate.getTemporalOperands().size(), greaterThan(0));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) Test(org.junit.Test)

Example 44 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class WfsSourceTest 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, 1, false, false, 0);
    MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
    when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
    when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
    List<MetacardMapper> mappers = new ArrayList<>(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 45 with FilterCapabilities

use of ogc.schema.opengis.filter_capabilities.v_1_0_0.FilterCapabilities in project ddf by codice.

the class TestCswSourceBase method configureMockCsw.

protected void configureMockCsw(int numRecordsReturned, long numRecordsMatched, String cswVersion) throws CswException {
    ServiceIdentification mockServiceIdentification = mock(ServiceIdentification.class);
    when(mockServiceIdentification.getAbstract()).thenReturn("myDescription");
    CapabilitiesType mockCapabilities = mock(CapabilitiesType.class);
    when(mockCapabilities.getVersion()).thenReturn(cswVersion);
    when(mockCapabilities.getServiceIdentification()).thenReturn(mockServiceIdentification);
    when(mockCapabilities.getServiceIdentification()).thenReturn(mockServiceIdentification);
    when(mockCsw.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilities);
    FilterCapabilities mockFilterCapabilities = mock(FilterCapabilities.class);
    when(mockCapabilities.getFilterCapabilities()).thenReturn(mockFilterCapabilities);
    List<ComparisonOperatorType> comparisonOpsList = new ArrayList<>();
    comparisonOpsList.add(ComparisonOperatorType.EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.LIKE);
    comparisonOpsList.add(ComparisonOperatorType.NOT_EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.GREATER_THAN);
    comparisonOpsList.add(ComparisonOperatorType.GREATER_THAN_EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.LESS_THAN);
    comparisonOpsList.add(ComparisonOperatorType.LESS_THAN_EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.BETWEEN);
    comparisonOpsList.add(ComparisonOperatorType.NULL_CHECK);
    ComparisonOperatorsType comparisonOps = new ComparisonOperatorsType();
    comparisonOps.setComparisonOperator(comparisonOpsList);
    ScalarCapabilitiesType mockScalarCapabilities = mock(ScalarCapabilitiesType.class);
    when(mockScalarCapabilities.getLogicalOperators()).thenReturn(mock(LogicalOperators.class));
    mockScalarCapabilities.setComparisonOperators(comparisonOps);
    when(mockScalarCapabilities.getComparisonOperators()).thenReturn(comparisonOps);
    when(mockFilterCapabilities.getScalarCapabilities()).thenReturn(mockScalarCapabilities);
    List<DomainType> getRecordsParameters = new ArrayList<>();
    DomainType typeName = new DomainType();
    typeName.setName(CswConstants.TYPE_NAME_PARAMETER);
    typeName.setValue(Collections.singletonList("csw:Record"));
    getRecordsParameters.add(typeName);
    DomainType typeNames = new DomainType();
    typeNames.setName(CswConstants.TYPE_NAMES_PARAMETER);
    getRecordsParameters.add(typeNames);
    DomainType getRecordsOutputSchema = new DomainType();
    getRecordsOutputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
    getRecordsOutputSchema.getValue().add(CswConstants.CSW_OUTPUT_SCHEMA);
    getRecordsParameters.add(getRecordsOutputSchema);
    DomainType constraintLang = new DomainType();
    constraintLang.setName(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
    constraintLang.setValue(Collections.singletonList(CswConstants.CONSTRAINT_LANGUAGE_FILTER));
    getRecordsParameters.add(constraintLang);
    DomainType outputFormat = new DomainType();
    outputFormat.setName(CswConstants.OUTPUT_FORMAT_PARAMETER);
    getRecordsParameters.add(outputFormat);
    DomainType resultType = new DomainType();
    resultType.setName(CswConstants.RESULT_TYPE_PARAMETER);
    getRecordsParameters.add(resultType);
    DomainType elementSetName = new DomainType();
    elementSetName.setName(CswConstants.ELEMENT_SET_NAME_PARAMETER);
    getRecordsParameters.add(elementSetName);
    List<DomainType> getRecordByIdParameters = new ArrayList<>();
    DomainType getRecordByIdOutputSchema = new DomainType();
    getRecordByIdOutputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
    List<String> outputSchemas = new ArrayList<>();
    outputSchemas.add(CswConstants.CSW_OUTPUT_SCHEMA);
    getRecordByIdOutputSchema.setValue(outputSchemas);
    getRecordByIdParameters.add(getRecordByIdOutputSchema);
    Operation getRecords = new Operation();
    getRecords.setName(CswConstants.GET_RECORDS);
    getRecords.setParameter(getRecordsParameters);
    Operation getRecordById = new Operation();
    getRecordById.setName(CswConstants.GET_RECORD_BY_ID);
    getRecordById.setParameter(getRecordByIdParameters);
    List<Operation> operations = new ArrayList<>(2);
    operations.add(getRecords);
    operations.add(getRecordById);
    OperationsMetadata mockOperationsMetadata = mock(OperationsMetadata.class);
    mockOperationsMetadata.setOperation(operations);
    when(mockCapabilities.getOperationsMetadata()).thenReturn(mockOperationsMetadata);
    when(mockOperationsMetadata.getOperation()).thenReturn(operations);
    if (numRecordsReturned > 0) {
        List<Metacard> metacards = new ArrayList<>(numRecordsReturned);
        for (int i = 1; i <= numRecordsReturned; i++) {
            String id = "ID_" + String.valueOf(i);
            MetacardImpl metacard = new MetacardImpl();
            metacard.setId(id);
            metacard.setContentTypeName("myContentType");
            metacards.add(metacard);
        }
        SearchResultsType searchResults = mock(SearchResultsType.class);
        when(searchResults.getNumberOfRecordsMatched()).thenReturn(BigInteger.valueOf(numRecordsMatched));
        when(searchResults.getNumberOfRecordsReturned()).thenReturn(BigInteger.valueOf(numRecordsReturned));
        CswRecordCollection mockCswRecordCollection = mock(CswRecordCollection.class);
        when(mockCswRecordCollection.getCswRecords()).thenReturn(metacards);
        when(mockCswRecordCollection.getNumberOfRecordsMatched()).thenReturn(numRecordsMatched);
        when(mockCswRecordCollection.getNumberOfRecordsReturned()).thenReturn((long) numRecordsReturned);
        when(mockCsw.getRecords(any(GetRecordsType.class))).thenReturn(mockCswRecordCollection);
    }
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) SearchResultsType(net.opengis.cat.csw.v_2_0_2.SearchResultsType) ArrayList(java.util.ArrayList) LogicalOperators(net.opengis.filter.v_1_1_0.LogicalOperators) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Operation(net.opengis.ows.v_1_0_0.Operation) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_1_1_0.ComparisonOperatorsType) Metacard(ddf.catalog.data.Metacard) DomainType(net.opengis.ows.v_1_0_0.DomainType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ComparisonOperatorType(net.opengis.filter.v_1_1_0.ComparisonOperatorType) ServiceIdentification(net.opengis.ows.v_1_0_0.ServiceIdentification)

Aggregations

FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)33 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)24 FilterType (net.opengis.filter.v_2_0_0.FilterType)14 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)11 SpatialOperatorType (net.opengis.filter.v_2_0_0.SpatialOperatorType)11 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)8 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)8 ScalarCapabilitiesType (net.opengis.filter.v_1_1_0.ScalarCapabilitiesType)8 SpatialCapabilitiesType (net.opengis.filter.v_1_1_0.SpatialCapabilitiesType)8 SpatialOperatorsType (net.opengis.filter.v_1_1_0.SpatialOperatorsType)8 Date (java.util.Date)6 QName (javax.xml.namespace.QName)6 SpatialOperatorType (net.opengis.filter.v_1_1_0.SpatialOperatorType)6 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)6 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)6 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)6 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)6 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)5 GeometryOperand (net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand)5