Class: MigrateResourceService
- Inherits:
-
Object
- Object
- MigrateResourceService
- Defined in:
- app/services/migrate_resource_service.rb
Overview
migrates models from AF to valkyrie
Instance Attribute Summary collapse
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(resource:) ⇒ MigrateResourceService
constructor
A new instance of MigrateResourceService.
- #model ⇒ Object
- #model_events(model) ⇒ Object
- #model_steps(model) ⇒ Object
- #prep_resource ⇒ Object
- #resource_form ⇒ Object
Constructor Details
#initialize(resource:) ⇒ MigrateResourceService
Returns a new instance of MigrateResourceService.
6 7 8 |
# File 'app/services/migrate_resource_service.rb', line 6 def initialize(resource:) @resource = resource end |
Instance Attribute Details
#resource ⇒ Object
Returns the value of attribute resource.
5 6 7 |
# File 'app/services/migrate_resource_service.rb', line 5 def resource @resource end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 |
# File 'app/services/migrate_resource_service.rb', line 14 def call prep_resource Hyrax::Transactions::Container[model_events(model)] .with_step_args(**model_steps(model)).call(resource_form) end |
#model ⇒ Object
10 11 12 |
# File 'app/services/migrate_resource_service.rb', line 10 def model @model ||= Wings::ModelRegistry.lookup(resource.class).to_s end |
#model_events(model) ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/services/migrate_resource_service.rb', line 31 def model_events(model) { 'AdminSet' => 'admin_set_resource.update', 'Collection' => 'change_set.update_collection', 'FileSet' => 'change_set.update_file_set' }[model] || 'change_set.update_work' end |
#model_steps(model) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/services/migrate_resource_service.rb', line 39 def model_steps(model) { 'AdminSet' => {}, 'Collection' => { 'collection_resource.save_collection_banner' => { banner_unchanged_indicator: true }, 'collection_resource.save_collection_logo' => { logo_unchanged_indicator: true } }, 'FileSet' => { 'file_set.save_acl' => {} } }[model] || { 'work_resource.add_file_sets' => { uploaded_files: [], file_set_params: [] }, 'work_resource.update_work_members' => { work_members_attributes: [] }, 'work_resource.save_acl' => { permissions_params: [] } } end |
#prep_resource ⇒ Object
20 21 22 23 24 25 |
# File 'app/services/migrate_resource_service.rb', line 20 def prep_resource case model when 'FileSet' resource.creator << ::User.batch_user.email if resource.creator.blank? end end |
#resource_form ⇒ Object
27 28 29 |
# File 'app/services/migrate_resource_service.rb', line 27 def resource_form @resource_form ||= Hyrax::Forms::ResourceForm.for(resource: resource) end |