public void setTransaction(Transaction transaction) { storeDelegate.setTransaction(transaction); }
public void setTransaction(Transaction transaction) { delegate().setTransaction(transaction); } }
((FeatureStore) featureSource).setTransaction(tx);
public void setTransaction(Transaction transaction) { fstore.setTransaction(transaction); }
public void setTransaction(Transaction transaction) { wrappedStore.setTransaction(transaction); }
public void setTransaction(Transaction transaction) { delegate().setTransaction(transaction); }
/** * Factors out the boilerplate to create a transaction, run it, commit it if successful, revert * otherwise, and finally close it * * @param store * @param featureStoreConsumer * @throws IOException */ protected void runTransactionOnStore( FeatureStore store, IOConsumer<FeatureStore> featureStoreConsumer) throws IOException { try (Transaction t = new DefaultTransaction()) { store.setTransaction(t); try { featureStoreConsumer.accept(store); t.commit(); } catch (Exception e) { t.rollback(); throw new IOException("Failed to run modification on storage:" + e.getMessage(), e); } } }
static void write(List<SimpleFeature> features, File file) throws IOException { String basename = file.getName(); if (basename.endsWith(FILE_EXTENSION_SHAPEFILE)) { basename = basename.substring(0, basename.length() - 4); } File shapefile = new File(file.getParentFile(), basename + FILE_EXTENSION_SHAPEFILE); ShapefileDataStoreFactory factory = new ShapefileDataStoreFactory(); Map map = Collections.singletonMap("url", shapefile.toURI().toURL()); DataStore dataStore = factory.createNewDataStore(map); SimpleFeature simpleFeature = features.get(0); SimpleFeatureType simpleFeatureType = simpleFeature.getType(); final String typeName = simpleFeatureType.getName().getLocalPart(); dataStore.createSchema(simpleFeatureType); FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) dataStore.getFeatureSource(typeName); DefaultTransaction transaction = new DefaultTransaction("X"); featureStore.setTransaction(transaction); final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = DataUtilities.collection(features); featureStore.addFeatures(featureCollection); try { transaction.commit(); } catch (Exception e) { transaction.rollback(); throw new IOException("Cannot write shapefile. Error:\n" + e.getMessage(), e); } finally { dataStore.dispose(); transaction.close(); } } }
FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) newDataStore .getFeatureSource(typeName); featureStore.setTransaction(transaction); try { featureStore.addFeatures(collection);
typeName); DefaultTransaction transaction = new DefaultTransaction("X"); featureStore.setTransaction(transaction); final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollection = DataUtilities.collection( features);
((FeatureStore) featureSource).setTransaction(tx);
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { FeatureStore<SimpleFeatureType, SimpleFeature> store; if (layer.getFeatureSource() instanceof FeatureStore) { store = (FeatureStore<SimpleFeatureType, SimpleFeature>) layer.getFeatureSource(); DefaultTransaction transaction = new DefaultTransaction("trans_maj"); store.setTransaction(transaction); FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); Filter filter = ff.id(Collections.singleton(features.get(rowIndex).getIdentifier())); FeatureType schema = store.getSchema(); AttributeDescriptor NAME = (AttributeDescriptor) schema.getDescriptor(getColumnName(columnIndex)); try { store.modifyFeatures(NAME, aValue, filter); transaction.commit(); } catch (IOException ex) { ex.printStackTrace(); try { transaction.rollback(); } catch (IOException e) { e.printStackTrace(); } } setQuery(query); } }
featureStore.setTransaction(transaction);
store.setTransaction(transaction); FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); Filter filter = ff.id(Collections.singleton(ff.featureId(ID)));
store.setTransaction(transaction);
FeatureStore store2 = (FeatureStore) data.getFeatureSource(roadFeatures[0].getFeatureType() .getTypeName()); store1.setTransaction(new DefaultTransaction()); class Listener implements FeatureListener { String name;
fs.setTransaction(transaction); fs.removeFeatures(Filter.INCLUDE);
.getFeatureSource(typeName); store.setTransaction(transaction);
FeatureStore road2 = (FeatureStore) data.getFeatureSource("ROAD"); road1.setTransaction(t1); road2.setTransaction(t2);
store.setTransaction(t); store.removeFeatures(rd1Filter);