View Javadoc

1   package liquibase.ext.spatial.sqlgenerator;
2   
3   import liquibase.database.Database;
4   import liquibase.database.core.OracleDatabase;
5   import liquibase.statement.core.UpdateStatement;
6   
7   /**
8    * The <code>SpatialUpdateGeneratorOracle</code> generates the SQL for <code>UPDATE</code>ing
9    * geometries in Oracle.
10   */
11  public class SpatialUpdateGeneratorOracle extends AbstractSpatialUpdateGenerator {
12     /**
13      * Verifies that the <code>UpdateStatement</code> has WKT or EWKT.
14      */
15     @Override
16     public boolean supports(final UpdateStatement statement, final Database database) {
17        return database instanceof OracleDatabase;
18     }
19  
20     /**
21      * Returns the name of the function that converts Well-Known Text to a database-specific
22      * geometry.
23      * 
24      * @return the name of the function that converts WKT to a geometry.
25      */
26     @Override
27     public String getGeomFromWktFunction() {
28        return "SDO_GEOMETRY";
29     }
30  
31     /**
32      * Handles the Well-Known Text and SRID for Oracle.
33      */
34     @Override
35     public String convertToFunction(final String wkt, final String srid, final Database database) {
36        final String oracleWkt = OracleSpatialUtils.getOracleWkt(wkt);
37        final String oracleSrid = OracleSpatialUtils.getOracleSrid(srid, database);
38        return super.convertToFunction(oracleWkt, oracleSrid, database);
39     }
40  }