org.opengis.filter.PropertyIsLike Java Examples

The following examples show how to use org.opengis.filter.PropertyIsLike. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticCapabilities.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
public ElasticCapabilities() {
    super(new ElasticFilterCapabilities());

    addAll(LOGICAL_OPENGIS);
    addAll(SIMPLE_COMPARISONS_OPENGIS);
    addType(PropertyIsNull.class);
    addType(PropertyIsBetween.class);
    addType(Id.class);
    addType(IncludeFilter.class);
    addType(ExcludeFilter.class);
    addType(PropertyIsLike.class);

    // spatial filters
    addType(BBOX.class);
    addType(Contains.class);
    //addType(Crosses.class);
    addType(Disjoint.class);
    //addType(Equals.class);
    addType(Intersects.class);
    //addType(Overlaps.class);
    //addType(Touches.class);
    addType(Within.class);
    addType(DWithin.class);
    addType(Beyond.class);

    //temporal filters
    addType(After.class);
    addType(Before.class);
    addType(Begins.class);
    addType(BegunBy.class);
    addType(During.class);
    addType(Ends.class);
    addType(EndedBy.class);
    addType(TContains.class);
    addType(TEquals.class);
}
 
Example #2
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testPropertyIsLike() {
    PropertyIsLike filter = ff.like(ff.property("analyzed"), "hello");
    Map<String,Object> expected = ImmutableMap.of("query_string",
            ImmutableMap.of("query", "hello", "default_field", "analyzed"));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #3
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testCaseSensitivePropertyIsLike() {
    PropertyIsLike filter = ff.like(ff.property("analyzed"), "hello", "\\", "*", ".", true);
    Map<String,Object> expected = ImmutableMap.of("query_string",
            ImmutableMap.of("query", "hello", "default_field", "analyzed"));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected, builder.getQueryBuilder());
}
 
Example #4
Source File: ElasticFilterTest.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNestedPropertyIsLike() {
    PropertyIsLike filter = ff.like(ff.property("nested.hej"), "hello");
    Map<String,Object> expectedFilter = ImmutableMap.of("query_string",
            ImmutableMap.of("query", "hello", "default_field", "nested.hej"));
    Map<String,Object> expected = ImmutableMap.of("nested",
            ImmutableMap.of("path", "nested", "query", expectedFilter));

    builder.visit(filter, null);
    assertTrue(builder.createCapabilities().fullySupports(filter));
    assertEquals(expected,builder.getQueryBuilder());
}
 
Example #5
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testGetFeaturesWithIsLikeFilter() throws Exception {
    init();
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyIsLike f = ff.like(ff.property("standard_ss"), "IEEE 802.11?");
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(11, features.size());
}
 
Example #6
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final PropertyIsLike filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #7
Source File: PropertyIgnoringFilterVisitor.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public Object visit(final PropertyIsLike filter, final Object extraData) {
  if (!usesProperty(filter)) {
    return Filter.INCLUDE;
  }
  return super.visit(filter, extraData);
}
 
Example #8
Source File: CriteriaVisitor.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(PropertyIsLike filter, Object userData) {
	String propertyName = getPropertyName(filter.getExpression());
	String finalName = parsePropertyName(propertyName, userData);

	String value = filter.getLiteral();
	value = value.replaceAll("\\*", "%");
	value = value.replaceAll("\\?", "_");
	if (filter.isMatchingCase()) {
		return Restrictions.like(finalName, value);
	} else {
		return Restrictions.ilike(finalName, value);
	}
}
 
Example #9
Source File: ExtendedFilterFactory.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public PropertyIsLike like(Expression expr, String pattern, String wildcard, String singleChar,
		String escape) {

	ExtendedLikeFilterImpl filter = new ExtendedLikeFilterImpl();
	filter.setExpression(expr);
	filter.setPattern(pattern, wildcard, singleChar, escape);

	return filter;
}
 
