本文整理汇总了Java中org.geotools.data.DefaultTransaction.commit方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTransaction.commit方法的具体用法?Java DefaultTransaction.commit怎么用?Java DefaultTransaction.commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.DefaultTransaction
的用法示例。
在下文中一共展示了DefaultTransaction.commit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRelockLock
import org.geotools.data.DefaultTransaction; //导入方法依赖的package包/类
@Test
public void testRelockLock()
throws InterruptedException,
IOException {
final LockingManagement memoryLockManager = new MemoryLockManager(
"default");
final DefaultTransaction t1 = new DefaultTransaction();
memoryLockManager.lock(
t1,
"f8");
memoryLockManager.lock(
t1,
"f8");
t1.commit();
t1.close();
}
示例2: writeEsriShapefile
import org.geotools.data.DefaultTransaction; //导入方法依赖的package包/类
static void writeEsriShapefile(Class<?> geomType, List<SimpleFeature> features, File file) throws IOException {
String geomName = geomType.getSimpleName();
String basename = file.getName();
if (basename.endsWith(FILE_EXTENSION_SHAPEFILE)) {
basename = basename.substring(0, basename.length() - 4);
}
File file1 = new File(file.getParentFile(), basename + "_" + geomName + FILE_EXTENSION_SHAPEFILE);
SimpleFeature simpleFeature = features.get(0);
SimpleFeatureType simpleFeatureType = changeGeometryType(simpleFeature.getType(), geomType);
ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory();
Map<String, Serializable> map = Collections.singletonMap("url", file1.toURI().toURL());
ShapefileDataStore dataStore = (ShapefileDataStore) factory.createNewDataStore(map);
dataStore.createSchema(simpleFeatureType);
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureSource featureSource = dataStore.getFeatureSource(typeName);
DefaultTransaction transaction = new DefaultTransaction("X");
if (featureSource instanceof SimpleFeatureStore) {
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
SimpleFeatureCollection collection = new ListFeatureCollection(simpleFeatureType, features);
featureStore.setTransaction(transaction);
// I'm not sure why the next line is necessary (mp/20170627)
// Without it is not working, the wrong feature type is used for writing
// But it is not mentioned in the tutorials
dataStore.getEntry(featureSource.getName()).getState(transaction).setFeatureType(simpleFeatureType);
try {
featureStore.addFeatures(collection);
transaction.commit();
} catch (Exception problem) {
transaction.rollback();
throw new IOException(problem);
} finally {
transaction.close();
}
} else {
throw new IOException(typeName + " does not support read/write access");
}
}
示例3: testLockReleaseOfBulkAuthLock
import org.geotools.data.DefaultTransaction; //导入方法依赖的package包/类
@Test
public void testLockReleaseOfBulkAuthLock()
throws InterruptedException,
IOException {
final LockingManagement memoryLockManager = new MemoryLockManager(
"default");
final Transaction t1 = Transaction.AUTO_COMMIT;
final DefaultTransaction t2 = new DefaultTransaction();
t2.addAuthorization("auth1");
FeatureLock lock = new FeatureLock(
"auth1",
1 /* minute */);
memoryLockManager.lockFeatureID(
"sometime",
"f4",
t1,
lock);
memoryLockManager.lock(
t2,
"f4");
t2.commit();
// commit should not take away the lock
assertTrue(memoryLockManager.exists("auth1"));
memoryLockManager.release(
"auth1",
t1);
assertFalse(memoryLockManager.exists("auth1"));
t1.close();
}