Permalink
Browse files

Merge pull request #38 from martin-sucha/ingres

Update Ingres data source with the latest jdbc datastore api
  • Loading branch information...
2 parents d5e54ba + aa961d9 commit 95c094612801619ea1b081460a0b65f6bb5e6210 Justin Deoliveira committed Oct 10, 2012
@@ -25,7 +25,7 @@
public static final Param LOOSEBBOX = new Param("Loose bbox", Boolean.class, "Perform only primary filter on bbox", false, Boolean.TRUE);
/** parameter for database port */
- public static final Param PORT = new Param("port", Integer.class, "Port", true, 5432);
+ public static final Param PORT = new Param("port", String.class, "Port", true, "II7");
/** parameter for database schema */
public static final Param SCHEMA = new Param("schema", String.class, "Schema", false, null);
@@ -69,4 +69,27 @@ public String getDescription() {
return "Ingres Database";
}
+ @Override
+ protected String getJDBCUrl(Map params) throws IOException {
+ String host = (String) HOST.lookUp(params);
+ String port = (String) PORT.lookUp(params);
+ String database = (String) DATABASE.lookUp(params);
+
+ StringBuilder url = new StringBuilder("jdbc:");
+ url.append(getDatabaseID());
+ url.append("://");
+ url.append(host);
+ if (port != null) {
+ url.append(":").append(port);
+ }
+ if (database != null) {
+ url.append("/").append(database);
+ }
+ url.append(";autocommit_mode=multi");
+
+ return url.toString();
+ }
+
+
+
}
@@ -1,35 +1,22 @@
package org.geotools.data.ingres;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.sql.Clob;
import java.sql.Connection;
-import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import java.sql.Blob;
-import java.sql.Time;
-import java.sql.Timestamp;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
-//import net.sf.jsqlparser.schema.Column;
-
import org.geotools.data.DataSourceException;
-import org.geotools.data.jdbc.FilterToSQL;
-import org.geotools.jdbc.BasicSQLDialect;
+import org.geotools.factory.Hints;
import org.geotools.jdbc.JDBCDataStore;
import org.geotools.jdbc.PreparedFilterToSQL;
import org.geotools.jdbc.PreparedStatementSQLDialect;
import org.geotools.referencing.CRS;
-import org.geotools.util.Converters;
-//import org.hsqldb.Types;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.AttributeDescriptor;
import org.opengis.feature.type.GeometryDescriptor;
@@ -137,13 +124,13 @@ public void encodeGeometryEnvelope(String tableName, String geometryColumn, Stri
}
@Override
- public void encodeGeometryColumn(GeometryDescriptor gatt, int srid,
- StringBuffer sql) {
+ public void encodeGeometryColumn(GeometryDescriptor gatt, String prefix,
+ int srid, Hints hints, StringBuffer sql) {
sql.append(" AsBinary( ");
- encodeColumnName(gatt.getLocalName(), sql);
+ encodeColumnName(prefix, gatt.getLocalName(), sql);
sql.append(" ) ");
}
-
+
@Override
public void prepareGeometryValue(Geometry g, int srid, Class binding,
StringBuffer sql) {
@@ -226,7 +213,7 @@ public Integer getGeometrySRID(String schemaName, String tableName, String colum
@Override
public void encodePrimaryKey(String column, StringBuffer sql) {
- encodeColumnName(column, sql);
+ encodeColumnName(null, column, sql);
sql.append(" INT PRIMARY KEY");
}
@@ -36,7 +36,7 @@
boolean looseBBOXEnabled;
public IngresFilterToSQL(IngresDialect dialect) {
-
+ super(dialect);
}
public boolean isLooseBBOXEnabled() {
@@ -167,9 +167,8 @@ void visitComparisonSpatialOperator(BinarySpatialOperator filter,
out.write("(");
property.accept(this, extraData);
- out.write(", GeomFromWKB(");
+ out.write(", ");
geometry.accept(this, extraData);
- out.write(")");
out.write(closingParenthesis);
out.write(" = 1");
}

0 comments on commit 95c0946

Please sign in to comment.