Search in sources :

Example 1 with PropertyIsLikeType

use of net.opengis.filter.v_2_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalCombinatorsOneItem.

private void testLogicalCombinatorsOneItem(String methName) throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    List<FilterType> filtersToCombine = new ArrayList<>();
    filtersToCombine.add(compFilter1);
    Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
    FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
    // Only one filter was provided to combinator so only that filter is returned as not
    // enough filters to combine together
    assertNull(filter.getLogicOps());
    PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) filter.getComparisonOps().getValue();
    String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
    assertThat(valRef1, is(mockProperty));
    String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
    assertThat(literal1, is(LITERAL));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) PropertyIsLikeType(net.opengis.filter.v_2_0_0.PropertyIsLikeType)

Example 2 with PropertyIsLikeType

use of net.opengis.filter.v_2_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalNotOfLogicals.

@Test
public void testLogicalNotOfLogicals() throws Exception {
    String mockProperty = "myPropertyName";
    String mockType = "myType";
    WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
    FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    List<FilterType> subFiltersToBeOred = new ArrayList<>();
    subFiltersToBeOred.add(compFilter1);
    subFiltersToBeOred.add(compFilter2);
    //Perform Test
    FilterType filter = delegate.not(delegate.or(subFiltersToBeOred));
    //Verify
    assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
    UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
    BinaryLogicOpType logicOrType = (BinaryLogicOpType) logicOpType.getLogicOps().getValue();
    assertThat(logicOpType.getLogicOps().getName().toString(), is(LOGICAL_OR_NAME));
    PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
    String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
    assertThat(valRef1, is(mockProperty));
    String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
    assertThat(literal1, is(LITERAL));
    PropertyIsLikeType compOpsType2 = (PropertyIsLikeType) logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
    String valRef2 = fetchPropertyIsLikeExpression(compOpsType2, VALUE_REFERENCE);
    assertThat(valRef2, is(mockProperty));
    String literal2 = fetchPropertyIsLikeExpression(compOpsType2, LITERAL);
    assertThat(literal2, is(LITERAL));
}
Also used : UnaryLogicOpType(net.opengis.filter.v_2_0_0.UnaryLogicOpType) FilterType(net.opengis.filter.v_2_0_0.FilterType) BinaryLogicOpType(net.opengis.filter.v_2_0_0.BinaryLogicOpType) ArrayList(java.util.ArrayList) PropertyIsLikeType(net.opengis.filter.v_2_0_0.PropertyIsLikeType) Test(org.junit.Test)

Example 3 with PropertyIsLikeType

use of net.opengis.filter.v_2_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsSource method testPropertyIsLikeQuery.

@Test
public void testPropertyIsLikeQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, ONE_FEATURE, null);
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("literal"));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(ogc.schema.opengis.wfs.v_1_0_0.QueryType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) Test(org.junit.Test)

Example 4 with PropertyIsLikeType

use of net.opengis.filter.v_2_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsSource method testTwoFeatureTypesQuery.

@Test
public void testTwoFeatureTypesQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, TWO_FEATURES, null);
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    assertTrue(getFeatureType.getQuery().size() == TWO_FEATURES);
    Collections.sort(getFeatureType.getQuery(), QUERY_TYPE_COMPARATOR);
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
    QueryType query2 = getFeatureType.getQuery().get(1);
    assertTrue(query2.getTypeName().equals(sampleFeatures.get(1)));
    assertTrue(query2.getFilter().isSetComparisonOps());
    assertTrue(query2.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(ogc.schema.opengis.wfs.v_1_0_0.QueryType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) Test(org.junit.Test)

Example 5 with PropertyIsLikeType

use of net.opengis.filter.v_2_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsSource method testContentTypeQuery.

@Test
public void testContentTypeQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, ONE_FEATURE, null);
    Filter propertyIsLikeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
    Filter contentTypeFilter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.allOf(propertyIsLikeFilter, contentTypeFilter));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(// SAMPLE_FEATURE[0]));
    sampleFeatures.get(0)));
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(ogc.schema.opengis.wfs.v_1_0_0.QueryType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 PropertyIsLikeType (net.opengis.filter.v_2_0_0.PropertyIsLikeType)6 PropertyIsLikeType (ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType)6 QueryImpl (ddf.catalog.operation.impl.QueryImpl)5 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)5 FilterType (net.opengis.filter.v_2_0_0.FilterType)5 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)5 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)5 ArrayList (java.util.ArrayList)4 Method (java.lang.reflect.Method)3 BinaryLogicOpType (net.opengis.filter.v_2_0_0.BinaryLogicOpType)3 Filter (org.opengis.filter.Filter)3 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)2 PropertyIsLikeType (net.opengis.filter.v_1_1_0.PropertyIsLikeType)1 BinaryComparisonOpType (net.opengis.filter.v_2_0_0.BinaryComparisonOpType)1 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)1 BinaryComparisonOpType (ogc.schema.opengis.filter.v_1_0_0.BinaryComparisonOpType)1