1 package liquibase.ext.spatial.sqlgenerator;
2
3 import liquibase.database.Database;
4 import liquibase.exception.ValidationErrors;
5 import liquibase.ext.spatial.statement.CreateSpatialIndexStatement;
6 import liquibase.sqlgenerator.SqlGenerator;
7 import liquibase.sqlgenerator.SqlGeneratorChain;
8 import liquibase.sqlgenerator.core.AbstractSqlGenerator;
9 import liquibase.structure.core.Index;
10 import liquibase.structure.core.Table;
11
12
13
14
15
16 public abstract class AbstractCreateSpatialIndexGenerator extends
17 AbstractSqlGenerator<CreateSpatialIndexStatement> {
18
19
20
21
22
23 @Override
24 public ValidationErrors validate(final CreateSpatialIndexStatement statement,
25 final Database database, final SqlGeneratorChain sqlGeneratorChain) {
26 final ValidationErrors validationErrors = new ValidationErrors();
27 validationErrors.checkRequiredField("tableName", statement.getTableName());
28 validationErrors.checkRequiredField("columns", statement.getColumns());
29 return validationErrors;
30 }
31
32 protected Index getAffectedIndex(final CreateSpatialIndexStatement statement) {
33 return new Index().setName(statement.getIndexName()).setTable(
34 (Table) new Table().setName(statement.getTableName()).setSchema(
35 statement.getTableCatalogName(), statement.getTableSchemaName()));
36 }
37 }