Search in sources :

Example 11 with PropertyIsLikeType

use of ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsSource method testQueryTwoFeaturesOneInvalid.

@Test
public void testQueryTwoFeaturesOneInvalid() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(TWO_TEXT_PROPERTY_SCHEMA, null, null, TWO_FEATURES, null);
    Filter orderPersonFilter = builder.attribute(EXT_PREFIX + sampleFeatures.get(0) + "." + ORDER_PERSON).is().like().text(LITERAL);
    Filter mctFeature1Fitler = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
    Filter feature1Filter = builder.allOf(Arrays.asList(orderPersonFilter, mctFeature1Fitler));
    Filter orderDogFilter = builder.attribute("FAKE").is().like().text(LITERAL);
    Filter mctFeature2Fitler = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(1).getLocalPart());
    Filter feature2Filter = builder.allOf(Arrays.asList(orderDogFilter, mctFeature2Fitler));
    Filter totalFilter = builder.anyOf(Arrays.asList(feature1Filter, feature2Filter));
    QueryImpl inQuery = new QueryImpl(totalFilter);
    inQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(inQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, inQuery);
    assertEquals(ONE_FEATURE.intValue(), getFeatureType.getQuery().size());
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
    // The Text Properties should be ORed
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
    PropertyIsLikeType pilt = (PropertyIsLikeType) query.getFilter().getComparisonOps().getValue();
    assertEquals(ORDER_PERSON, pilt.getPropertyName().getContent());
}
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)

Example 12 with PropertyIsLikeType

use of ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType in project ddf by codice.

the class TestWfsSource method testQueryTwoFeaturesWithMixedPropertyNames.

@Test
public void testQueryTwoFeaturesWithMixedPropertyNames() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(TWO_TEXT_PROPERTY_SCHEMA, null, null, TWO_FEATURES, null);
    Filter orderPersonFilter = builder.attribute(EXT_PREFIX + sampleFeatures.get(0).getLocalPart() + "." + ORDER_PERSON).is().like().text(LITERAL);
    Filter mctFeature1Fitler = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
    Filter feature1Filter = builder.allOf(Arrays.asList(orderPersonFilter, mctFeature1Fitler));
    Filter orderDogFilter = builder.attribute(EXT_PREFIX + sampleFeatures.get(1).getLocalPart() + "." + ORDER_DOG).is().like().text(LITERAL);
    Filter mctFeature2Fitler = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(1).getLocalPart());
    Filter feature2Filter = builder.allOf(Arrays.asList(orderDogFilter, mctFeature2Fitler));
    Filter totalFilter = builder.anyOf(Arrays.asList(feature1Filter, feature2Filter));
    QueryImpl inQuery = new QueryImpl(totalFilter);
    inQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(inQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, inQuery);
    Collections.sort(getFeatureType.getQuery(), QUERY_TYPE_COMPARATOR);
    assertEquals(TWO_FEATURES.intValue(), getFeatureType.getQuery().size());
    // Feature 1
    QueryType query = getFeatureType.getQuery().get(0);
    assertThat(query.getTypeName(), equalTo(sampleFeatures.get(0)));
    // this should only have 1 filter which is a comparison
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
    PropertyIsLikeType pilt = (PropertyIsLikeType) query.getFilter().getComparisonOps().getValue();
    assertNotNull(pilt);
    assertEquals(ORDER_PERSON, pilt.getPropertyName().getContent());
    // Feature 2
    QueryType query2 = getFeatureType.getQuery().get(1);
    assertTrue(query2.getTypeName().equals(sampleFeatures.get(1)));
    // this should only have 1 filter which is a comparison
    assertTrue(query2.getFilter().isSetComparisonOps());
    assertTrue(query2.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
    PropertyIsLikeType pilt2 = (PropertyIsLikeType) query2.getFilter().getComparisonOps().getValue();
    assertEquals(ORDER_DOG, pilt2.getPropertyName().getContent());
}
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)

Example 13 with PropertyIsLikeType

use of ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType in project ddf by codice.

the class WfsFilterDelegate method createPropertyIsFilter.

private JAXBElement<? extends ComparisonOpsType> createPropertyIsFilter(String property, Object literal, PROPERTY_IS_OPS operation) {
    switch(operation) {
        case PropertyIsEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsEqualTo = filterObjectFactory.createPropertyIsEqualTo(new BinaryComparisonOpType());
            propIsEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsEqualTo;
        case PropertyIsNotEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsNotEqualTo = filterObjectFactory.createPropertyIsNotEqualTo(new BinaryComparisonOpType());
            propIsNotEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsNotEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsNotEqualTo;
        case PropertyIsGreaterThan:
            JAXBElement<BinaryComparisonOpType> propIsGreaterThan = filterObjectFactory.createPropertyIsGreaterThan(new BinaryComparisonOpType());
            propIsGreaterThan.getValue().getExpression().add(createPropertyNameType(property));
            propIsGreaterThan.getValue().getExpression().add(createLiteralType(literal));
            return propIsGreaterThan;
        case PropertyIsGreaterThanOrEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsGreaterThanOrEqualTo = filterObjectFactory.createPropertyIsGreaterThanOrEqualTo(new BinaryComparisonOpType());
            propIsGreaterThanOrEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsGreaterThanOrEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsGreaterThanOrEqualTo;
        case PropertyIsLessThan:
            JAXBElement<BinaryComparisonOpType> propIsLessThan = filterObjectFactory.createPropertyIsLessThan(new BinaryComparisonOpType());
            propIsLessThan.getValue().getExpression().add(createPropertyNameType(property));
            propIsLessThan.getValue().getExpression().add(createLiteralType(literal));
            return propIsLessThan;
        case PropertyIsLessThanOrEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsLessThanOrEqualTo = filterObjectFactory.createPropertyIsLessThanOrEqualTo(new BinaryComparisonOpType());
            propIsLessThanOrEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsLessThanOrEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsLessThanOrEqualTo;
        case PropertyIsLike:
            JAXBElement<PropertyIsLikeType> propIsLike = filterObjectFactory.createPropertyIsLike(new PropertyIsLikeType());
            propIsLike.getValue().setPropertyName(createPropertyNameType(property).getValue());
            propIsLike.getValue().setEscape(WfsConstants.ESCAPE);
            propIsLike.getValue().setSingleChar(SINGLE_CHAR);
            propIsLike.getValue().setWildCard(WfsConstants.WILD_CARD);
            propIsLike.getValue().setLiteral(createLiteralType(literal).getValue());
            return propIsLike;
        default:
            throw new UnsupportedOperationException("Unsupported Property Comparison Type");
    }
}
Also used : BinaryComparisonOpType(ogc.schema.opengis.filter.v_1_0_0.BinaryComparisonOpType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType)

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