void update ( Object feature ) throws LayerException { SimpleFeatureSource source = getFeatureSource ( ) ; if ( source instanceof SimpleFeatureStore ) { SimpleFeatureStore store = ( SimpleFeatureStore ) source ; String featureId = getFeatureModel ( ) . getId ( feature ) ; Filter filter = filterService . createFidFilter ( new String [ ] { featureId } ) ; transactionSynchronization . synchTransaction ( store ) ; List < Name > names = new ArrayList < Name > ( ) ; Map < String , Attribute > attrMap = getFeatureModel ( ) . getAttributes ( feature ) ; List < Object > values = new ArrayList < Object > ( ) ; for ( Map . Entry < String , Attribute > entry : attrMap . entrySet ( ) ) { String name = entry . getKey ( ) ; names . add ( store . getSchema ( ) . getDescriptor ( name ) . getName ( ) ) ; values . add ( entry . getValue ( ) . 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 ) ; } } else { log . error ( "Don't know how to create or update " + getFeatureSourceName ( ) + ", class " + source . getClass ( ) . getName ( ) + " does not implement SimpleFeatureStore" ) ; throw new LayerException ( ExceptionCode . CREATE_OR_UPDATE_NOT_IMPLEMENTED , getFeatureSourceName ( ) , source . getClass ( ) . getName ( ) ) ; } }
Update an existing feature . Made package private for testing purposes .