use of org.geotoolkit.storage.feature.FeatureStore in project geotoolkit by Geomatys.
the class DefaultFolderFeatureStore method deleteFeatureType.
/**
* Unsupported, throws a {@link DataStoreException}.
*/
@Override
public synchronized void deleteFeatureType(final String typeName) throws DataStoreException {
final FeatureStore store = stores.get(this, typeName);
if (store == null) {
throw new DataStoreException("There's no data with the following type name : " + typeName);
}
// We should get a file feature store.
final Path[] sourceFiles;
try {
if (store instanceof ResourceOnFileSystem) {
sourceFiles = ((ResourceOnFileSystem) store).getComponentFiles();
} else {
// Not a file store ? We try to find an url parameter and see if it's a file one.
final URI fileURI = Parameters.castOrWrap(store.getOpenParameters().get()).getValue(ShapefileProvider.PATH);
if (fileURI == null) {
throw new DataStoreException("Source data cannot be reached for type name : " + typeName);
}
sourceFiles = new Path[] { Paths.get(fileURI) };
}
for (Path path : sourceFiles) {
Files.deleteIfExists(path);
}
} catch (IOException e) {
throw new DataStoreException("Source data cannot be deleted for type name : " + typeName, e);
}
stores.remove(this, store.getNames().iterator().next());
}
use of org.geotoolkit.storage.feature.FeatureStore in project geotoolkit by Geomatys.
the class ShapefileQuadTreeReadWriteTest method doubleWrite.
private void doubleWrite(final FeatureType type, final FeatureCollection one, final File tmp, final ShapefileProvider maker, final boolean memorymapped) throws IOException, MalformedURLException, DataStoreException, URISyntaxException {
FeatureStore s;
s = createDataStore(maker, tmp.toURI().toURL(), memorymapped);
s.createFeatureType(type);
Session session = s.createSession(true);
session.addFeatures(type.getName().toString(), one);
session.addFeatures(type.getName().toString(), one);
session.commit();
s = createDataStore(maker, tmp.toURI().toURL(), true);
assertEquals(one.size() * 2, s.getCount(new Query(s.getNames().iterator().next())));
}
use of org.geotoolkit.storage.feature.FeatureStore in project geotoolkit by Geomatys.
the class IndexedShapefileDataStoreFactoryTest method testCreateDataStoreURL.
/*
* Test method for
* 'org.geotoolkit.data.shapefile.indexed.IndexedShapefileDataStoreFactory.createDataStore(URL)'
*/
@Test
public void testCreateDataStoreURL() throws DataStoreException, IOException, URISyntaxException {
copyShapefiles(IndexedShapefileDataStoreTest.STATE_POP);
FeatureStore ds = factory.createDataStore(TestData.url(AbstractTestCaseSupport.class, IndexedShapefileDataStoreTest.STATE_POP).toURI());
testDataStore(IndexType.QIX, true, (IndexedShapefileFeatureStore) ds);
}
Aggregations