Skip to content

Instantly share code, notes, and snippets.

@rosy1280
Last active August 29, 2015 14:10
Show Gist options
  • Save rosy1280/f4b25437e2ed51d83412 to your computer and use it in GitHub Desktop.
Save rosy1280/f4b25437e2ed51d83412 to your computer and use it in GitHub Desktop.
bulk close version via a script
#!/usr/bin/env ruby
# usage is ruby bulkCloseScript.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
druid = "druid:#{druid}" unless druid.start_with?('druid')
@object=Dor::Item.find(druid)
@object.versionMetadata.update_current_version({:description=>'apply apo defaults', :significance=>:minor})
@object.save
Dor::WorkflowService.close_version 'dor', @object.pid
puts "completed object #{druid}"
end
end
puts "Done!"
@rosy1280
Copy link
Author

rosy1280 commented Dec 4, 2014

this script should be placed in the bin directory of the common accessioning robot suite

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