use of org.geotoolkit.storage.FeatureMapUpdate in project geotoolkit by Geomatys.
the class WFSFeatureSet method replaceIf.
@Override
public void replaceIf(Predicate<? super Feature> filter, UnaryOperator<Feature> updater) throws DataStoreException {
if (!(filter instanceof Filter)) {
throw new DataStoreException("Predicate filter must be an instance of org.opengis.filter.Filter");
}
if (!(updater instanceof FeatureMapUpdate)) {
throw new DataStoreException("Predicate filter must be an instance of org.opengis.filter.Filter");
}
final FeatureType featureType = getType();
final FeatureMapUpdate map = (FeatureMapUpdate) updater;
final TransactionRequest request = store.createTransaction();
final Update update = store.createUpdateElement();
update.setInputFormat("text/xml; subtype=\"gml/3.1.1\"");
update.setFilter((Filter) filter);
update.setTypeName(featureType.getName());
for (Map.Entry<String, ? extends Object> entry : map.getValues().entrySet()) {
update.updates().put(featureType.getProperty(entry.getKey()), entry.getValue());
}
request.elements().add(update);
try {
final InputStream response = request.getResponseStream();
response.close();
// TODO send event
} catch (IOException ex) {
throw new DataStoreException(ex);
}
}
Aggregations