private Filter standardFilter(Class<? extends CatalogInfo> clazz) { final Filter forGlobal; if (LocalWorkspace.get() != null) { // TODO need a well known implementation // Show globals unless an object with the same name is in the local workspace forGlobal = super.getSecurityFilter(clazz); } else { // Global request, show all globals forGlobal = Predicates.acceptAll(); } // If it's a global use the global filter, otherwise check if it's in the local workspace return Predicates.or( Predicates.and(Predicates.isNull("workspace.id"), forGlobal), Predicates.and( Predicates.factory.not(Predicates.isNull("workspace.id")), inWorkspace())); }
public Filter buildNotFilter() throws CQLException { Filter right = this.resultStack.popFilter(); Filter logicFilter = null; if (Filter.INCLUDE.equals(right)) { logicFilter = Filter.EXCLUDE; } else if (Filter.EXCLUDE.equals(right)) { logicFilter = Filter.INCLUDE; } else { logicFilter = filterFactory.not(right); } return logicFilter; }
public void testNegateEquals() { Filter f = ff.not(ff.equals(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.notEqual(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
/** * Builds a not equal filter with that evaluate the relate pattern function * * @return Not filter * @throws CQLException */ public Not buildNotRelatePattern() throws CQLException { PropertyIsEqualTo eq = buildRelatePattern(); Not notFilter = getFilterFactory().not(eq); return notFilter; }
@Test public void testVisitLogicalNOTFilter() throws Exception { Filter f1 = createPropertyIsEqualToFilter(nameAtt, "david"); runTest(ff.not(f1), simpleLogicalCaps, nameAtt); }
public void testDualFilterNullOr() { Filter original = ff.or( Arrays.asList( ff.not(ff.isNull(ff.property("a"))), ff.isNull(ff.property("a")))); assertEquals(Filter.INCLUDE, original.accept(simpleVisitor, null)); }
public void testDualFilterNullAnd() { Filter original = ff.and( Arrays.asList( ff.not(ff.isNull(ff.property("a"))), ff.isNull(ff.property("a")))); assertEquals(Filter.EXCLUDE, original.accept(simpleVisitor, null)); }
public void testNegateBetween() { PropertyName prop = ff.property("prop"); Literal l10 = ff.literal(10); Literal l20 = ff.literal(20); Filter f = ff.not(ff.between(prop, l10, l20)); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals( ff.or(Arrays.asList((Filter) ff.less(prop, l10), ff.greater(prop, l20))), result); }
public void testDualFilterAnd() { Filter original = ff.and( Arrays.asList( ff.not(ff.equal(ff.property("a"), ff.literal(3), true)), ff.equal(ff.property("a"), ff.literal(3), true))); assertEquals(Filter.EXCLUDE, original.accept(simpleVisitor, null)); }
public void testDualFilterOr() { Or or = ff.or( Arrays.asList( ff.not(ff.equal(ff.property("a"), ff.literal(3), true)), ff.equal(ff.property("a"), ff.literal(3), true))); assertEquals(Filter.INCLUDE, or.accept(simpleVisitor, null)); }
public void testSimplifyNegateImpossible() throws Exception { PropertyIsEqualTo propertyIsEqualTo = ff.equal(ff.literal("a"), ff.literal("b"), true); Not negated = ff.not(propertyIsEqualTo); SimplifyingFilterVisitor visitor = new SimplifyingFilterVisitor(); SimpleFeatureType schema = DataUtilities.createType("test", "pop:String"); visitor.setFeatureType(schema); Filter simplified = (Filter) negated.accept(visitor, null); assertEquals(Filter.INCLUDE, simplified); } }
public void testNotFilter() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); Filter f = ff.equal(ff.property(aname("stringProperty")), ff.literal("one"), true); f = ff.not(f); assertEquals( featureSource.getCount(Query.ALL) - 1, featureSource.getCount(new Query(null, f))); }
public void testSimpleNegation() throws Exception { Not filter = ff.not(ff.equal(ff.property(aname(A)), ff.literal(10), false)); ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC)); int count = fs.getCount(new Query(tname(ABC), filter)); assertEquals(2, count); }
public void testNegateLessOrEqual() { Filter f = ff.not(ff.lessOrEqual(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.greater(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testNegateGreater() { Filter f = ff.not(ff.greater(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.lessOrEqual(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testNegateGreaterOrEqual() { Filter f = ff.not(ff.greaterOrEqual(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.less(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testNegateLess() { Filter f = ff.not(ff.less(ff.property("prop"), ff.literal(10))); Filter result = (Filter) f.accept(simpleVisitor, null); assertEquals(ff.greaterOrEqual(ff.property("prop"), ff.literal(10)), result); // not simplified for complex features result = (Filter) f.accept(complexVisitor, null); assertEquals(f, result); }
public void testNegated() throws IOException { FilterFactory ff = dataStore.getFilterFactory(); Function function = ff.function( "in", ff.property(aname("intProperty")), ff.literal("1"), ff.literal("2")); Filter filter = ff.not(ff.equal(function, ff.literal("true"), false)); SimpleFeatureSource fs = dataStore.getFeatureSource(tname("ft1")); SimpleFeatureCollection fc = fs.getFeatures(filter); assertEquals(getCaseInsensitiveSet("ft1.0"), collectFeatureIds(fc)); }