}
public void update(Object feature) throws LayerException {
FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
if (source instanceof FeatureStore<?, ?>) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
String featureId = getFeatureModel().getId(feature);
Filter filter = filterService.createFidFilter(new String[] {featureId});
if (transactionManager != null) {
store.setTransaction(transactionManager.getTransaction());
}
List<Name> names = new ArrayList<Name>();
Map<String, Attribute> attrMap = getFeatureModel().getAttributes(feature);
List<Object> values = new ArrayList<Object>();
for (String name : attrMap.keySet()) {
names.add(store.getSchema().getDescriptor(name).getName());
values.add(attrMap.get(name).getValue());
}
try {
store.modifyFeatures(names.toArray(new Name[names.size()]), values.toArray(), filter);
store.modifyFeatures(store.getSchema().getGeometryDescriptor().getName(), getFeatureModel()
.getGeometry(feature), filter);
log.debug("Updated feature {} in {}", featureId, getFeatureSourceName());
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);