示例#1
0
    public StoreObject merge() {
      boolean alreadySetDatabaseObject = false;

      // first pass
      for (StoreObject store : this.storeObjects) {
        copySchemaInfo(store);
      }

      // second pass
      for (StoreObject store : this.storeObjects) {
        if (store.getSchema().getVersion() == targetStore.getSchema().getVersion()
            && !alreadySetDatabaseObject) {
          BaseSchema targetSchema = targetStore.getSchema();
          targetSchema.clearObjects();
          targetSchema.addObjects(mergeDatabaseObjects(store.getSchema().getObjects()));

          alreadySetDatabaseObject = true;
        }

        mergePatches(store.getPatches());
        mergeExistQueries(store.getExistQueries());
        mergeDropStatements(store.getDropStatements());
      }

      return this.targetStore;
    }
示例#2
0
  protected String getDropSQL(DatabaseObjectType type, String name) {
    SQLObject foundDropQuery = null;
    String sqlStatement = "DROP " + type.toString() + " " + name;

    for (SQLObject dropQuery : catalogStore.getDropStatements()) {
      if (type == dropQuery.getType()) {
        foundDropQuery = dropQuery;
        break;
      }
    }

    if (foundDropQuery != null
        && foundDropQuery.getSql() != null
        && !foundDropQuery.getSql().isEmpty()) {
      String dropStatement = foundDropQuery.getSql();
      StringBuffer sqlBuffer = new StringBuffer(dropStatement.length() + name.length());
      int identifier = dropStatement.indexOf('?');

      sqlBuffer
          .append(dropStatement.substring(0, identifier))
          .append(name)
          .append(dropStatement.substring(identifier + 1));
      sqlStatement = sqlBuffer.toString();
    }

    return sqlStatement;
  }