-
Notifications
You must be signed in to change notification settings - Fork 5
Bulk Changes to Items in Sets
Ryan Wick edited this page Jun 24, 2015
·
8 revisions
Bulk changes to Oregon Digital items are possible from the Rails Console. This page is to provide examples of what's been done and help inform future cleanup work.
For test runs: Comment out the save, add puts statements showing result, change 'rows' value to 10 or 1, then check those items.
ActiveFedora::SolrService.query("desc_metadata__set_sim:#{RSolr.escape("http://oregondigital.org/resource/oregondigital:osu-baseball")}", :fl => "id", :rows => 100000).map{|x| x["id"]}.each do |pid|
puts pid
bb = Image.find(:pid => pid).first || Document.find(:pid => pid).first || Audio.find(:pid => pid).first || GenericAsset.find(:pid => pid).first
next if bb.descMetadata.isPartOf.empty?
collection = bb.descMetadata.isPartOf.first.rdf_subject.to_s.gsub('http://data.library.oregonstate.edu/collection/', 'http://opaquenamespace.org/ns/localCollectionName/')
next if collection.nil?
bb.descMetadata.localCollectionName = RDF::URI(collection)
bb.descMetadata.isPartOf.clear
puts "Local Collection: #{collection}"
bb.save!
end
Used to add items in OSU Yearbooks set to OSU Historical Publications set as well.
hp = GenericCollection.find(:pid => 'oregondigital:osu-historical-publications').first
ActiveFedora::SolrService.query("desc_metadata__set_sim:#{RSolr.escape("http://oregondigital.org/resource/oregondigital:osu-yearbooks")}", :fl => "id", :rows => 100000).map{|x| x["id"]}.each do |pid|
c1 = Image.find(:pid => pid).first || Document.find(:pid => pid).first || Audio.find(:pid => pid).first || Video.find(:pid => pid).first || GenericAsset.find(:pid => pid).first
c1.set << hp
c1.save!
end