@Override protected SQLDialect createSQLDialect(JDBCDataStore dataStore) { return new OracleDialect(dataStore); }
public Geometry decodeGeometryValue( GeometryDescriptor descriptor, ResultSet rs, int column, GeometryFactory factory, Connection cx, Hints hints) throws IOException, SQLException { // read the geometry Geometry geom = readGeometry(rs, column, factory, cx); return convertGeometry(geom, descriptor, factory); };
@Override public void encodeGeometryEnvelope(String tableName, String geometryColumn, StringBuffer sql) { sql.append("SDO_AGGR_MBR("); encodeColumnName(null, geometryColumn, sql); sql.append(")"); }
String columnName = att.getName().getLocalPart(); if (canAccessUserViews(cx)) { sql = "SELECT DIMINFO FROM MDSYS.USER_SDO_GEOM_METADATA WHERE TABLE_NAME = ? AND COLUMN_NAME = ?"; Envelope env = decodeDiminfoEnvelope(rs, 1); Envelope env = decodeDiminfoEnvelope(rs, 1); "Failed to use METADATA DIMINFO, falling back on SDO_TUNE.EXTENT_OF", e); return getOptimizedBoundsSDO_TUNE(schema, featureType, cx); } finally { if (savePoint != null) { return getOptimizedBoundsSDO_TUNE(schema, featureType, cx);
/** * Reads the SRID from the SDO_USER* views * * @param tableName * @param columnName * @param cx * @return * @throws SQLException */ private Integer lookupSRIDFromUserViews(String tableName, String columnName, Connection cx) throws SQLException { // we run this only if we can access the user views if (!canAccessUserViews(cx)) { return null; } List<String> parameters = new ArrayList<String>(); String userSdoSql = "SELECT SRID FROM MDSYS.USER_SDO_GEOM_METADATA WHERE TABLE_NAME = ? AND COLUMN_NAME = ?"; parameters.add(tableName.toUpperCase()); parameters.add(columnName.toUpperCase()); return readIntegerFromStatement(cx, userSdoSql, parameters); }
/** Looks up the geometry type on the "USER_*" metadata views */ private Class lookupGeometryClassOnUserIndex( Connection cx, String tableName, String columnName, String schema) throws SQLException { // we only try this if we are able to access the // user_sdo views if (!canAccessUserViews(cx)) { return null; } List<String> parameters = new ArrayList<String>(); // setup the sql to use for the USER_SDO table String userSdoSqlStatement = "SELECT META.SDO_LAYER_GTYPE\n" + "FROM ALL_INDEXES INFO\n" + "INNER JOIN MDSYS.USER_SDO_INDEX_METADATA META\n" + "ON INFO.INDEX_NAME = META.SDO_INDEX_NAME\n" + "WHERE INFO.TABLE_NAME = ?\n" + "AND REPLACE(meta.sdo_column_name, '\"') = ?\n"; parameters.add(tableName); parameters.add(columnName); if (schema != null && !"".equals(schema)) { userSdoSqlStatement += " AND INFO.TABLE_OWNER = ?"; parameters.add(schema); } return readGeometryClassFromStatement(cx, userSdoSqlStatement, parameters); }
if (i < cs.getDimension()) { CoordinateSystemAxis axis = cs.getAxis(i); axisNames[i] = getCompatibleAxisName(axis, i); min[i] = Double.isInfinite(axis.getMinimumValue()) int idxDim = isGeodeticSrid(srid, cx) ? 2 : dims;
@Override public void encodeTableAlias(String raw, StringBuffer sql) { sql.append(" "); encodeTableName(raw, sql); }
@Override public void postCreateAttribute( AttributeDescriptor att, String tableName, String schemaName, Connection cx) throws SQLException { super.postCreateAttribute(att, tableName, schemaName, cx); if (att instanceof GeometryDescriptor) { Integer srid = (Integer) att.getUserData().get(JDBCDataStore.JDBC_NATIVE_SRID); boolean geodetic = isGeodeticSrid(srid, cx); att.getUserData().put(GEODETIC, geodetic); } }
@Override public Object getNextSequenceValue(String schemaName, String sequenceName, Connection cx) throws SQLException { Statement st = cx.createStatement(); try { ResultSet rs = st.executeQuery( "SELECT " + encodeNextSequenceValue(schemaName, sequenceName) + " FROM DUAL"); try { if (!rs.next()) { throw new SQLException("Could not find next sequence value"); } return rs.getInt(1); } finally { dataStore.closeSafe(rs); } } finally { dataStore.closeSafe(st); } }
/** * Reads the SRID from the SDO_USER* views * * @param tableName * @param columnName * @param cx * @return * @throws SQLException */ private Integer lookupDimensionFromUserViews(String tableName, String columnName, Connection cx) throws SQLException { // we run this only if we can access the user views if (!canAccessUserViews(cx)) { return null; } List<String> parameters = new ArrayList<String>(); String userSdoSql = "SELECT COUNT(*) FROM MDSYS.USER_SDO_GEOM_METADATA USGM, table(USGM.DIMINFO)" + " WHERE TABLE_NAME = ? AND COLUMN_NAME = ?"; parameters.add(tableName.toUpperCase()); parameters.add(columnName.toUpperCase()); return readIntegerFromStatement(cx, userSdoSql, parameters); }
static final class GeomClasses extends HashMap<Class, String> { private static final long serialVersionUID = -3359664692996608331L; public GeomClasses() { super(); put(Point.class, "POINT"); put(LineString.class, "LINE"); put(LinearRing.class, "LINE"); put(Polygon.class, "POLYGON"); put(GeometryCollection.class, "COLLECTION"); put(MultiPoint.class, "MULTIPOINT"); put(MultiLineString.class, "MULTILINE"); put(MultiPolygon.class, "MULTIPOLYGON"); } }