Last active
August 29, 2015 14:10
-
-
Save rosy1280/c301f96660c963592967 to your computer and use it in GitHub Desktop.
bulk close versions via console
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
druids = ["druid:bt238kw3938", "druid:bw690ww9101", "druid:cc502yd9847", "druid:ch100bz7050"] | |
druids.each do |druid| | |
begin | |
@object=Dor::Item.find(druid) | |
# for some reason this doesn't seem to work. no idea why... | |
#Dor::WorkflowService.close_version 'dor', @object.pid, {:description=>'apply apo defaults', :significance=>:minor} | |
# so instead I'll do the following | |
@object.versionMetadata.update_current_version({:description=>'apply apo defaults', :significance=>:minor}) | |
@object.save | |
Dor::WorkflowService.close_version 'dor', @object.pid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i noticed that the bulk close doesn't work when an object's version metadata is jankey like the below
this little script when run in console fixes that.
documentation: http://www.rubydoc.info/gems/dor-services/Dor/Versionable:close_version
code: https://github.com/sul-dlss/dor-services/blob/24ec33c8e289e81fe5926b2727a9b3d0b624e40a/lib/dor/models/versionable.rb#L63