コード例 #1
0
 private void configureCustomChange() throws CustomChangeException {
   try {
     for (String param : params) {
       ObjectUtil.setProperty(customChange, param, paramValues.get(param));
     }
     customChange.setFileOpener(getResourceAccessor());
     customChange.setUp();
   } catch (Exception e) {
     throw new CustomChangeException(e);
   }
 }
コード例 #2
0
  /**
   * Finishes configuring the CustomChange based on the values passed to {@link #setParam(String,
   * String)} then calls {@link CustomSqlChange#generateStatements(liquibase.database.Database)} or
   * {@link CustomTaskChange#execute(liquibase.database.Database)} depending on the CustomChange
   * implementation.
   *
   * <p>If the CustomChange returns a null SqlStatement array, this method returns an empty array.
   * If a CustomTaskChange is being used, this method will return an empty array.
   */
  @Override
  public SqlStatement[] generateStatements(Database database) {
    SqlStatement[] statements = null;
    try {
      configureCustomChange();
      if (customChange instanceof CustomSqlChange) {
        statements = ((CustomSqlChange) customChange).generateStatements(database);
      } else if (customChange instanceof CustomTaskChange) {
        ((CustomTaskChange) customChange).execute(database);
      } else {
        throw new UnexpectedLiquibaseException(
            customChange.getClass().getName()
                + " does not implement "
                + CustomSqlChange.class.getName()
                + " or "
                + CustomTaskChange.class.getName());
      }
    } catch (CustomChangeException e) {
      throw new UnexpectedLiquibaseException(e);
    }

    if (statements == null) {
      statements = new SqlStatement[0];
    }
    return statements;
  }
コード例 #3
0
 /**
  * Call the {@link CustomChange#validate(liquibase.database.Database)} method and return the
  * result.
  */
 @Override
 public ValidationErrors validate(Database database) {
   try {
     return customChange.validate(database);
   } catch (Throwable e) {
     return new ValidationErrors()
         .addError("Exception thrown calling " + getClassName() + ".validate():" + e.getMessage());
   }
 }
コード例 #4
0
  /**
   * Finishes configuring the CustomChange based on the values passed to {@link #setParam(String,
   * String)} then calls {@link
   * CustomSqlRollback#generateRollbackStatements(liquibase.database.Database)} or {@link
   * CustomTaskRollback#rollback(liquibase.database.Database)} depending on the CustomChange
   * implementation.
   *
   * <p>If the CustomChange returns a null SqlStatement array, this method returns an empty array.
   * If a CustomTaskChange is being used, this method will return an empty array. Any {@link
   * RollbackImpossibleException} exceptions thrown by the CustomChange will thrown by this method.
   */
  @Override
  public SqlStatement[] generateRollbackStatements(Database database)
      throws RollbackImpossibleException {
    SqlStatement[] statements = null;
    try {
      configureCustomChange();
      if (customChange instanceof CustomSqlRollback) {
        statements = ((CustomSqlRollback) customChange).generateRollbackStatements(database);
      } else if (customChange instanceof CustomTaskRollback) {
        ((CustomTaskRollback) customChange).rollback(database);
      } else {
        throw new RollbackImpossibleException(
            "Unknown rollback type: " + customChange.getClass().getName());
      }
    } catch (CustomChangeException e) {
      throw new UnexpectedLiquibaseException(e);
    }

    if (statements == null) {
      statements = new SqlStatement[0];
    }
    return statements;
  }
コード例 #5
0
 /**
  * Return the customChange's {@link CustomChange#getConfirmationMessage} message as the Change's
  * message.
  */
 @Override
 public String getConfirmationMessage() {
   return customChange.getConfirmationMessage();
 }