# File app/controllers/metarep_controller.rb, line 336
  def tree_location_build
    TreeLocation.destroy_all
    @database = Database.find_by_database_nm(Database.find_first.currentDatabaseName)
    @schema_types = SchemaType.find(:all, :order => "display_seq")     
    @tree_loc = TreeLocation.new({:path => '/metarep/showDatabase/' + 
      @database.id.to_s, :tree_id => 0})
    @tree_loc.save
    @count = 0
    
    for schema_type in @schema_types
      @count += 1
      @tree_loc = TreeLocation.new({:path => '/metarep/showSchemaType/' + 
            schema_type.id.to_s, :tree_id => @count})
      @tree_loc.save
    
      @schemas = Schema.find(:all, :conditions => { :schema_type_id => schema_type.id, :database_id => @database.id}, :order => "schema_nm") 
        for schema in @schemas
          @count += 1
          @tree_loc = TreeLocation.new({:path => '/metarep/showSchema/' + 
            schema.id.to_s, :tree_id => @count})
          @tree_loc.save
          for table in schema.tables
            @count += 1
                  @tree_loc = TreeLocation.new({:path => '/metarep/showTable/' + 
              table.id.to_s, :tree_id => @count})
            @tree_loc.save
              for column in table.columns
                @count += 1
                      @tree_loc = TreeLocation.new({:path => '/metarep/showColumn/'+ 
                  column.id.to_s, :tree_id => @count})
                      @tree_loc.save
              end    
          end
        end
    end
    
    unless ReportFolder.find_by_report_folder_nm('Reports').nil?
      f = ReportFolder.find_by_report_folder_nm('Reports')      
      # The root node of Northwestern's reports server is called "Reports".  Please this with yours.
      @tree_loc = TreeLocation.new({:path => '/metarep/showReportFolder/'+ 
      f.id.to_s, :tree_id => @count+1})
      @tree_loc.save
      # After adding the root node, build the rest of the Report tree
      report_tree_location_build (@count, f) #Build the report part of the tree
    end
  end