Search in sources :

Example 6 with PropertyIsEqualTo

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

the class FilterAdapterTest method testTemporalRelativeFilter.

@Test
public void testTemporalRelativeFilter() {
    PropertyIsEqualTo mockTemporalFilter = mock(PropertyIsEqualTo.class);
    PropertyName mockPropertyName = mock(PropertyName.class);
    doReturn("created").when(mockPropertyName).accept(any(), any());
    Literal mockLiteral = mock(Literal.class);
    doReturn("RELATIVE(P2Y3M2DT1H6M)").when(mockLiteral).accept(any(), any());
    doReturn(mockPropertyName).when(mockTemporalFilter).getExpression1();
    doReturn(mockLiteral).when(mockTemporalFilter).getExpression2();
    // Use fake delegate to return fake result to verify operation
    // This will only return the expected result if the relative temporal path is followed
    FilterDelegate mockFilterDelegate = mock(FilterDelegate.class);
    doReturn(Boolean.TRUE).when(mockFilterDelegate).propertyIsBetween(any(), any(Date.class), any(Date.class));
    try {
        GeotoolsFilterAdapterImpl geotoolsFilterAdapter = new GeotoolsFilterAdapterImpl();
        assertThat(geotoolsFilterAdapter.visit(mockTemporalFilter, mockFilterDelegate), is(true));
    } catch (Exception e) {
        fail("The filter was not handled as a between query after generating literal dates.");
    }
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) FilterDelegate(ddf.catalog.filter.FilterDelegate) Literal(org.opengis.filter.expression.Literal) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) Date(java.util.Date) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) URISyntaxException(java.net.URISyntaxException) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 7 with PropertyIsEqualTo

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

the class OpenSearchFilterVisitorTest method testPropertyEqualToNotNest.

@Test
public void testPropertyEqualToNotNest() {
    PropertyIsEqualTo propertyIsEqualToFilter = (PropertyIsEqualTo) geotoolsFilterBuilder.attribute(ID_ATTRIBUTE_NAME).is().equalTo().text(TEST_STRING);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.NOT);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(propertyIsEqualToFilter, openSearchFilterVisitorObject);
    assertThat(result.getId(), is(nullValue()));
}
Also used : PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Test(org.junit.Test)

Example 8 with PropertyIsEqualTo

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

the class TestCswRecordMapperFilterVisitor method testSourceIdFilter.

@Test
public void testSourceIdFilter() {
    Expression val = factory.literal("source1");
    Expression val2 = factory.literal("source2");
    Expression sourceExpr = factory.property(Core.SOURCE_ID);
    PropertyIsEqualTo filter = factory.equal(sourceExpr, val, false);
    Filter filter2 = factory.equal(sourceExpr, val2, false);
    Filter likeFilter = factory.like(attrExpr, "something");
    Filter sourceFilter = factory.or(filter, filter2);
    Filter totalFilter = factory.and(sourceFilter, likeFilter);
    Object obj = totalFilter.accept(visitor, null);
    assertThat(obj, instanceOf(PropertyIsLike.class));
    PropertyIsLike duplicate = (PropertyIsLike) obj;
    assertThat(duplicate.getExpression(), is(attrExpr));
    assertThat(duplicate.getLiteral(), is("something"));
    assertThat(visitor.getSourceIds().size(), is(2));
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Expression(org.opengis.filter.expression.Expression) Filter(org.opengis.filter.Filter) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 9 with PropertyIsEqualTo

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

the class TestCswRecordMapperFilterVisitor 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 10 with PropertyIsEqualTo

use of org.opengis.filter.PropertyIsEqualTo in project polymap4-core by Polymap4.

the class ColorMap2FilterEditor method initValues.

protected void initValues() {
    List<Mapped<Filter, Color>> values = prop.get().values();
    for (Mapped<Filter, Color> entry : values) {
        PropertyIsEqualTo filter = (PropertyIsEqualTo) entry.key();
        propertyName = ((PropertyName) filter.getExpression1()).getPropertyName();
        Object value = ((Literal) filter.getExpression2()).getValue();
        colorMap.add(new Triple(value, -1, entry.value()));
    }
}
Also used : Mapped(org.polymap.core.style.model.feature.MappedValues.Mapped) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Filter(org.opengis.filter.Filter) Color(java.awt.Color) Literal(org.opengis.filter.expression.Literal)

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