|
From: Andrea A. <aa...@op...> - 2008-05-08 16:12:32
|
Hi, I'm looking at this geoserver jira issue: http://jira.codehaus.org/browse/GEOS-1373 To sum it up in gt2 terms, consider hitting a shapefile datastore wrapping states.shp with a fid filter using "foobar.1", and to your surprise, you'll get back a feature whose fid is "states.1". The thing is, primary keys and raw feature identifiers of any kind are prefixed by the feature type name. I don't know exactly when this happened, but it has something to do with the request that on a WFS using a feature id you should be able to figure out the feature without any specification of the type name (like "give me states.1" out of the blue, without telling you from which feature type is should be extracted). Now, when we go back from the published fid to the raw one, the code that does the prefixes just wipes out everything before the dot... leading to this issue. The problem is a little deeper than this thought. The FIDMapper method that unwraps a FID into the DBMS column values has the following contract: /** * Creates the value for the PK attributes given the feature. If the FID is * null, will throw an IOException if not possible. If null is returned, * no primary key value needs to be specified, which is what we want for * auto-increment fields. * * @param FID The feature ID is going to be parsed * * * @throws IOException */ public Object[] getPKAttributes(String FID) throws IOException; Basically this means that if you want to say "this is not a FID I can unpack" you end up with throwing an exception (this is what MultiColumnFIDMapper does for example). Yet, if you queried for a datastore with a FID that does not match any feature, would you expect an exception? I certainly would not. I'd prefer the encoder to forget about that FID and eventually get back nothing... The contract as above leaves one free option, that is, return an empty array if the FID cannot be decoded into an array of values... but does not look very nice. What about adding a method like "canDecode(String FID)" and then have the code in getPKAttribute throw an exception if the decode is not possible? Cheers Andrea |