Class: MigrateResourcesJob
- Inherits:
-
ApplicationJob
- Object
- ApplicationJob
- MigrateResourcesJob
- Defined in:
- app/jobs/migrate_resources_job.rb
Overview
migrates models from AF to valkyrie
Instance Attribute Summary collapse
Instance Method Summary collapse
- #migrate(id) ⇒ Object
-
#perform(ids: [], models: ['AdminSet', 'Collection']) ⇒ Object
input [Array>>String] Array of ActiveFedora model names to migrate to valkyrie objects defaults to AdminSet & Collection models if empty.
Instance Attribute Details
#errors ⇒ Object
23 24 25 |
# File 'app/jobs/migrate_resources_job.rb', line 23 def errors @errors ||= [] end |
Instance Method Details
#migrate(id) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/jobs/migrate_resources_job.rb', line 27 def migrate(id) resource = Hyrax.query_service.find_by(id: id) return unless resource.wings? # this resource has already been converted result = MigrateResourceService.new(resource: resource).call errors << result unless result.success? result end |
#perform(ids: [], models: ['AdminSet', 'Collection']) ⇒ Object
input [Array>>String] Array of ActiveFedora model names to migrate to valkyrie objects defaults to AdminSet & Collection models if empty
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/jobs/migrate_resources_job.rb', line 8 def perform(ids: [], models: ['AdminSet', 'Collection']) if ids.blank? models.each do |model| model.constantize.find_each do |item| migrate(item.id) end end else ids.each do |id| migrate(id) end end raise errors.inspect if errors.present? end |