use of org.opengis.filter.PropertyIsLike in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsFuzzy.
@Test
public void testVisitPropertyIsFuzzy() {
visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
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 sldeditor by robward-scisys.
the class ExpressionPanelv2 method addFilter.
/**
* Adds the filter.
*
* @param node the node
* @return the filter
*/
private Filter addFilter(FilterNode node) {
Filter filter = node.getFilter();
FilterConfigInterface filterConfig = node.getFilterConfig();
if (filter instanceof LogicFilterImpl) {
List<Filter> filterList = new ArrayList<Filter>();
createFilterList(node, filterList);
return filterConfig.createLogicFilter(filterList);
}
List<Expression> parameterFilter = new ArrayList<Expression>();
if (filter instanceof FidFilterImpl) {
createExpressionParameterList(node, 1, parameterFilter);
} else if (filter instanceof BinaryTemporalOperator) {
createExpressionParameterList(node, 2, parameterFilter);
} else if (filter instanceof PropertyIsBetween) {
createExpressionParameterList(node, 3, parameterFilter);
} else if (filter instanceof PropertyIsNull) {
createExpressionParameterList(node, 1, parameterFilter);
} else if (filter instanceof PropertyIsLike) {
createExpressionParameterList(node, 6, parameterFilter);
} else if (filter instanceof BinarySpatialOperator) {
createExpressionParameterList(node, 2, parameterFilter);
} else if (filter instanceof BinaryComparisonAbstract) {
if (filter instanceof Not) {
createExpressionParameterList(node, 1, parameterFilter);
} else if (filter instanceof PropertyIsGreaterThan) {
createExpressionParameterList(node, 2, parameterFilter);
} else {
createExpressionParameterList(node, 3, parameterFilter);
}
} else {
return filter;
}
return filterConfig.createFilter(parameterFilter);
}
use of org.opengis.filter.PropertyIsLike in project sldeditor by robward-scisys.
the class FilterPanelv2 method addFilter.
/**
* Adds the filter.
*
* @param node the node
* @return the filter
*/
private Filter addFilter(FilterNode node) {
Filter filter = node.getFilter();
FilterConfigInterface filterConfig = node.getFilterConfig();
if (filter instanceof LogicFilterImpl) {
List<Filter> filterList = new ArrayList<Filter>();
createFilterList(node, filterList);
return filterConfig.createLogicFilter(filterList);
}
List<Expression> parameterFilter = new ArrayList<Expression>();
if (filter instanceof FidFilterImpl) {
createExpressionParameterList(node, 1, parameterFilter);
} else if (filter instanceof BinaryTemporalOperator) {
createExpressionParameterList(node, 2, parameterFilter);
} else if (filter instanceof PropertyIsBetween) {
createExpressionParameterList(node, 3, parameterFilter);
} else if (filter instanceof PropertyIsNull) {
createExpressionParameterList(node, 1, parameterFilter);
} else if (filter instanceof PropertyIsLike) {
createExpressionParameterList(node, 6, parameterFilter);
} else if (filter instanceof BinarySpatialOperator) {
createExpressionParameterList(node, 2, parameterFilter);
} else if (filter instanceof BinaryComparisonAbstract) {
if (filter instanceof Not) {
createExpressionParameterList(node, 1, parameterFilter);
} else if (filter instanceof PropertyIsGreaterThan) {
createExpressionParameterList(node, 2, parameterFilter);
} else {
createExpressionParameterList(node, 3, parameterFilter);
}
} else {
return filter;
}
return filterConfig.createFilter(parameterFilter);
}
use of org.opengis.filter.PropertyIsLike in project ddf by codice.
the class OpenSearchFilterVisitorTest method testPropertyIsLikeAnd.
@Test
public void testPropertyIsLikeAnd() {
PropertyIsLike textLikeFilter = (PropertyIsLike) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).is().like().text(TEST_STRING);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
assertThat(result.getContextualSearch(), allOf(is(notNullValue()), hasProperty("searchPhraseMap", hasEntry(OpenSearchConstants.SEARCH_TERMS, "test AND test"))));
}
use of org.opengis.filter.PropertyIsLike in project ddf by codice.
the class OpenSearchFilterVisitorTest method testPropertyIsLikeNonSearchTerm.
@Test
public void testPropertyIsLikeNonSearchTerm() {
PropertyIsLike textLikeFilter = (PropertyIsLike) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).is().like().text(TEST_STRING);
OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
Map<String, String> searchPhraseMap = new HashMap<>();
searchPhraseMap.put("anotherTerm", TEST_STRING);
openSearchFilterVisitorObject.setContextualSearch(new ContextualSearch(SOME_ATTRIBUTE_NAME, searchPhraseMap, true));
OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
assertThat(result.getContextualSearch(), allOf(is(notNullValue()), hasProperty("searchPhraseMap", hasEntry(OpenSearchConstants.SEARCH_TERMS, TEST_STRING))));
}
Aggregations