/** * A safe cast to SimpleFeatureLocking; that will introduce a wrapper if it has to. * * <p>Please keep the use of this class to a minimum; if you are expecting a * FeatureLocking<SimpleFeatureType,SimpleFeature> please make use of SimpleFeatureLocking if * you possibly can. * * @since 2.7 */ public static SimpleFeatureLocking simple(FeatureLocking locking) { if (locking instanceof SimpleFeatureLocking) { return (SimpleFeatureLocking) locking; } if (locking.getSchema() instanceof SimpleFeatureType) { return new SimpleFeatureLockingBridge(locking); } throw new IllegalArgumentException( "The provided feature store contains complex features, cannot be bridged to a simple one"); } //
/** * A safe cast to SimpleFeatureLocking; that will introduce a wrapper if it has to. * <p> * Please keep the use of this class to a minimum; if you are expecting a * FeatureLocking<SimpleFeatureType,SimpleFeature> please make use of SimpleFeatureLocking if * you possibly can. * * @since 2.7 */ public static SimpleFeatureLocking simple(FeatureLocking locking) { if (locking instanceof SimpleFeatureLocking) { return (SimpleFeatureLocking) locking; } if (locking.getSchema() instanceof SimpleFeatureType) { return new SimpleFeatureLockingBridge(locking); } throw new IllegalArgumentException( "The provided feature store contains complex features, cannot be bridged to a simple one"); } //
public void removeFeatures(Filter filter) throws IOException { // this we can optimize, it's a matter of mass updating the last // revisions (and before that, we have to compute the modified envelope) Filter versionedFilter = (Filter) store.buildVersionedFilter(schema.getTypeName(), filter, new RevisionInfo()); Envelope bounds = locking .getBounds(new DefaultQuery(schema.getTypeName(), versionedFilter)); Transaction t = getTransaction(); boolean autoCommit = false; if (Transaction.AUTO_COMMIT.equals(t)) { t = new DefaultTransaction(); autoCommit = true; } VersionedJdbcTransactionState state = store.wrapped.getVersionedJdbcTransactionState(t); locking.modifyFeatures(locking.getSchema().getAttributeType("expired"), new Long(state .getRevision()), versionedFilter); if (autoCommit) { t.commit(); t.close(); } store.listenerManager.fireFeaturesRemoved(schema.getTypeName(), t, bounds, false); }