Search in sources :

Example 16 with PropertyIsEqualTo

use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.

the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsEqualToFunction.

@Test
public void testVisitPropertyIsEqualToFunction() {
    Expression val = factory.literal(true);
    ExtendedGeotoolsFunctionFactory geotoolsFunctionFactory = new ExtendedGeotoolsFunctionFactory();
    Function function = geotoolsFunctionFactory.function("proximity", Arrays.asList(attrExpr, factory.literal(1), factory.literal("Marry little")), null);
    PropertyIsEqualTo filter = factory.equals(function, val);
    PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
    assertThat(duplicate.getExpression1(), Matchers.instanceOf(Function.class));
    Function dupFunction = (Function) duplicate.getExpression1();
    assertThat(dupFunction.getFunctionName(), is(function.getFunctionName()));
    assertThat(dupFunction.getParameters(), is(function.getParameters()));
    assertThat(duplicate.getExpression2(), is(val));
    assertThat(duplicate.isMatchingCase(), is(true));
}
Also used : Function(org.opengis.filter.expression.Function) FuzzyFunction(ddf.catalog.impl.filter.FuzzyFunction) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Expression(org.opengis.filter.expression.Expression) ExtendedGeotoolsFunctionFactory(org.codice.ddf.spatial.ogc.csw.catalog.common.ExtendedGeotoolsFunctionFactory) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 17 with PropertyIsEqualTo

use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.

the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsEqualToCaseInsensitive.

@Test
public void testVisitPropertyIsEqualToCaseInsensitive() {
    Expression val = factory.literal("foo");
    PropertyIsEqualTo filter = factory.equal(attrExpr, val, false);
    PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2(), is(val));
    assertThat(duplicate.isMatchingCase(), is(false));
}
Also used : PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Expression(org.opengis.filter.expression.Expression) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 18 with PropertyIsEqualTo

use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.

the class CswQueryFactoryTest method testPostGetRecordsFunctionCQLQuery.

@Test
public void testPostGetRecordsFunctionCQLQuery() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    constraint.setCqlText(CQL_CONTEXTUAL_FUNCTION_QUERY);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryRequest queryRequest = queryFactory.getQuery(grr);
    QueryImpl frameworkQuery = (QueryImpl) queryRequest.getQuery();
    Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
    assertThat(queryFilter, instanceOf(PropertyIsEqualTo.class));
    PropertyIsEqualTo equalTo = (PropertyIsEqualTo) queryFilter;
    assertThat(equalTo.getExpression1(), instanceOf(Function.class));
    Function function = (Function) equalTo.getExpression1();
    assertThat(equalTo.getExpression2(), instanceOf(Literal.class));
    Literal literal = (Literal) equalTo.getExpression2();
    assertThat(function.getName(), is("proximity"));
    assertThat(function.getParameters().get(0).evaluate(null), is(CONTEXTUAL_TEST_ATTRIBUTE));
    assertThat(function.getParameters().get(1).evaluate(null), is(1L));
    assertThat(function.getParameters().get(2).evaluate(null), is(CQL_CONTEXTUAL_PATTERN));
    assertThat(literal.getValue(), is(true));
}
Also used : QueryRequest(ddf.catalog.operation.QueryRequest) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) Function(org.opengis.filter.expression.Function) QueryImpl(ddf.catalog.operation.impl.QueryImpl) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Filter(org.opengis.filter.Filter) Literal(org.opengis.filter.expression.Literal) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) Test(org.junit.Test)

Aggregations

PropertyIsEqualTo (org.opengis.filter.PropertyIsEqualTo)18 Test (org.junit.Test)15 Expression (org.opengis.filter.expression.Expression)7 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)6 Filter (org.opengis.filter.Filter)5 Literal (org.opengis.filter.expression.Literal)4 ArrayList (java.util.ArrayList)3 Ignore (org.junit.Ignore)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 Function (org.opengis.filter.expression.Function)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 FilterDelegate (ddf.catalog.filter.FilterDelegate)1 LiteralImpl (ddf.catalog.filter.impl.LiteralImpl)1 PropertyIsEqualToLiteral (ddf.catalog.filter.impl.PropertyIsEqualToLiteral)1 PropertyNameImpl (ddf.catalog.filter.impl.PropertyNameImpl)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 FuzzyFunction (ddf.catalog.impl.filter.FuzzyFunction)1