Skip to content

Instantly share code, notes, and snippets.

@rosy1280
Last active August 29, 2015 14:11
Show Gist options
  • Save rosy1280/93d2ca20d8706b4deca4 to your computer and use it in GitHub Desktop.
Save rosy1280/93d2ca20d8706b4deca4 to your computer and use it in GitHub Desktop.
get all the tags for a list of objects
#!/usr/bin/env ruby
# usage is ruby bulkGetTagsScript.rb env druid-list.txt
# where env is the environment in which you want to run the script (production, test, development)
# and druid-list.txt is the list of druids you want to bulk close.
unless(ARGV.first.nil?)
ENV['ROBOT_ENVIRONMENT'] = ARGV.first
end
require File.expand_path(File.dirname(__FILE__) + '/../config/boot')
#pull the file from the commandline argument and read each line into the druids array
druids = []
druidlist = File.open(ARGV.second)
druidlist.each_line {|line|
druids.push line.chomp
}
druids.each do |druid|
begin
#format the druids
druid = "druid:#{druid}" unless druid.start_with?('druid')
#make sure that they exist in dor
@object=Dor::Item.find(druid)
#output the druid and the tag for the object
#to do: the output isn't really a .csv file. i need to figure out how to format the tags so that they display nicely
p "#{druid}, #{@object.identityMetadata.tag}"
end
end
puts "Done!"
@rosy1280
Copy link
Author

when doing bulk remediation of tags in argo, if you don't include existing tags when running the remediation, they are wiped from the identityMetadata. you could pull a report from Argo that gives you the tags, however if the objects are not grouped together in anyway (ie via a tag, a collection, an apo) then there is no easy way to get the tags.

i created this script to help me pull all the tags from a random list of druids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment