WFSFeatureStore extends ContentFeatureStore { @Override public void modifyFeatures(Name[] properties, Object[] values, Filter filter) throws IOException { if (filter == null) { throw new IllegalArgumentException("filter is null"); } filter = resolvePropertyNames(filter); { QName typeName = getDataStore().getRemoteTypeName(getName()); WFSClient wfsClient = getDataStore().getWfsClient(); Filter[] splitFilters = wfsClient.splitFilters(typeName, filter); Filter unsupported = splitFilters[1]; if (!Filter.INCLUDE.equals(unsupported)) { super.modifyFeatures(properties, values, filter); return; } } final ContentState contentState = getState(); ReferencedEnvelope affectedBounds = new ReferencedEnvelope(getInfo().getCRS()); if (contentState.hasListener()) { ReferencedEnvelope before = getBounds(new Query(getSchema().getTypeName(), filter)); if (before != null && !before.isEmpty()) { affectedBounds = before; } } final Transaction transaction = getTransaction(); FeatureReader<SimpleFeatureType, SimpleFeature> oldFeatures = getReader(filter); try { if (!oldFeatures.hasNext()) { oldFeatures.close(); return; } } catch (IOException e) { oldFeatures.close(); throw e; } catch (RuntimeException e) { oldFeatures.close(); throw e; } if (Transaction.AUTO_COMMIT.equals(transaction)) { WFSLocalTransactionState localState = getState().getLocalTransactionState(); WFSRemoteTransactionState committingState = new WFSRemoteTransactionState( getDataStore()); committingState.watch(localState.getState()); WFSDiff diff = localState.getDiff(); ReferencedEnvelope bounds; bounds = diff.batchModify(properties, values, filter, oldFeatures, contentState); affectedBounds.expandToInclude(bounds); committingState.commit(); } else { WFSLocalTransactionState localState; localState = (WFSLocalTransactionState) transaction.getState(getEntry()); WFSDiff diff = localState.getDiff(); ReferencedEnvelope bounds; bounds = diff.batchModify(properties, values, filter, oldFeatures, contentState); affectedBounds.expandToInclude(bounds); } if (contentState.hasListener()) { FeatureEvent event = new FeatureEvent(this, Type.CHANGED, affectedBounds, filter); contentState.fireFeatureEvent(event); } } WFSFeatureStore(WFSFeatureSource source); @Override boolean canReproject(); @Override boolean canLock(); @Override WFSDataStore getDataStore(); @Override ContentEntry getEntry(); @Override ResourceInfo getInfo(); @Override Name getName(); @Override QueryCapabilities getQueryCapabilities(); @Override WFSContentState getState(); @Override Transaction getTransaction(); @Override void setTransaction(Transaction transaction); @Override void modifyFeatures(Name[] properties, Object[] values, Filter filter);  }
@Test public void testUpdateFeaturesAutoCommit() throws Exception { FilterFactory2 filterfac = CommonFactoryFinder.getFilterFactory2(); ContentFeatureSource source = (ContentFeatureSource) dataStore.getFeatureSource(simpleTypeName1); WFSFeatureStore store = (WFSFeatureStore) source; Filter filter = filterfac.id(filterfac.featureId("poi.2")); store.modifyFeatures("NAME", "blah", filter); ContentFeatureCollection coll = store.getFeatures( new Query(simpleTypeName1.getLocalPart(), filter) ); assertEquals(1, coll.size()); SimpleFeature feature = coll.features().next(); assertEquals("blah", feature.getAttribute("NAME")); }