Search in sources :

Example 1 with PropertyIsEqualToLiteral

use of ddf.catalog.filter.impl.PropertyIsEqualToLiteral in project ddf by codice.

the class OpenSearchFilterVisitor method visit.

/**
     * PropertyIsEqualTo filter maps to a type/version criteria.
     */
@Override
public Object visit(PropertyIsEqualTo filter, Object data) {
    LOGGER.trace("ENTERING: PropertyIsEqualTo filter");
    if (currentNest != NestedTypes.NOT) {
        if (filter instanceof IsEqualsToImpl) {
            IsEqualsToImpl isEqualsTo = (IsEqualsToImpl) filter;
            Expression leftValue = isEqualsTo.getLeftValue();
            if (Metacard.ID.equals(leftValue.toString())) {
                id = isEqualsTo.getExpression2().toString();
            }
        } else if (filter instanceof PropertyIsEqualToLiteral) {
            PropertyIsEqualToLiteral isEqualsTo = (PropertyIsEqualToLiteral) filter;
            if (Metacard.ID.equals(isEqualsTo.getExpression1().toString())) {
                id = isEqualsTo.getExpression2().toString();
            }
        }
    }
    filters.add(filter);
    LOGGER.trace("EXITING: PropertyIsEqualTo filter");
    return super.visit(filter, data);
}
Also used : Expression(org.geotools.filter.Expression) IsEqualsToImpl(org.geotools.filter.IsEqualsToImpl) PropertyIsEqualToLiteral(ddf.catalog.filter.impl.PropertyIsEqualToLiteral)

Example 2 with PropertyIsEqualToLiteral

use of ddf.catalog.filter.impl.PropertyIsEqualToLiteral in project ddf by codice.

the class OpenSearchFilterVisitorTest method testPropertyIsEqualToLiteral.

@Test
public void testPropertyIsEqualToLiteral() {
    PropertyIsEqualTo propertyIsEqualToLiteralFilter = new PropertyIsEqualToLiteral(new PropertyNameImpl(ID_ATTRIBUTE_NAME), new LiteralImpl(TEST_STRING));
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(propertyIsEqualToLiteralFilter, openSearchFilterVisitorObject);
    assertThat(result.getId(), is(TEST_STRING));
}
Also used : LiteralImpl(ddf.catalog.filter.impl.LiteralImpl) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) PropertyIsEqualToLiteral(ddf.catalog.filter.impl.PropertyIsEqualToLiteral) PropertyNameImpl(ddf.catalog.filter.impl.PropertyNameImpl) Test(org.junit.Test)

Aggregations

PropertyIsEqualToLiteral (ddf.catalog.filter.impl.PropertyIsEqualToLiteral)2 LiteralImpl (ddf.catalog.filter.impl.LiteralImpl)1 PropertyNameImpl (ddf.catalog.filter.impl.PropertyNameImpl)1 Expression (org.geotools.filter.Expression)1 IsEqualsToImpl (org.geotools.filter.IsEqualsToImpl)1 Test (org.junit.Test)1 PropertyIsEqualTo (org.opengis.filter.PropertyIsEqualTo)1