Andrea Aime ha scritto:
Justin Deoliveira ha scritto:
Anyways, this is less critical, I think it would be better to
solve the above regression part before releasing GeoServer 1.7.6
instead given it's (rightfully imho) perceived as a regression
from the users pov (it makes NG datastore not a drop in replacement
for old ones).
Agreed. If you want to cook up a patch I will be happy to review asap
before 1.7.6.
So I tried to make a patch but there is a design problem in the
ContentDataStore that won't let me implement a fix.
Oh, here is the current patch I have (which triggers the infinite
recursion).
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Index: src/main/java/org/geotools/jdbc/JDBCFeatureSource.java
===================================================================
--- src/main/java/org/geotools/jdbc/JDBCFeatureSource.java (revisione 33600)
+++ src/main/java/org/geotools/jdbc/JDBCFeatureSource.java (copia locale)
@@ -138,6 +138,11 @@
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
AttributeTypeBuilder ab = new AttributeTypeBuilder();
+
+ // setup the read only marker if no pk or null pk
+ if(pkey == null || pkey instanceof NullPrimaryKey) {
+ tb.userData(JDBCDataStore.JDBC_READ_ONLY, Boolean.TRUE);
+ }
//set up the name
String tableName = entry.getName().getLocalPart();
@@ -258,10 +263,10 @@
binding = getDataStore().getMapping(nativeTypeName);
}
- //if still not found, resort to Object
+ // if still not found, ignore the column we don't know about
if (binding == null) {
- getDataStore().getLogger().warning("Could not find mapping for:" + name);
- binding = Object.class;
+ tb.userData(JDBCDataStore.JDBC_READ_ONLY, Boolean.TRUE);
+ continue;
}
//store the native database type in the attribute descriptor user data
Index: src/main/java/org/geotools/jdbc/JDBCDataStore.java
===================================================================
--- src/main/java/org/geotools/jdbc/JDBCDataStore.java (revisione 33600)
+++ src/main/java/org/geotools/jdbc/JDBCDataStore.java (copia locale)
@@ -127,6 +127,11 @@
public static final String JDBC_NATIVE_SRID = "nativeSRID";
/**
+ * Boolean marker stating whether the feature type is to be considered read only
+ */
+ public static final String JDBC_READ_ONLY = "org.geotools.jdbc.readOnly";
+
+ /**
* The key for attribute descriptor user data which specifies the original database column data
* type.
*/
@@ -615,8 +620,9 @@
protected ContentFeatureSource createFeatureSource(ContentEntry entry)
throws IOException {
//check primary key to figure out if we must return a read only (feature source)
- PrimaryKey pkey = getPrimaryKey(entry);
- if ( pkey == null || pkey instanceof NullPrimaryKey ) {
+ SimpleFeatureType schema = getSchema(entry.getTypeName());
+ Object readOnlyMarker = schema.getUserData().get(JDBC_READ_ONLY);
+ if ( Boolean.TRUE.equals(readOnlyMarker)) {
return new JDBCFeatureSource(entry,null);
}
return new JDBCFeatureStore(entry,null);
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel