Java Code Examples for liquibase.exception.ValidationErrors#addError()

The following examples show how to use liquibase.exception.ValidationErrors#addError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveDropColumnGenerator.java    From liquibase-impala with Apache License 2.0 6 votes vote down vote up
@Override
public ValidationErrors validate(DropColumnStatement dropColumnStatement, Database database, SqlGeneratorChain sqlGeneratorChain) {
    if (dropColumnStatement.isMultiple()) {
        ValidationErrors validationErrors = new ValidationErrors();
        DropColumnStatement firstColumn = dropColumnStatement.getColumns().get(0);

        for (DropColumnStatement drop : dropColumnStatement.getColumns()) {
            validationErrors.addAll(validateSingleColumn(drop));
            if (drop.getTableName() != null && !drop.getTableName().equals(firstColumn.getTableName())) {
                validationErrors.addError("All columns must be targeted at the same table");
            }
            if (drop.isMultiple()) {
                validationErrors.addError("Nested multiple drop column statements are not supported");
            }
        }
        return validationErrors;
    } else {
        return validateSingleColumn(dropColumnStatement);
    }
}
 
Example 2
Source File: AddGeometryColumnGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 6 votes vote down vote up
@Override
public ValidationErrors validate(final AddColumnStatement statement,
      final Database database, final SqlGeneratorChain sqlGeneratorChain) {
   final ValidationErrors errors = new ValidationErrors();
   final LiquibaseDataType dataType = DataTypeFactory.getInstance()
         .fromDescription(statement.getColumnType(), database);

   // Ensure that the SRID parameter is provided.
   if (dataType instanceof GeometryType) {
      final GeometryType geometryType = (GeometryType) dataType;
      if (geometryType.getSRID() == null) {
         errors.addError("The SRID parameter is required on the geometry type");
      }
   }
   final ValidationErrors chainErrors = sqlGeneratorChain.validate(
         statement, database);
   if (chainErrors != null) {
      errors.addAll(chainErrors);
   }
   return errors;
}
 
Example 3
Source File: CreateSpatialIndexChange.java    From liquibase-spatial with Apache License 2.0 6 votes vote down vote up
/**
 * @see liquibase.change.AbstractChange#validate(liquibase.database.Database)
 */
@Override
public ValidationErrors validate(final Database database) {
   final ValidationErrors validationErrors = new ValidationErrors();
   if (this.srid != null) {
      if (!this.srid.matches("[0-9]+")) {
         validationErrors.addError("The SRID must be numeric");
      }
   }

   if (!validationErrors.hasErrors()) {
      validationErrors.addAll(super.validate(database));
   }

   return validationErrors;
}
 
Example 4
Source File: CreateSpatialTableGeneratorGeoDB.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
@Override
public ValidationErrors validate(final CreateTableStatement statement, final Database database,
      final SqlGeneratorChain sqlGeneratorChain) {
   final ValidationErrors validationErrors = new ValidationErrors();
   for (final Entry<String, LiquibaseDataType> entry : statement.getColumnTypes().entrySet()) {
      if (entry.getValue() instanceof GeometryType) {
         final GeometryType geometryType = (GeometryType) entry.getValue();
         if (geometryType.getSRID() == null) {
            validationErrors.addError("The SRID parameter is required on the geometry type");
         }
      }
   }
   validationErrors.addAll(sqlGeneratorChain.validate(statement, database));
   return validationErrors;
}
 
Example 5
Source File: SpatialSupportedPrecondition.java    From liquibase-spatial with Apache License 2.0 5 votes vote down vote up
@Override
public ValidationErrors validate(final Database database) {
   final ValidationErrors errors = new ValidationErrors();
   if (!(database instanceof DerbyDatabase || database instanceof H2Database
         || database instanceof MySQLDatabase || database instanceof OracleDatabase || database instanceof PostgresDatabase)) {
      errors.addError(database.getDatabaseProductName() + " is not supported by this extension");
   }
   return errors;
}