From: <svn...@os...> - 2012-05-29 08:54:06
|
Author: mcr Date: 2012-05-29 01:53:53 -0700 (Tue, 29 May 2012) New Revision: 38776 Added: trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTest.java trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTestSetup.java Modified: trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2Util.java Log: Empty geomtry support for DB2 Modified: trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java 2012-05-29 07:47:24 UTC (rev 38775) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2SQLDialectPrepared.java 2012-05-29 08:53:53 UTC (rev 38776) @@ -184,7 +184,7 @@ @Override public void setGeometryValue(Geometry g, int srid, Class binding, PreparedStatement ps, int column) throws SQLException { - if (g ==null) { + if (g ==null || g.isEmpty()) { //ps.setNull(column, Types.OTHER); ps.setBytes(column, null); return; Modified: trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2Util.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2Util.java 2012-05-29 07:47:24 UTC (rev 38775) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/main/java/org/geotools/data/db2/DB2Util.java 2012-05-29 08:53:53 UTC (rev 38776) @@ -143,7 +143,7 @@ static public void encodeGeometryValue(Geometry value, int srid, StringBuffer sql) throws IOException { - if (value ==null) { + if (value ==null || value.isEmpty()) { sql.append("null"); return; } Added: trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTest.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTest.java (rev 0) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTest.java 2012-05-29 08:53:53 UTC (rev 38776) @@ -0,0 +1,33 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.db2; + +import org.geotools.jdbc.JDBCEmptyGeometryTest; +import org.geotools.jdbc.JDBCEmptyGeometryTestSetup; + +/** + * + * + */ +public class DB2EmptyGeometryTest extends JDBCEmptyGeometryTest { + + @Override + protected JDBCEmptyGeometryTestSetup createTestSetup() { + return new DB2EmptyGeometryTestSetup(new DB2TestSetup()); + } + +} \ No newline at end of file Property changes on: trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native Added: trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTestSetup.java =================================================================== --- trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTestSetup.java (rev 0) +++ trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTestSetup.java 2012-05-29 08:53:53 UTC (rev 38776) @@ -0,0 +1,72 @@ +/* + * GeoTools - The Open Source Java GIS Toolkit + * http://geotools.org + * + * (C) 2002-2008, Open Source Geospatial Foundation (OSGeo) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ +package org.geotools.data.db2; + +import java.sql.Connection; + +import org.geotools.jdbc.JDBCEmptyGeometryTestSetup; +import org.geotools.jdbc.JDBCTestSetup; + +/** + * + * + */ +public class DB2EmptyGeometryTestSetup extends JDBCEmptyGeometryTestSetup { + + public DB2EmptyGeometryTestSetup(JDBCTestSetup delegate) { + super(delegate); + } + + @Override + protected void createEmptyGeometryTable() throws Exception { + Connection con = getDataSource().getConnection(); + con.prepareStatement("CREATE TABLE "+DB2TestUtil.SCHEMA_QUOTED+".\"empty\"(\"fid\" int PRIMARY KEY not null GENERATED ALWAYS AS IDENTITY, " + + "\"id\" integer, " + + "\"geom_point\" db2gse.ST_POINT, " + + "\"geom_linestring\" db2gse.ST_LINESTRING, " + + "\"geom_polygon\" db2gse.ST_POLYGON, " + + "\"geom_multipoint\" db2gse.ST_MULTIPOINT, " + + "\"geom_multilinestring\" db2gse.ST_MULTILINESTRING, " + + "\"geom_multipolygon\" db2gse.ST_MULTIPOLYGON, " + + "\"name\" varchar(250))" ).execute(); + + DB2Util.executeRegister(DB2TestUtil.SCHEMA, "empty", "geom_point", DB2TestUtil.SRSNAME,con); + DB2Util.executeRegister(DB2TestUtil.SCHEMA, "empty", "geom_linestring",DB2TestUtil.SRSNAME, con); + DB2Util.executeRegister(DB2TestUtil.SCHEMA, "empty", "geom_polygon", DB2TestUtil.SRSNAME,con); + DB2Util.executeRegister(DB2TestUtil.SCHEMA, "empty", "geom_multipoint", DB2TestUtil.SRSNAME,con); + DB2Util.executeRegister(DB2TestUtil.SCHEMA, "empty", "geom_linestring", DB2TestUtil.SRSNAME,con); + DB2Util.executeRegister(DB2TestUtil.SCHEMA, "empty", "geom_multipolygon", DB2TestUtil.SRSNAME,con); + + con.close(); + + } + + @Override + protected void dropEmptyGeometryTable() throws Exception { + Connection con = getDataSource().getConnection(); + DB2Util.executeUnRegister(DB2TestUtil.SCHEMA, "empty", "geom_point", con); + DB2Util.executeUnRegister(DB2TestUtil.SCHEMA, "empty", "geom_linestring", con); + DB2Util.executeUnRegister(DB2TestUtil.SCHEMA, "empty", "geom_polygon", con); + DB2Util.executeUnRegister(DB2TestUtil.SCHEMA, "empty", "geom_multipoint", con); + DB2Util.executeUnRegister(DB2TestUtil.SCHEMA, "empty", "geom_linestring", con); + DB2Util.executeUnRegister(DB2TestUtil.SCHEMA, "empty", "geom_multipolygon", con); + DB2TestUtil.dropTable(DB2TestUtil.SCHEMA, "empty", con); + con.close(); + + } + +} Property changes on: trunk/modules/plugin/jdbc/jdbc-db2/src/test/java/org/geotools/data/db2/DB2EmptyGeometryTestSetup.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Id URL Added: svn:eol-style + native |