Hi - we had that method in the datastore API but it was removed as nobody ever implemented it as you pointed out.
We had proposal as part of the "Join" idea, with an Expression used to define the default values so that you could calculate them from other attributes (or use a literal expression). Could you take Expression[] values instead? Trying to remember: - we may of just defined a new list of AttributeTypes (so that you could add / remove AttributeTypes anywhere in your FeatureType). - you will also need to specify the "typeName", so that the method works for more then just shapefile... I am the module maintainer for API so we can add this one in pretty quickly again if you have a will. Jody Vitali Diatchkov wrote: > Hello! > > I would like to see a method > > public void ShapefileDataStore.modifyFeatureType(AttributeType[] > removedTypes, AttributeType[] addedTypes, Object[] defaultAddedValues) > throws IOException; > > for modifying current ShapefileDataStore schema. > > There is a unimplemented stuff updateSchema(FeatureType) that can just > delegate real work to the underlying method by analyzing passed FeatureType > with current schema. > > The developer may call ShapefileDataStore.updateSchema(FeatureType) or > modifyFeatureType(...) directly from ShapefileDataStore. The last method > gives more freedom to manipulate by attribute types without creating > FeatureType (etc.). > > The ShapefileDataStore has to perform schema modifications internally > because of read/write lock object is inside of it. The approach is usual: > read from current datastore, modify features on the fly to conform changes, > write into temporary. Then lock current datastore to rewrite files from > temporary one, unlock. > > I have implemented the method, also tests. Any comments or suggestions > (for/against this proposal). > If there are no points against I can commit to geotools 2.2.x branch and to > trunk. > > Regards, Vitali. > > P.S. the difficulty to perform this operation outside of ShapefileDataStore > - there is no possibility to get lock. Because of the requirement is schema > modification of the current shapefile, not a creation of new shapefile. > Without lock it is dangerous in multi-threading environment like UDIG and > led to exceptions like "java.io.IOException: Shp has extra record"... > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Geotools-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-devel > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
