use of org.geotools.data.Query in project incubator-rya by apache.
the class GeoWaveFeatureReaderTest method testFidFilterQuery.
@Test
public void testFidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException {
final String fidsString = fids.stream().collect(Collectors.joining("','", "'", "'"));
final Filter filter = ECQL.toFilter("IN (" + fidsString + ")");
final Query query = new Query("GeoWaveFeatureReaderTest", filter, new String[] { "geometry", "pid" });
final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
int count = 0;
while (reader.hasNext()) {
final SimpleFeature feature = reader.next();
assertTrue(fids.contains(feature.getID()));
count++;
}
assertTrue(count == fids.size());
}
use of org.geotools.data.Query in project incubator-rya by apache.
the class GeoWaveFeatureReaderTest method testPidFilterQuery.
@Test
public void testPidFilterQuery() throws IllegalArgumentException, NoSuchElementException, IOException, CQLException {
// Filter it so that it only queries for everything but the first pid.
// There's only 2 pids total so it should just return the second one.
final String pidsString = pids.subList(1, pids.size()).stream().collect(Collectors.joining("','", "'", "'"));
final Filter filter = ECQL.toFilter("pid IN (" + pidsString + ")");
final Query query = new Query("GeoWaveFeatureReaderTest", filter, new String[] { "geometry", "pid" });
final FeatureReader<SimpleFeatureType, SimpleFeature> reader = dataStore.getFeatureReader(query, Transaction.AUTO_COMMIT);
int count = 0;
while (reader.hasNext()) {
final SimpleFeature feature = reader.next();
assertTrue(fids.contains(feature.getID()));
count++;
}
assertTrue(count == pids.size() - 1);
}
use of org.geotools.data.Query in project polymap4-core by Polymap4.
the class PipelineFeatureSource method getReaderInternal.
@Override
@SuppressWarnings("hiding")
protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) throws IOException {
log.debug("query= " + query);
// assert query.getFilter() != null : "No filter in query.";
if (query.getFilter() == null) {
log.warn("Filter is NULL -> changing to EXCLUDE to prevent unwanted loading of all features! Use INCLUDE to get all.");
query = new Query(query);
query.setFilter(Filter.EXCLUDE);
}
return new PipelineAsyncFeatureReader(this, query, sessionContext);
}
use of org.geotools.data.Query in project polymap4-core by Polymap4.
the class RFeatureStore method removeFeatures.
@Override
public void removeFeatures(Filter filter) throws IOException {
try {
startModification();
RFeatureCollection features = getFeatures(new Query(null, filter));
for (RFeature feature : features) {
txState.updater().remove(feature.state);
}
completeModification(true);
} catch (IOException e) {
completeModification(false);
throw e;
} catch (Throwable e) {
log.warn("", e);
completeModification(false);
throw new RuntimeException(e);
}
}
use of org.geotools.data.Query in project polymap4-core by Polymap4.
the class PipelineReadTest method testCount.
@Test
public void testCount() throws IOException {
PipelineFeatureSource fs = pipeDs.getFeatureSource();
Query query = Query.ALL;
assertEquals(expected.COUNT, fs.getCount(query));
query = new Query(null, Filter.INCLUDE);
assertEquals(expected.COUNT, fs.getCount(query));
query = new Query(null, Filter.EXCLUDE);
assertEquals(0, /*origFs.getCount( query )*/
fs.getCount(query));
}
Aggregations