public FeatureCollection<T, F> getFeatures(Filter filter) throws IOException { return getFeatures(new Query(null, filter)); }
public int lockFeatures(Filter filter) throws IOException { return lockDelegate.lockFeatures(new Query(null, filter)); }
public void unLockFeatures(Filter filter) throws IOException { unLockFeatures(new Query(null, filter)); }
public SimpleFeatureCollection getFeatures(Filter filter) throws IOException { return getFeatures(new Query(typeMap.getName(), filter)); }
public SimpleFeatureCollection getFeatures(Filter filter) throws IOException { return getFeatures(new Query(schema.getTypeName(), filter)); }
/** * Setup the WFS data source and add the DynamicStreetNotesSource to the graph */ @Override public void setup(Graph graph) throws IOException, FactoryException { LOG.info("Setup WFS polling updater"); HashMap<String, Object> connectionParameters = new HashMap<>(); connectionParameters.put(WFSDataStoreFactory.URL.key, url); WFSDataStore data = (new WFSDataStoreFactory()).createDataStore(connectionParameters); query = new Query(featureType); // Read only single feature type from the source query.setCoordinateSystem(CRS.decode("EPSG:4326", true)); // Get coordinates in WGS-84 featureSource = data.getFeatureSource(featureType); graph.streetNotesService.addNotesSource(notesSource); }
/** Returns a GeoTools query build with the provided attributes and filters */ private Query buildQuery(List<PropertyName> attributes, Filter filter) { if (attributes == null && (filter == null || filter == Filter.INCLUDE)) { return Query.ALL; } else { Query q = new Query(); q.setFilter(filter); // TODO: switch this to property names when possible q.setPropertyNames(flattenNames(attributes)); return q; } }
Query query = new Query("__BlobInfo__"); query.addFilter("filename", FilterOperator.EQUAL, filename); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); PreparedQuery pq = datastore.prepare(query); List<Entity> entList = pq.asList(FetchOptions.Builder.withLimit(1)); String name = entList.get(0).getKey().getName();
/** Builds the write query based on the access limits class */ public static Query getWriteQuery(WrapperPolicy policy) { if (policy.getAccessLevel() != AccessLevel.READ_WRITE) { return new Query(null, Filter.EXCLUDE); } else if (policy.getLimits() == null) { return Query.ALL; } else if (policy.getLimits() instanceof VectorAccessLimits) { VectorAccessLimits val = (VectorAccessLimits) policy.getLimits(); return val.getWriteQuery(); } else { throw new IllegalArgumentException( "SecureFeatureStore has been fed " + "with unexpected AccessLimits class " + policy.getLimits().getClass()); } }
/** * Retrieves the total extent of this FeatureSource. * * <p>Please note this extent will reflect the provided definitionQuery. * * @return Extent of this FeatureSource, or <code>null</code> if no optimizations exist. * @throws IOException If bounds of definitionQuery */ public ReferencedEnvelope getBounds() throws IOException { // since CRS is at most forced, we don't need to change this code if (definitionQuery == Filter.INCLUDE) { return source.getBounds(); } else { Query query = new Query(getSchema().getTypeName(), definitionQuery); return source.getBounds(query); } }
public SimpleFeatureCollection getFeatures(Query query) throws IOException { if (query.getTypeName() == null) { query = new Query(query); ((Query) query).setTypeName(typeMap.getName()); } else if (!typeMap.getName().equals(query.getTypeName())) { throw new IOException( "Cannot query this feature source with " + query.getTypeName() + " since it serves only " + typeMap.getName()); } // GEOS-3210, if the query specifies a subset of property names we need to take that into // account SimpleFeatureType target = typeMap.getFeatureType(query); return new RetypingFeatureCollection( wrapped.getFeatures(store.retypeQuery(query, typeMap)), target); }
public void removeFeatures(Filter filter) throws IOException { // are we limiting anything? Query writeQuery = getWriteQuery(policy); if (writeQuery == Query.ALL) { storeDelegate.removeFeatures(filter); } else if (writeQuery.getFilter() == Filter.EXCLUDE || writeQuery.getPropertyNames() == Query.NO_NAMES) { throw unsupportedOperation(); } // get the mixed filter final Query local = new Query(null, filter); Query mixed = mixQueries(local, writeQuery); storeDelegate.removeFeatures(mixed.getFilter()); }
@Test public void testDelete() throws Exception { final Query queryAll = new Query(RENAMED); SimpleFeatureStore store; store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED); int count = store.getCount(queryAll); store.removeFeatures(fidFilter); assertEquals(count - 1, store.getCount(queryAll)); }
@Test public void testDelete() throws Exception { final Query queryAll = new Query(RENAMED); SimpleFeatureStore store; store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED); int count = store.getCount(queryAll); store.removeFeatures(fidFilter); assertEquals(count - 1, store.getCount(queryAll)); }
@Test public void testGetFeaturesReader() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED), Transaction.AUTO_COMMIT); SimpleFeature sf = fr.next(); fr.close(); assertEquals(primitive, sf.getFeatureType()); // check the feature ids have been renamed as well assertTrue( "Feature id has not been renamed, it's still " + sf.getID(), sf.getID().startsWith(RENAMED)); }
@Test public void testGetFeaturesReader() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED), Transaction.AUTO_COMMIT); SimpleFeature sf = fr.next(); fr.close(); assertEquals(RENAMED, sf.getFeatureType().getName().getLocalPart()); // check the feature ids have been renamed as well assertTrue( "Feature id has not been renamed, it's still " + sf.getID(), sf.getID().startsWith(RENAMED)); }
@Test public void testFeatureReaderFidFilter() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED, fidFilter), Transaction.AUTO_COMMIT); assertEquals(primitive, fr.getFeatureType()); assertTrue(fr.hasNext()); SimpleFeature sf = fr.next(); assertFalse(fr.hasNext()); fr.close(); assertEquals(fid, sf.getID()); }
@Test public void testFeautureReaderFidFilter() throws Exception { FeatureReader<SimpleFeatureType, SimpleFeature> fr; fr = rts.getFeatureReader(new Query(RENAMED, fidFilter), Transaction.AUTO_COMMIT); assertEquals(RENAMED, fr.getFeatureType().getName().getLocalPart()); assertTrue(fr.hasNext()); SimpleFeature sf = fr.next(); assertFalse(fr.hasNext()); fr.close(); assertEquals(fid, sf.getID()); }
@Test public void testModify() throws Exception { final Query queryAll = new Query(RENAMED); SimpleFeatureStore store; store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED); SimpleFeature original = store.getFeatures(fidFilter).features().next(); String newAddress = ((String) original.getAttribute("ADDRESS")) + " xxx"; store.modifyFeatures( original.getFeatureType().getDescriptor("ADDRESS"), newAddress, fidFilter); SimpleFeature modified = store.getFeatures(fidFilter).features().next(); assertEquals(newAddress, modified.getAttribute("ADDRESS")); }
@Test public void testQueryWithPropertyNames() throws Exception { // check the schemas in feature source and feature collection SimpleFeatureSource fs = rts.getFeatureSource(RENAMED); Query q = new Query(RENAMED, Filter.INCLUDE, new String[] {"ADDRESS"}); FeatureCollection<SimpleFeatureType, SimpleFeature> fc = fs.getFeatures(q); assertEquals(1, fc.getSchema().getAttributeCount()); // make sure the feature schema is good as well FeatureIterator<SimpleFeature> it = fc.features(); SimpleFeature sf = it.next(); it.close(); assertEquals(1, sf.getAttributeCount()); assertNull(sf.getAttribute("FID")); assertNotNull(sf.getAttribute("ADDRESS")); } }