use of org.opengis.filter.PropertyIsLike in project ddf by codice.
the class OpenSearchFilterVisitorTest method testPropertyLikeWildcard.
@Test
public void testPropertyLikeWildcard() {
FilterFactory2 factory = new FilterFactoryImpl();
PropertyIsLike textLikeFilter = factory.like(factory.property(Core.TITLE), UI_WILDCARD, UI_WILDCARD, "'", "_", false);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
assertThat(result.getContextualSearch(), allOf(is(notNullValue()), hasProperty("searchPhraseMap", hasEntry(OpenSearchConstants.SEARCH_TERMS, WILDCARD))));
}
use of org.opengis.filter.PropertyIsLike 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.PropertyIsLike in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsFuzzy.
@Test
public void testVisitPropertyIsFuzzy() {
visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
Expression val1 = factory.property("fooProperty");
Expression val2 = factory.literal("fooLiteral");
// PropertyIsFuzzy maps to a propertyIsLike filter with a fuzzy function
GeotoolsFilterBuilder builder = new GeotoolsFilterBuilder();
PropertyIsLike fuzzySearch = (PropertyIsLike) builder.attribute(val1.toString()).is().like().fuzzyText(val2.toString());
PropertyIsLike visitedFilter = (PropertyIsLike) visitor.visit(fuzzySearch, null);
assertThat(visitedFilter.getExpression(), is(instanceOf(FuzzyFunction.class)));
assertThat(visitedFilter.getLiteral(), is(val2.toString()));
}
use of org.opengis.filter.PropertyIsLike 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));
}
use of org.opengis.filter.PropertyIsLike in project sldeditor by robward-scisys.
the class FilterNode method setFilter.
/**
* Sets the filter.
*
* @param filter the new expression
* @param filterConfig the filter config
*/
public void setFilter(Filter filter, FilterConfigInterface filterConfig) {
this.filter = filter;
this.filterConfig = filterConfig;
setDisplayString();
this.removeAllChildren();
TypeManager.getInstance().reset();
if (filterConfig != null) {
FilterName filterName = filterConfig.getFilterConfiguration();
if (filter instanceof Not) {
List<Filter> childFilterList = ((LogicFilterImpl) filter).getChildren();
if (childFilterList.isEmpty()) {
// No child filter so add a minimum 1 to work with.
setFilterParameter(null, filterName.getParameter(0));
} else {
setFilterParameter(childFilterList.get(0), filterName.getParameter(0));
}
} else if (filter instanceof LogicFilterImpl) {
List<Filter> childFilterList = ((LogicFilterImpl) filter).getChildren();
if (childFilterList.isEmpty()) {
// No child filter so add a minimum 2 to work with.
setFilterParameter(null, filterName.getParameter(0));
setFilterParameter(null, filterName.getParameter(0));
} else {
for (Filter childFilter : childFilterList) {
setFilterParameter(childFilter, filterName.getParameter(0));
}
}
} else if (filter instanceof BinaryTemporalOperator) {
setExpressionParameter(((BinaryTemporalOperator) filter).getExpression1(), filterName.getParameter(0));
setExpressionParameter(((BinaryTemporalOperator) filter).getExpression2(), filterName.getParameter(1));
} else if (filter instanceof PropertyIsNull) {
setExpressionParameter(((PropertyIsNull) filter).getExpression(), filterName.getParameter(0));
} else if (filter instanceof PropertyIsBetween) {
setExpressionParameter(((PropertyIsBetween) filter).getLowerBoundary(), filterName.getParameter(0));
setExpressionParameter(((PropertyIsBetween) filter).getExpression(), filterName.getParameter(1));
setExpressionParameter(((PropertyIsBetween) filter).getUpperBoundary(), filterName.getParameter(2));
} else if (filter instanceof PropertyIsLike) {
setExpressionParameter(((PropertyIsLike) filter).getExpression(), filterName.getParameter(0));
setExpressionParameter(ff.literal(((PropertyIsLike) filter).getLiteral()), filterName.getParameter(1));
setExpressionParameter(ff.literal(((PropertyIsLike) filter).getWildCard()), filterName.getParameter(2));
setExpressionParameter(ff.literal(((PropertyIsLike) filter).getSingleChar()), filterName.getParameter(3));
setExpressionParameter(ff.literal(((PropertyIsLike) filter).getEscape()), filterName.getParameter(4));
setExpressionParameter(ff.literal(((PropertyIsLike) filter).isMatchingCase()), filterName.getParameter(5));
} else if (filter instanceof BinarySpatialOperator) {
setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression1(), filterName.getParameter(0));
setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression2(), filterName.getParameter(1));
} else if (filter instanceof BinaryComparisonAbstract) {
setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression1(), filterName.getParameter(0));
setExpressionParameter(((BinaryComparisonAbstract) filter).getExpression2(), filterName.getParameter(1));
// which has no matchCase parameter
if (filterName.getParameterList().size() > 2) {
setExpressionParameter(ff.literal(((BinaryComparisonAbstract) filter).isMatchingCase()), filterName.getParameter(2));
}
}
}
}
Aggregations