use of org.opengis.filter.expression.Expression in project ddf by codice.
the class GeoToolsFunctionFactoryTest method testFuzzyFunction.
@Test
public void testFuzzyFunction() {
List<Expression> expr = new ArrayList<>();
expr.add(Expression.NIL);
Function result = toTest.function(FuzzyFunction.NAME.getName(), expr, null);
assertThat(result.getName(), is(FuzzyFunction.NAME.getName()));
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class GeoToolsFunctionFactoryTest method testFunctionForValidNameWithTooManyExpressions.
@Test(expected = IllegalArgumentException.class)
public void testFunctionForValidNameWithTooManyExpressions() {
List<Expression> expr = new ArrayList<>();
expr.add(Expression.NIL);
expr.add(Expression.NIL);
Function result = toTest.function(FuzzyFunction.NAME.getName(), expr, null);
assertThat(result.getName(), is(FuzzyFunction.NAME.getName()));
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class MockQuery method addTypeFilter.
public void addTypeFilter(List<MockTypeVersionsExtension> extensionList) {
List<Filter> runningFilterList = new ArrayList<Filter>();
for (MockTypeVersionsExtension e : extensionList) {
String type = e.getExtensionTypeName();
List<String> versions = e.getVersions();
Filter oneTypeFilter = null;
Expression expressionType = FILTER_FACTORY.property(Metacard.CONTENT_TYPE);
Expression expressionVersion = FILTER_FACTORY.property(Metacard.CONTENT_TYPE_VERSION);
// Logically 'AND' the type and versions together
if (versions != null && !versions.isEmpty()) {
List<Filter> andedTypeVersionPairs = new ArrayList<Filter>();
for (String v : versions) {
if (v != null) {
PropertyIsLike typeFilter = FILTER_FACTORY.like(expressionType, type, "*", "?", "\\", false);
PropertyIsLike versionFilter = FILTER_FACTORY.like(expressionVersion, v, "*", "?", "\\", false);
andedTypeVersionPairs.add(FILTER_FACTORY.and(typeFilter, versionFilter));
}
}
// Check if we had any pairs and logically 'OR' them together.
if (!andedTypeVersionPairs.isEmpty()) {
oneTypeFilter = FILTER_FACTORY.or(andedTypeVersionPairs);
} else {
// if we don't have any pairs, means we don't have versions, handle single type
oneTypeFilter = FILTER_FACTORY.like(expressionType, type, "*", "?", "\\", false);
}
} else {
// we do not have versions, handle single type case
oneTypeFilter = FILTER_FACTORY.like(expressionType, type, "*", "?", "\\", false);
}
runningFilterList.add(oneTypeFilter);
}
if (!runningFilterList.isEmpty()) {
Filter filter = FILTER_FACTORY.or(runningFilterList);
filters.add(filter);
}
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class MockQuery method addContextualFilter.
public void addContextualFilter(String searchPhrase, String textPathSections, boolean caseSensitive) {
Filter filter = null;
if (searchPhrase != null) {
if (textPathSections != null) {
List<Filter> xpathFilters = new ArrayList<Filter>();
String[] selectors = textPathSections.split(",");
for (int i = 0; i < selectors.length; i++) {
Expression xpathRef = new AttributeExpressionImpl(selectors[i]);
filter = FILTER_FACTORY.like(xpathRef, searchPhrase);
xpathFilters.add(filter);
}
filter = FILTER_FACTORY.or(xpathFilters);
} else {
filter = FILTER_FACTORY.like(FILTER_FACTORY.property(Metacard.ANY_TEXT), searchPhrase, SubscriptionFilterVisitor.LUCENE_WILDCARD_CHAR, SubscriptionFilterVisitor.LUCENE_SINGLE_CHAR, SubscriptionFilterVisitor.LUCENE_ESCAPE_CHAR, caseSensitive);
}
if (filter != null) {
filters.add(filter);
}
}
}
use of org.opengis.filter.expression.Expression in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsEqualTo.
@Test
public void testVisitPropertyIsEqualTo() {
Expression val = factory.literal("foo");
PropertyIsEqualTo filter = factory.equals(attrExpr, val);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(attrExpr));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(true));
}
Aggregations