Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

GEOT-2333: removeSchema #308

Merged
merged 1 commit into from

2 participants

Daniele Romagnoli Andrea Aime
Daniele Romagnoli
Collaborator

Implementing removeSchema in JDBC datastore

Andrea Aime
Owner

Looks good to me

Daniele Romagnoli dromagnoli merged commit 81a60cc into from
Daniele Romagnoli dromagnoli deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 11, 2013
  1. Daniele Romagnoli

    GEOT-2333: removeSchema

    dromagnoli authored
This page is out of date. Refresh to see the latest.
Showing with 415 additions and 29 deletions.
  1. +9 −0 modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/AppSchemaDataAccess.java
  2. +9 −0 modules/extension/app-schema/sample-data-access/src/main/java/org/geotools/data/SampleDataAccess.java
  3. +10 −0 modules/extension/transform/src/main/java/org/geotools/data/transform/SingleFeatureSourceDataStore.java
  4. +12 −1 modules/library/api/src/main/java/org/geotools/data/DataAccess.java
  5. +11 −0 modules/library/api/src/main/java/org/geotools/data/DataStore.java
  6. +11 −0 modules/library/data/src/main/java/org/geotools/data/directory/DirectoryDataStore.java
  7. +26 −1 modules/library/data/src/main/java/org/geotools/data/store/ContentDataStore.java
  8. +61 −0 modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java
  9. +25 −0 modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java
  10. +21 −8 modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCDataStoreTest.java
  11. +15 −0 modules/library/main/src/main/java/org/geotools/data/AbstractDataStore.java
  12. +9 −0 modules/library/main/src/test/java/org/geotools/data/DataAccessFinderTest.java
  13. +10 −0 modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEDataStore.java
  14. +9 −0 modules/plugin/feature-pregeneralized/src/main/java/org/geotools/data/gen/PreGeneralizedDataStore.java
  15. +16 −0 modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/oracle/DataStoreWrapper.java
  16. +0 −1  ...es/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/oracle/OracleDatastoreWrapper.java
  17. +50 −1 modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java
  18. +15 −3 modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2DialectBasic.java
  19. +15 −3 modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2DialectPrepared.java
  20. +17 −2 modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/OracleDialect.java
  21. +21 −0 modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java
  22. +15 −9 modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java
  23. +9 −0 modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java
  24. +10 −0 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
  25. +9 −0 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/WFS_1_1_0_DataStore.java
