public void testRemoveFeatures() throws IOException { FilterFactory ff = dataStore.getFilterFactory(); Filter filter = ff.equals(ff.property(aname("intProperty")), ff.literal(1)); SimpleFeatureCollection features = featureStore.getFeatures(); assertEquals(3, features.size()); featureStore.removeFeatures(filter); assertEquals(2, features.size()); featureStore.removeFeatures(Filter.INCLUDE); assertEquals(0, features.size()); }
public void testRemoveFeaturesWithInvalidFilter() throws IOException { SimpleFeatureType t = featureStore.getSchema(); FilterFactory ff = CommonFactoryFinder.getFilterFactory(null); PropertyIsEqualTo f = ff.equals(ff.property("invalidAttribute"), ff.literal(5)); try { featureStore.removeFeatures(f); fail("This should have failed with an exception reporting the invalid filter"); } catch (Exception e) { // fine } } }
public void testDeleteLockedFeatures() throws Exception { FeatureLock lock = FeatureLockFactory.generate(tname("ft1"), 60 * 60 * 1000); try (Transaction tx = new DefaultTransaction()) { store.setTransaction(tx); store.setFeatureLock(lock); tx.addAuthorization(lock.getAuthorization()); FilterFactory ff = dataStore.getFilterFactory(); Filter f1 = ff.id(Collections.singleton(ff.featureId(tname("ft1") + ".1"))); assertEquals(1, store.lockFeatures(f1)); try (Transaction tx1 = new DefaultTransaction()) { store.setTransaction(tx1); try { store.removeFeatures(f1); fail("Locked feature should not be deleted."); } catch (FeatureLockException e) { } } store.setTransaction(tx); store.removeFeatures(f1); tx.commit(); } }
public void removeLayer(String refSysName, String layerName) throws DaoException { try { String cqlQuery = String.format("ref_sys_name = '%s' and layer_name = '%s'", refSysName, layerName); Filter f = CQL.toFilter(cqlQuery); ((JDBCFeatureStore)getFeatureSource()).removeFeatures(f); } catch (CQLException e) { throw new DaoException(e); } catch (IOException e) { throw new DaoException(e); } }
public void removeLayer(String refSysName, String layerName) throws DaoException { try { String cqlQuery = String.format("ref_sys_name = '%s' and layer_name = '%s'", refSysName, layerName); Filter f = CQL.toFilter(cqlQuery); ((JDBCFeatureStore)getFeatureSource()).removeFeatures(f); } catch (CQLException e) { throw new DaoException(e); } catch (IOException e) { throw new DaoException(e); } }