Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Script to double check that permalinks for MediaObjects and MasterFiles ended up with the correct values and in the correct places after migration.

Code Block
languageruby
Here's the script I ran to produce the report below: 
load '/srv/avalon/avalon_r6/f3_mopermalinks.rb' # includes F3P = { f3_pid: permalink } 
load '/srv/avalon/avalon_r6/f3_mfpermalinks.rb' # includes F3MFP = { f3_pid: permalink } 

puts 'Inspecting F4 permalinks for MediaObjects' 
puts '1) If permalink in Fedora 3, the Fedora 4 object should have the same permalink' 
puts '2) If permalink in Fedora 4, the permalink noid should be persisted in Fedora 4 in identifiers:local ' 
puts '3) If permalink in Fedora 4, the permalink noid should be persisted in Solr in identifer_ssim ' 

count = 0 

MediaObject.find_each({},{batch_size: 5}) do |obj| 
  count += 1 
  migration_status = MigrationStatus.where(f4_pid: obj.id).first 
  unless migration_status.nil? 
    f3_permalink = F3P[migration_status.f3_pid] 
    unless f3_permalink.nil? 
      unless f3_permalink.split('://').last == obj.permalink.split('://').last 
        puts "#{obj.id} F3/F4 permalink mismatch: #{f3_permalink} / #{obj.permalink}" 
      end 
    end 
  end 
  if obj.permalink.present? 
    unless obj.identifier.include? obj.permalink.split('/').last 
      puts "#{obj.id} F4 permalink not found in identifiers" 
    end 
    unless obj.to_solr['permalink_tesim'].include? obj.permalink 
      puts "#{obj.id} F4 permalink not found in solr" 
    end 
  end 
  print '.' if (count%10==0) 
  puts count if (count%1000==0) 
  STDOUT.flush if (count%10==0) 
end 

count = 0 

puts '' 
puts 'Inspecting F4 permalinks for MasterFiles' 

MasterFile.find_each({},{batch_size: 5}) do |obj| 
  count += 1 
  migration_status = MigrationStatus.where(f4_pid: obj.id).first 
  unless migration_status.nil? 
    f3_permalink = F3MFP[migration_status.f3_pid] 
    unless f3_permalink.nil? 
      unless f3_permalink.split('://').last == obj.permalink.split('://').last 
        puts "#{obj.id} F3/F4 permalink mismatch: #{f3_permalink} / #{obj.permalink}" 
      end 
    end 
  end 
  if obj.permalink.present? 
    unless obj.identifier.include? obj.permalink.split('/').last 
      puts "#{obj.id} F4 permalink not found in identifiers" 
    end 
    unless obj.to_solr['permalink_tesim'].include? obj.permalink 
      puts "#{obj.id} F4 permalink not found in solr" 
    end 
  end 
  print '.' if (count%10==0) 
  puts count if (count%1000==0) 
  STDOUT.flush if (count%10==0) 
end