Esempio n. 1
0
 protected void setDbms(String dbmsList) {
   if (StringUtils.trimToNull(dbmsList) != null) {
     String[] strings = dbmsList.toLowerCase().split(",");
     dbmsSet = new HashSet<String>();
     for (String string : strings) {
       dbmsSet.add(string.trim().toLowerCase());
     }
   }
 }
Esempio n. 2
0
  /**
   * Generate the ChangeMetaData for this class. Default implementation reads from the @{@link
   * DatabaseChange } annotation and calls out to {@link #createChangeParameterMetadata(String)} for
   * each property.
   *
   * @throws UnexpectedLiquibaseException if no @DatabaseChange annotation on this Change class
   */
  @Override
  public ChangeMetaData createChangeMetaData() {
    try {
      DatabaseChange databaseChange = this.getClass().getAnnotation(DatabaseChange.class);

      if (databaseChange == null) {
        throw new UnexpectedLiquibaseException(
            "No @DatabaseChange annotation for " + getClass().getName());
      }

      Set<ChangeParameterMetaData> params = new HashSet<ChangeParameterMetaData>();
      for (PropertyDescriptor property :
          Introspector.getBeanInfo(this.getClass()).getPropertyDescriptors()) {
        if (isInvalidProperty(property)) {
          continue;
        }
        Method readMethod = property.getReadMethod();
        Method writeMethod = property.getWriteMethod();
        if (readMethod == null) {
          try {
            readMethod =
                this.getClass().getMethod("is" + StringUtils.upperCaseFirst(property.getName()));
          } catch (Exception ignore) {
            // it was worth a try
          }
        }
        if (readMethod != null && writeMethod != null) {
          DatabaseChangeProperty annotation =
              readMethod.getAnnotation(DatabaseChangeProperty.class);
          if (annotation == null || annotation.isChangeProperty()) {
            params.add(createChangeParameterMetadata(property.getDisplayName()));
          }
        }
      }

      Map<String, String> notes = new HashMap<String, String>();
      for (DatabaseChangeNote note : databaseChange.databaseNotes()) {
        notes.put(note.database(), note.notes());
      }

      return new ChangeMetaData(
          databaseChange.name(),
          databaseChange.description(),
          databaseChange.priority(),
          databaseChange.appliesTo(),
          notes,
          params);
    } catch (Throwable e) {
      throw new UnexpectedLiquibaseException(e);
    }
  }
Esempio n. 3
0
 public void addValidCheckSum(String text) {
   validCheckSums.add(CheckSum.parse(text));
 }