private CatalogInfo replaceCatalogInfo(CatalogInfo ci) { String id = ci.getId(); Catalog catalog = (Catalog) GeoServerExtensions.bean("catalog"); FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Class iface = getCatalogInfoInterface(ci.getClass()); CatalogInfo replacement = catalog.get(iface, ff.equal(ff.property("id"), ff.literal(id), true)); return replacement; }
public void setGeometryPropertyName(String geometryPropertyName) { if (geometryPropertyName == null) { geometry = null; } else { org.opengis.filter.FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); geometry = ff.property(geometryPropertyName); } }
/** * Returns a predicate that checks a CatalogInfo object's property for inequality with the * provided property value. * * <p>The <tt>property</tt> parameter may be specified as a "path" of the form "prop1.prop2". If * any of the resulting properties along the path result in null this method will return null. * * <p>Indexed access to nested list and array properties is supported through the syntax {@code * "prop1[M].prop2.prop3[N]"}, where {@code prop1} and {@code prop3} are list or array * properties, {@code M} is the index of the {@code prop2} element to retrieve from {@code * prop1}, and {@code N} is the index of array or list property {@code prop3} to retrieve. * Indexed access to {{java.util.Set}} properties is <b>not</b> supported. * * <p>Evaluation of nested properties for <b>any</b> member of a collection property is at the * moment not supported * * <p> * * @param property the qualified property name of the predicate's input object to evaluate * @param expected the value to check the input object's property against * @see PropertyIsEqualTo */ public static Filter notEqual(final String property, final Object expected) { return factory.notEqual(factory.property(property), factory.literal(expected)); } }
FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); dq.setFilter(ff.greater(ff.property("PERSONS"), ff.literal(20000000))); FeatureCollection fc = fs.getFeatures(dq); if (fc.size() != 1) {
private Expression toExpression(int attributeTypeIndex, SimpleFeatureType type) { FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null); AttributeDescriptor attribute = type.getDescriptor(attributeTypeIndex); if (attribute == null) { throw new IllegalArgumentException( "Attribute index '" + attributeTypeIndex + "' is not valid."); } return filterFactory.property(attribute.getLocalName()); }
filter = factory.equal(factory.literal(ft1.getId()), factory.property("id"), true); expected = Sets.newHashSet(ft1); actual = Sets.newHashSet(catalog.list(ResourceInfo.class, filter)); filter = factory.equal(factory.literal("FT1"), factory.property("name"), false); expected = Sets.newHashSet(ft1); actual = Sets.newHashSet(catalog.list(ResourceInfo.class, filter)); filter = factory.equal(factory.property("name"), factory.property("description"), true); expected = Sets.newHashSet(ft2); actual = Sets.newHashSet(catalog.list(ResourceInfo.class, filter)); filter = factory.equal(factory.property("name"), factory.property("description"), false); expected = Sets.newHashSet(ft2, ft3); actual = Sets.newHashSet(catalog.list(ResourceInfo.class, filter)); factory.literal(new Keyword("keyword1")), factory.property("keywords"), true, MatchAction.ANY); factory.property("keywords"), true, MatchAction.ALL); factory.property("keywords"), true, MatchAction.ONE);
private Expression toExpression(String attributeName, SimpleFeatureType type) { FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null); AttributeDescriptor attribute = type.getDescriptor(attributeName); if (attribute == null) { throw new IllegalArgumentException("Attribute '" + attributeName + "' is not valid."); } return filterFactory.property(attribute.getLocalName()); }
private Filter getFilter() throws IllegalFilterException { FilterFactory fac = CommonFactoryFinder.getFilterFactory(null); Filter f = fac.equals(fac.property("name"), fac.literal("name2")); return f; }
public MedianVisitor(int attributeTypeIndex, SimpleFeatureType type) throws IllegalFilterException { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); expr = factory.property(type.getDescriptor(attributeTypeIndex).getLocalName()); }
public Function buildInFunction(String functionName, Object[] valueList) { Stream<Literal> values = Arrays.stream(valueList).map(v -> filterFac.literal(v)); Stream<PropertyName> property = Stream.of(filterFac.property("testAttr")); Expression[] literals = Stream.concat(property, values).toArray(i -> new Expression[i]); return filterFac.function(functionName, literals); } }
public void testEquals() throws Exception { org.opengis.filter.FilterFactory ff = CommonFactoryFinder.getFilterFactory(); PropertyIsBetween f1 = ff.between(ff.property("abc"), ff.literal(10), ff.literal(20)); PropertyIsBetween f2 = ff.between(ff.property("efg"), ff.literal(10), ff.literal(20)); PropertyIsBetween f3 = ff.between(ff.property("abc"), ff.literal(10), ff.literal(20)); assertEquals(f1, f3); assertFalse(f1.equals(f2)); } }
public MaxVisitor(int attributeTypeIndex, SimpleFeatureType type) throws IllegalFilterException { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); expr = factory.property(type.getDescriptor(attributeTypeIndex).getLocalName()); }
public void testSimpleExpressions() { final String exp = "I'm a ${name} expression of type ${type}"; List<Expression> result = ExpressionExtractor.splitCqlExpressions(exp); assertEquals(4, result.size()); assertEquals(ff.literal("I'm a "), result.get(0)); assertEquals(ff.property("name"), result.get(1)); assertEquals(ff.literal(" expression of type "), result.get(2)); assertEquals(ff.property("type"), result.get(3)); }
private SimpleFeatureSource getView() throws IllegalFilterException, IOException, SchemaException { FilterFactory fac = CommonFactoryFinder.getFilterFactory(null); Filter f = fac.less(fac.property("id"), fac.literal(3)); SimpleFeatureSource view = DataUtilities.createView(fs, new Query(typeName, f)); return view; } }
public SumVisitor(int attributeTypeIndex, SimpleFeatureType type) throws IllegalFilterException { FilterFactory factory = CommonFactoryFinder.getFilterFactory(null); AttributeDescriptor attributeType = type.getDescriptor(attributeTypeIndex); expr = factory.property(attributeType.getLocalName()); createStrategy(attributeType.getType().getBinding()); }
protected PropertyIsEqualTo createFunctionFilter() throws Exception { FilterFunction_geometryType geomTypeExpr = new FilterFunction_geometryType(); geomTypeExpr.setParameters(Arrays.asList(new Expression[] {ff.property("geom")})); PropertyIsEqualTo filter = ff.equals(geomTypeExpr, ff.literal("Polygon")); return filter; }
public void testGetFeatureWriterInvalidFilter() { FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); PropertyIsEqualTo f = ff.equals(ff.property("invalidAttribute"), ff.literal(5)); // make sure a complaint related to the invalid filter is thrown here try (FeatureWriter<SimpleFeatureType, SimpleFeature> writer = dataStore.getFeatureWriter("river", f, Transaction.AUTO_COMMIT)) { fail("This query should have failed, it contains an invalid filter"); } catch (Exception e) { // fine } }