Example #10
Source File: FilterNode.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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) {
            setNotFilter(filter, filterName);
        } else if (filter instanceof LogicFilterImpl) {
            setLogicFilter(filter, filterName);
        } 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));
            setExpressionStringSizeParameter(
                    ff.literal(((PropertyIsLike) filter).getWildCard()),
                    filterName.getParameter(2),
                    1,
                    true);
            setExpressionStringSizeParameter(
                    ff.literal(((PropertyIsLike) filter).getSingleChar()),
                    filterName.getParameter(3),
                    1,
                    true);
            setExpressionStringSizeParameter(
                    ff.literal(((PropertyIsLike) filter).getEscape()),
                    filterName.getParameter(4),
                    1,
                    true);
            setExpressionParameter(
                    ff.literal(((PropertyIsLike) filter).isMatchingCase()),
                    filterName.getParameter(5));
        } else if (filter instanceof BinarySpatialOperator) {
            setBinarySpatialOperator(filter, filterName);
        } else if (filter instanceof BinaryComparisonAbstract) {
            setBinaryComparisonAbstract(filter, filterName);
        } else if (filter instanceof FidFilterImpl) {
            FidFilterImpl fidFilter = (FidFilterImpl) filter;

            for (Identifier identifier : fidFilter.getIdentifiers()) {
                setExpressionParameter(ff.literal(identifier), filterName.getParameter(0));
            }
        }
    }
}
 
Example #11
Source File: FilterPanelv2.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter nodeFilter = node.getFilter();

    FilterConfigInterface filterConfig = node.getFilterConfig();

    if (nodeFilter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<>();

        createFilterList(node, filterList);

        return filterConfig.createLogicFilter(filterList);
    }

    List<Expression> parameterFilter = new ArrayList<>();

    if (originalFilter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (originalFilter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (originalFilter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (originalFilter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (originalFilter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (originalFilter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (originalFilter instanceof BinaryComparisonAbstract) {
        if (originalFilter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (originalFilter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return nodeFilter;
    }

    return filterConfig.createFilter(parameterFilter);
}
 
Example #12
Source File: FilterToElastic.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Writes the FilterBuilder for the Like Filter.
 *
 * @param filter the filter to be visited
 *
 */
public Object visit(PropertyIsLike filter, Object extraData) {
    char esc = filter.getEscape().charAt(0);
    char multi = filter.getWildCard().charAt(0);
    char single = filter.getSingleChar().charAt(0);
    if (filter.isMatchingCase()) {
        LOGGER.fine("Case sensitive search not supported");
    }

    String literal = filter.getLiteral();
    Expression att = filter.getExpression();

    AttributeDescriptor attType = (AttributeDescriptor) att.evaluate(featureType);
    Boolean analyzed = false;
    nested = false;
    if (attType != null) {
        if (attType.getUserData().containsKey(ANALYZED)) {
            analyzed = (Boolean) attType.getUserData().get(ANALYZED);
        }
        if (attType.getUserData().containsKey(NESTED)) {
            nested = (Boolean) attType.getUserData().get(NESTED);
        }
        if (Date.class.isAssignableFrom(attType.getType().getBinding())) {
            updateDateFormatter(attType);
        }
    }

    att.accept(this, extraData);
    key = (String) field;

    String pattern;
    if (analyzed) {
        // use query string query post filter for analyzed fields
        pattern = convertToQueryString(esc, multi, single, literal);
    } else {
        // default to regexp filter
        pattern = convertToRegex(esc, multi, single, literal);
    }
    if (nested) {
        path = extractNestedPath(key);
    }

    if (analyzed) {
        // use query string query for analyzed fields
        queryBuilder = ImmutableMap.of("query_string", ImmutableMap.of("query", pattern, "default_field", key));
    } else {
        // default to regexp query
        queryBuilder = ImmutableMap.of("regexp", ImmutableMap.of(key, pattern));
    }
    if (nested) {
        queryBuilder = ImmutableMap.of("nested", ImmutableMap.of("path", path, "query", queryBuilder));
    }

    return extraData;
}
 
Example #13
Source File: ExtractGeometryFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final PropertyIsLike filter, final Object data) {
  return new ExtractGeometryFilterVisitorResult(infinity(), null);
}
 
Example #14
Source File: ExtractTimeFilterVisitor.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Object visit(final PropertyIsLike filter, final Object data) {
  return new TemporalConstraints();
}