Refine search
/** * Returns a filter that will check if the object passed to it can be accessed by the user * * @param resourceAccesssManager * @param user */ public static Filter buildUserAccessFilter( ResourceAccessManager resourceAccesssManager, Authentication user) { org.opengis.filter.expression.Function visible = new InMemorySecurityFilter(resourceAccesssManager, user); FilterFactory factory = Predicates.factory; // create a filter combined with the security credentials check Filter filter = factory.equals(factory.literal(Boolean.TRUE), visible); return filter; }
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; }
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 testStringContext() throws Exception { Expression literal = filterFac.literal(5); Expression prop = filterFac.property(stringFType.getAttributeDescriptors().get(0).getLocalName()); PropertyIsEqualTo filter = filterFac.equals(prop, literal); encoder.setFeatureType(stringFType); encoder.encode(filter); LOGGER.fine("testAttr is a String " + filter + " -> " + output.getBuffer().toString()); assertEquals(output.getBuffer().toString(), "WHERE testAttr = '5'"); }
public void testIntegerContext() throws Exception { Expression literal = filterFac.literal(5); Expression prop = filterFac.property(integerFType.getAttributeDescriptors().get(0).getLocalName()); PropertyIsEqualTo filter = filterFac.equals(prop, literal); encoder.setFeatureType(integerFType); encoder.encode(filter); LOGGER.fine("testAttr is an Integer " + filter + " -> " + output.getBuffer().toString()); assertEquals(output.getBuffer().toString(), "WHERE testAttr = 5"); }
public void testTimestampContext() throws Exception { Expression literal = filterFac.literal("2002-12-03 10:00"); Expression prop = filterFac.property(timestampFType.getAttributeDescriptors().get(0).getLocalName()); PropertyIsEqualTo filter = filterFac.equals(prop, literal); encoder.setFeatureType(timestampFType); encoder.encode(filter); LOGGER.fine("testAttr is a Timestampa " + filter + " -> " + output.getBuffer().toString()); assertEquals(output.getBuffer().toString(), "WHERE testAttr = '2002-12-03 10:00'"); }
public void testIntegerToNumberContext() throws Exception { Expression literal = filterFac.literal(5.0); Expression prop = filterFac.property(integerFType.getAttributeDescriptors().get(0).getLocalName()); PropertyIsEqualTo filter = filterFac.equals(prop, literal); encoder.setFeatureType(integerFType); encoder.encode(filter); LOGGER.fine("testAttr is an Integer " + filter + " -> " + output.getBuffer().toString()); assertEquals(output.getBuffer().toString(), "WHERE testAttr = 5.0"); }
public void testAfterInstant() throws Exception { Date date = convert("2002-12-03 10:00:00AM", Date.class); DefaultInstant instant = new DefaultInstant(new DefaultPosition(date)); Expression literal = filterFac.literal(instant); Expression prop = filterFac.property(timestampFType.getAttributeDescriptors().get(0).getLocalName()); PropertyIsEqualTo filter = filterFac.equals(prop, literal); encoder.setFeatureType(timestampFType); encoder.encode(filter); LOGGER.fine("testAttr is a Timestamp " + filter + " -> " + output.getBuffer().toString()); assertEquals(output.getBuffer().toString(), "WHERE testAttr = '2002-12-03 10:00:00.0'"); }
public void testGetFeaturesWithInvalidFilter() throws Exception { 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 (SimpleFeatureIterator fi = featureSource.getFeatures(f).features()) { fail("This query should have failed, it contains an invalid filter"); } catch (Exception e) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", e); // fine } }
public void testStrfunc() throws IOException { if (skipTests(FilterFunction_strConcat.class)) { return; } Function func = ff.function("strConcat", ff.property(aname("stringProperty")), ff.literal("abc")); Filter filter = ff.equals(func, ff.literal("zeroabc")); assertFeatures(fs, filter, tname("ft1") + ".0"); }
public void testStrStartsWith() throws IOException { if (skipTests(FilterFunction_strStartsWith.class)) { return; } Function func = ff.function( "strStartsWith", ff.property(aname("stringProperty")), ff.literal("ze")); Filter filter = ff.equals(func, ff.literal(true)); assertFeatures(fs, filter, tname("ft1") + ".0"); }
public void testStrSubstringStart() throws IOException { if (skipTests(FilterFunction_strSubstringStart.class)) { return; } // intentionally mixing string and int literals Function func = ff.function( "strSubstringStart", ff.property(aname("stringProperty")), ff.literal("1")); Filter filter = ff.equals(func, ff.literal("ero")); assertFeatures(fs, filter, tname("ft1") + ".0"); }