Last active
August 29, 2015 14:10
-
-
Save rosy1280/f4b25437e2ed51d83412 to your computer and use it in GitHub Desktop.
bulk close version via a script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script should be placed in the bin directory of the common accessioning robot suite