9 modules/extension/app-schema/app-schema/src/main/java/org/geotools/data/complex/AppSchemaDataAccess.java
View
@@ -654,6 +654,15 @@ public void updateSchema(Name typeName, FeatureType featureType) throws IOExcept
}
/**
+ * Not a supported operation.
+ *
+ * @see org.geotools.data.DataAccess#removeSchema(org.opengis.feature.type.Name)
+ */
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
* Return a feature source that can be used to obtain features of a particular name. This name
* would be the mappingName in the TypeMapping if it exists, otherwise it's the target element
* name.
9 modules/extension/app-schema/sample-data-access/src/main/java/org/geotools/data/SampleDataAccess.java
View
@@ -129,4 +129,13 @@ public void updateSchema(Name typeName, FeatureType featureType) throws IOExcept
throw new UnsupportedOperationException();
}
+
+ /**
+ * Unsupported operation.
+ *
+ * @see org.geotools.data.DataAccess#removeSchema(org.opengis.feature.type.Name)
+ */
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException("Schema removal not supported");
+ }
}
10 modules/extension/transform/src/main/java/org/geotools/data/transform/SingleFeatureSourceDataStore.java
View
@@ -101,6 +101,16 @@ public void updateSchema(String typeName, SimpleFeatureType featureType) throws
}
@Override
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public String[] getTypeNames() throws IOException {
return new String[] { source.getSchema().getName().getLocalPart() };
}
13 modules/library/api/src/main/java/org/geotools/data/DataAccess.java
View
@@ -131,7 +131,18 @@
*/
void updateSchema(Name typeName, T featureType)
throws IOException;
-
+
+ /**
+ * Used to permanently remove a schema from the underlying storage
+ * <p>
+ * This functionality is similar to an "drop table" statement in SQL. Implementation
+ * is optional; it may not be supported by all servers or files.
+ * @param typeName
+ * @throws IOException if the operation failed
+ * @throws UnsupportedOperation if functionality is not available
+ */
+ void removeSchema(Name typeName) throws IOException;
+
/**
* Names of the available Resources.
* <p>
11 modules/library/api/src/main/java/org/geotools/data/DataStore.java
View
@@ -57,6 +57,17 @@ void updateSchema(String typeName, SimpleFeatureType featureType)
throws IOException;
/**
+ * Used to permanently remove a schema from the underlying storage
+ * <p>
+ * This functionality is similar to an "drop table" statement in SQL. Implementation
+ * is optional; it may not be supported by all servers or files.
+ * @param typeName
+ * @throws IOException if the operation failed
+ * @throws UnsupportedOperation if functionality is not available
+ */
+ void removeSchema(String typeName) throws IOException;
+
+ /**
* Gets the names of feature types available in this {@code DataStore}.
* Please note that this is not guaranteed to return a list of unique
* names since the same unqualified name may be present in separate
11 modules/library/data/src/main/java/org/geotools/data/directory/DirectoryDataStore.java
View
@@ -193,4 +193,15 @@ public DataStore getDataStore(String typeName) throws IOException {
return store;
}
+ @Override
+ public void removeSchema(Name name) throws IOException {
+ removeSchema(name.getLocalPart());
+
+ }
+
+ @Override
+ public void removeSchema(String name) throws IOException {
+ getDataStore(name).removeSchema(name);
+ }
+
}
27 modules/library/data/src/main/java/org/geotools/data/store/ContentDataStore.java
View
@@ -598,7 +598,18 @@ final protected ContentEntry ensureEntry(Name name)
return entry;
}
-
+
+ /**
+ * Helper method to remove an entry from the cached entry map.
+ *
+ * @param name The name of the entry.
+ */
+ final protected void removeEntry(Name name) {
+ if (entries.containsKey(name)) {
+ entries.remove(name);
+ }
+ }
+
/**
* Creates a set of qualified names corresponding to the types that the
* datastore provides.
@@ -688,4 +699,18 @@ public SimpleFeatureType getSchema(Name name) throws IOException {
public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException {
updateSchema(typeName.getLocalPart(), featureType);
}
+
+ /**
+ * @see DataAccess#removeSchema(Name)
+ */
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException("Schema removal not supported");
+ }
+
+ /**
+ * @see DataStore#removeSchema(String)
+ */
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException("Schema removal not supported");
+ }
}
61 modules/library/jdbc/src/main/java/org/geotools/jdbc/JDBCDataStore.java
View
@@ -81,6 +81,7 @@
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
import org.opengis.feature.type.GeometryDescriptor;
+import org.opengis.feature.type.Name;
import org.opengis.filter.Filter;
import org.opengis.filter.Id;
import org.opengis.filter.PropertyIsLessThanOrEqualTo;
@@ -687,6 +688,53 @@ public void createSchema(final SimpleFeatureType featureType)
}
}
+ public void removeSchema(String typeName) throws IOException {
+ removeSchema(name(typeName));
+ }
+
+ public void removeSchema(Name typeName) throws IOException {
+ if (entry(typeName) == null) {
+ String msg = "Schema '" + typeName + "' does not exist";
+ throw new IllegalArgumentException(msg);
+ }
+
+ //check for virtual table
+ if (virtualTables.containsKey(typeName.getLocalPart())) {
+ removeVirtualTable(typeName.getLocalPart());
+ return;
+ }
+
+ SimpleFeatureType featureType = getSchema(typeName);
+
+ //execute the drop table statement
+ Connection cx = createConnection();
+ try {
+ //give the dialect a chance to cleanup pre
+ dialect.preDropTable(databaseSchema, featureType, cx);
+
+ String sql = dropTableSQL(featureType, cx);
+ LOGGER.log(Level.FINE, "Drop schema: {0}", sql);
+
+ Statement st = cx.createStatement();
+
+ try {
+ st.execute(sql);
+ } finally {
+ closeSafe(st);
+ }
+
+ dialect.postDropTable(databaseSchema, featureType, cx);
+ removeEntry(typeName);
+ }
+ catch(Exception e) {
+ String msg = "Error occurred dropping table";
+ throw (IOException) new IOException(msg).initCause(e);
+ }
+ finally {
+ closeSafe(cx);
+ }
+ }
+
/**
*
*/
@@ -1981,6 +2029,19 @@ protected String findPrimaryKeyColumnName(SimpleFeatureType featureType) {
}
/**
+ * Generates a 'DROP TABLE' sql statement.
+ */
+ protected String dropTableSQL(SimpleFeatureType featureType, Connection cx)
+ throws Exception {
+ StringBuffer sql = new StringBuffer();
+ sql.append("DROP TABLE ");
+
+ encodeTableName(featureType.getTypeName(), sql, null);
+
+ return sql.toString();
+ }
+
+ /**
* Ensures that that the specified transaction has access to features specified by a filter.
* <p>
* If any features matching the filter are locked, and the transaction does not have authorization
25 modules/library/jdbc/src/main/java/org/geotools/jdbc/SQLDialect.java
View
@@ -979,6 +979,31 @@ public void postCreateFeatureType(SimpleFeatureType featureType, DatabaseMetaDat
}
/**
+ * Callback which executes before a table is about to be dropped.
+ * <p>
+ * This base implementation does nothing, subclasses should override as need be.
+ * </p>
+ * @param schemaName The database schema containing the table.
+ * @param featureType The featureType/table being dropped.
+ * @param cx The database connection.
+ */
+ public void preDropTable(String schemaName, SimpleFeatureType featureType, Connection cx) throws SQLException {
+ }
+
+ /**
+ * Callback which executes after a table has been dropped.
+ *
+ * <p>
+ * This base implementation does nothing, subclasses should override as need be.
+ * </p>
+ * @param schemaName The database schema containing the table.
+ * @param featureType The featureType/table being dropped.
+ * @param cx The database connection.
+ */
+ public void postDropTable(String schemaName, SimpleFeatureType featureType, Connection cx) throws SQLException {
+ }
+
+ /**
* Controls whether keys are looked up post or pre insert.
* <p>
* When a row is inserted into a table, and a key is automatically generated
29 modules/library/jdbc/src/test/java/org/geotools/jdbc/JDBCDataStoreTest.java
View
@@ -128,24 +128,24 @@ public void testCreateSchemaWithConstraints() throws Exception {
builder.setCRS(CRS.decode("EPSG:4326"));
builder.add(aname("geometry"), Geometry.class);
builder.nillable(false).add(aname("intProperty"), Integer.class);
-
+
builder.length(5).add(aname("stringProperty"), String.class);
-
+
SimpleFeatureType featureType = builder.buildFeatureType();
dataStore.createSchema(featureType);
-
+
SimpleFeatureType ft2 = dataStore.getSchema(tname("ft2"));
//assertEquals(ft2, featureType);
-
+
//grab a writer
FeatureWriter w = dataStore.getFeatureWriter( tname("ft2"),Transaction.AUTO_COMMIT);
w.hasNext();
-
+
SimpleFeature f = (SimpleFeature) w.next();
f.setAttribute( 1, new Integer(0));
f.setAttribute( 2, "hello");
w.write();
-
+
w.hasNext();
f = (SimpleFeature) w.next();
f.setAttribute( 1, null );
@@ -155,7 +155,7 @@ public void testCreateSchemaWithConstraints() throws Exception {
}
catch( Exception e ) {
}
-
+
f.setAttribute( 1, new Integer(1) );
f.setAttribute( 2, "hello!");
try {
@@ -164,10 +164,23 @@ public void testCreateSchemaWithConstraints() throws Exception {
}
catch( Exception e ) {
}
-
+
w.close();
}
+ public void testRemoveSchema() throws Exception {
+ SimpleFeatureType ft = dataStore.getSchema(tname("ft1"));
+ assertNotNull(ft);
+
+ dataStore.removeSchema(tname("ft1"));
+ try {
+ dataStore.getSchema(tname("ft1"));
+ fail("getSchema() should fail if table was deleted");
+ }
+ catch(Exception e) {
+ }
+ }
+
public void testCreateSchemaUTMCRS() throws Exception {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName(tname("ft2"));
15 modules/library/main/src/main/java/org/geotools/data/AbstractDataStore.java
View
@@ -634,4 +634,19 @@ public SimpleFeatureType getSchema(Name name) throws IOException {
public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException {
updateSchema(typeName.getLocalPart(), featureType);
}
+
+ /**
+ * @see DataAccess#removeSchema(Name)
+ */
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException("Schema removal not supported");
+ }
+
+ /**
+ * @see DataStore#removeSchema(String)
+ */
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException("Schema removal not supported");
+ }
+
}
9 modules/library/main/src/test/java/org/geotools/data/DataAccessFinderTest.java
View
@@ -347,6 +347,9 @@ public FeatureType getSchema(Name name) throws IOException {
public void updateSchema(Name typeName, FeatureType featureType) throws IOException {
}
+
+ public void removeSchema(Name typeName) throws IOException {
+ }
};
/**
@@ -394,6 +397,9 @@ public SimpleFeatureType getSchema(String typeName) throws IOException {
public void updateSchema(String typeName, SimpleFeatureType featureType) throws IOException {
}
+ public void removeSchema(String typeName) throws IOException {
+ }
+
public void createSchema(SimpleFeatureType featureType) throws IOException {
}
@@ -419,5 +425,8 @@ public SimpleFeatureType getSchema(Name name) throws IOException {
public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException {
}
+
+ public void removeSchema(Name typeName) throws IOException {
+ }
};
}
10 modules/plugin/arcsde/datastore/src/main/java/org/geotools/arcsde/data/ArcSDEDataStore.java
View
@@ -798,4 +798,14 @@ private void verifyUnsupportedSqlConstruct(List<Object> errors, Object construct
errors.add(construct);
}
}
+
+ @Override
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
9 modules/plugin/feature-pregeneralized/src/main/java/org/geotools/data/gen/PreGeneralizedDataStore.java
View
@@ -206,4 +206,13 @@ public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IO
}
+ @Override
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
16 modules/plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/oracle/DataStoreWrapper.java
View
@@ -279,6 +279,22 @@ public void updateSchema(String typeName, SimpleFeatureType featureType) throws
}
@Override
+ public void removeSchema(Name typeName) throws IOException {
+ FeatureTypeMapper mapper = getMapper(typeName);
+ if (mapper == null) {
+ throw new IOException ("No wrapper found for " + typeName);
+ } else {
+ String mappedName = mapper.getMappedName();
+ datastore.removeSchema(mappedName);
+ }
+ }
+
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ removeSchema(new NameImpl(typeName));
+ }
+
+ @Override
public String[] getTypeNames() throws IOException {
return typeNames != null ? (String[]) typeNames.toArray(new String[typeNames.size()]) : null;
}
1  ...plugin/imagemosaic/src/main/java/org/geotools/gce/imagemosaic/catalog/oracle/OracleDatastoreWrapper.java
View
@@ -16,7 +16,6 @@
*/
package org.geotools.gce.imagemosaic.catalog.oracle;
-import java.io.File;
import java.io.IOException;
import org.geotools.data.DataStore;
51 modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2Dialect.java
View
@@ -275,7 +275,56 @@ public void postCreateFeatureType(SimpleFeatureType featureType, DatabaseMetaDat
dataStore.closeSafe(rs);
}
}
-
+
+ @Override
+ public void preDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ String tableName = featureType.getTypeName();
+ Statement st = cx.createStatement();
+
+ try {
+ //drop the spatial index
+ StringBuffer sql = new StringBuffer();
+ sql.append("CALL DropSpatialIndex(");
+ if (schemaName == null) {
+ sql.append("NULL");
+ }
+ else {
+ sql.append("'").append(schemaName).append("'");
+ }
+
+ sql.append(",'").append(tableName).append("')");
+ LOGGER.fine(sql.toString());
+
+ try {
+ st.execute(sql.toString());
+ }
+ catch(SQLException e) {
+ //table may not have had a spatial index
+ //TODO: do a better check
+ LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);
+ }
+
+ //remove the geometry metadata
+ sql = new StringBuffer();
+ sql.append("CALL DropGeometryColumns(");
+ if (schemaName == null) {
+ sql.append("NULL");
+ }
+ else {
+ sql.append("'").append(schemaName).append("'");
+ }
+
+ sql.append(",'").append(tableName).append("')");
+ LOGGER.fine(sql.toString());
+
+ st.execute(sql.toString());
+ }
+ finally {
+ dataStore.closeSafe(st);
+ }
+ }
+
boolean isConcreteGeometry( Class binding ) {
return Point.class.isAssignableFrom(binding)
|| LineString.class.isAssignableFrom(binding)
18 modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2DialectBasic.java
View
@@ -99,19 +99,31 @@ public void encodePostColumnCreateTable(AttributeDescriptor att,
public void encodePostCreateTable(String tableName, StringBuffer sql) {
delegate.encodePostCreateTable(tableName, sql);
}
-
+
@Override
public void postCreateTable(String schemaName,
SimpleFeatureType featureType, Connection cx) throws SQLException {
delegate.postCreateTable(schemaName, featureType, cx);
}
-
+
@Override
public void postCreateFeatureType(SimpleFeatureType featureType, DatabaseMetaData metadata,
String schemaName, Connection cx) throws SQLException {
delegate.postCreateFeatureType(featureType, metadata, schemaName, cx);
}
-
+
+ @Override
+ public void preDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ delegate.preDropTable(schemaName, featureType, cx);
+ }
+
+ @Override
+ public void postDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ delegate.postDropTable(schemaName, featureType, cx);
+ }
+
@Override
public Integer getGeometrySRID(String schemaName, String tableName, String columnName,
Connection cx) throws SQLException {
18 modules/plugin/jdbc/jdbc-h2/src/main/java/org/geotools/data/h2/H2DialectPrepared.java
View
@@ -108,13 +108,25 @@ public void postCreateTable(String schemaName,
SimpleFeatureType featureType, Connection cx) throws SQLException {
delegate.postCreateTable(schemaName, featureType, cx);
}
-
+
@Override
public void postCreateFeatureType(SimpleFeatureType featureType, DatabaseMetaData metadata,
String schemaName, Connection cx) throws SQLException {
delegate.postCreateFeatureType(featureType, metadata, schemaName, cx);
}
-
+
+ @Override
+ public void preDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ delegate.preDropTable(schemaName, featureType, cx);
+ }
+
+ @Override
+ public void postDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ delegate.postDropTable(schemaName, featureType, cx);
+ }
+
@Override
public Integer getGeometrySRID(String schemaName, String tableName, String columnName,
Connection cx) throws SQLException {
@@ -131,7 +143,7 @@ public String getSequenceForColumn(String schemaName, String tableName,
String columnName, Connection cx) throws SQLException {
return delegate.getSequenceForColumn(schemaName, tableName, columnName, cx);
}
-
+
@Override
public Object getNextSequenceValue(String schemaName, String sequenceName,
Connection cx) throws SQLException {
19 modules/plugin/jdbc/jdbc-oracle/src/main/java/org/geotools/data/oracle/OracleDialect.java
View
@@ -43,7 +43,6 @@
import org.geotools.factory.Hints;
import org.geotools.geometry.jts.JTS;
import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.geotools.geometry.jts.ReferencedEnvelope3D;
import org.geotools.jdbc.JDBCDataStore;
import org.geotools.jdbc.PreparedFilterToSQL;
import org.geotools.jdbc.PreparedStatementSQLDialect;
@@ -56,7 +55,6 @@
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.CoordinateSystemAxis;
-import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
@@ -959,6 +957,23 @@ public Object getNextSequenceValue(String schemaName, String sequenceName,
}
+ @Override
+ public void postDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ Statement st = cx.createStatement();
+ String tableName = featureType.getTypeName();
+
+ try {
+ // remove all the geometry metadata (no need for schema as we can only play against
+ // the current user's table)
+ String sql = "DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = '" + tableName + "'";
+ LOGGER.fine( sql );
+ st.execute( sql );
+ } finally {
+ dataStore.closeSafe(st);
+ }
+ }
+
/**
* Checks if the specified srid is geodetic or not
* @throws SQLException
21 modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISDialect.java
View
@@ -794,6 +794,27 @@ public void postCreateTable(String schemaName,
}
@Override
+ public void postDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ Statement st = cx.createStatement();
+ String tableName = featureType.getTypeName();
+
+ try {
+ //remove all the geometry_column entries
+ String sql =
+ "DELETE FROM GEOMETRY_COLUMNS"
+ + " WHERE f_table_catalog=''" //
+ + " AND f_table_schema = '" + schemaName + "'"
+ + " AND f_table_name = '" + tableName + "'";
+ LOGGER.fine( sql );
+ st.execute( sql );
+ }
+ finally {
+ dataStore.closeSafe(st);
+ }
+ }
+
+ @Override
public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql)
throws IOException {
if (value == null || value.isEmpty()) {
24 modules/plugin/jdbc/jdbc-postgis/src/main/java/org/geotools/data/postgis/PostGISPSDialect.java
View
@@ -135,41 +135,48 @@ public Object getLastAutoGeneratedValue(String schemaName, String tableName, Str
Connection cx) throws SQLException {
return delegate.getLastAutoGeneratedValue(schemaName, tableName, columnName, cx);
}
-
+
public Object getNextSequenceValue(String schemaName, String sequenceName,
Connection cx) throws SQLException {
return delegate.getNextSequenceValue(schemaName, sequenceName, cx);
}
-
public String getSequenceForColumn(String schemaName, String tableName,
String columnName, Connection cx) throws SQLException {
return delegate.getSequenceForColumn(schemaName, tableName, columnName,
cx);
}
-
public boolean isLooseBBOXEnabled() {
return delegate.isLooseBBOXEnabled();
}
-
public void postCreateTable(String schemaName,
SimpleFeatureType featureType, Connection cx) throws SQLException {
delegate.postCreateTable(schemaName, featureType, cx);
}
+ @Override
+ public void preDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ delegate.preDropTable(schemaName, featureType, cx);
+ }
+
+ @Override
+ public void postDropTable(String schemaName, SimpleFeatureType featureType, Connection cx)
+ throws SQLException {
+ delegate.postDropTable(schemaName, featureType, cx);
+ }
public void registerClassToSqlMappings(Map<Class<?>, Integer> mappings) {
delegate.registerClassToSqlMappings(mappings);
}
-
public void registerSqlTypeNameToClassMappings(
Map<String, Class<?>> mappings) {
delegate.registerSqlTypeNameToClassMappings(mappings);
}
-
+
@Override
public void registerSqlTypeToSqlTypeNameOverrides(
Map<Integer, String> overrides) {
@@ -186,7 +193,6 @@ public void setLooseBBOXEnabled(boolean looseBBOXEnabled) {
delegate.setLooseBBOXEnabled(looseBBOXEnabled);
}
-
@Override
public void prepareGeometryValue(Geometry g, int srid, Class binding,
StringBuffer sql) {
@@ -219,12 +225,12 @@ public PreparedFilterToSQL createPreparedFilterToSQL() {
fts.setLooseBBOXEnabled(delegate.isLooseBBOXEnabled());
return fts;
}
-
+
@Override
public boolean isLimitOffsetSupported() {
return delegate.isLimitOffsetSupported();
}
-
+
@Override
public void applyLimitOffset(StringBuffer sql, int limit, int offset) {
delegate.applyLimitOffset(sql, limit, offset);
9 modules/unsupported/mongodb/src/main/java/org/geotools/data/mongodb/MongoDataStore.java
View
@@ -347,4 +347,13 @@ public MongoLayer getMongoLayer (String typeName)
return layer;
}
+ @Override
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
10 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_0_0/WFS_1_0_0_DataStore.java
View
@@ -1162,4 +1162,14 @@ public void setUseDefaultSRS(Boolean useDefaultSRS) {
throw new UnsupportedOperationException(
"Not used, this class needs to be adapted to the new architecture in the wfs.v_1_1_0 package");
}
+
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
9 modules/unsupported/wfs/src/main/java/org/geotools/data/wfs/v1_1_0/WFS_1_1_0_DataStore.java
View
@@ -1024,4 +1024,13 @@ public void setGetFeatureOutputFormat(String outputFormat) {
}
}
+ @Override
+ public void removeSchema(String typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void removeSchema(Name typeName) throws IOException {
+ throw new UnsupportedOperationException();
+ }
}
Something went wrong with that request. Please try again.