From 081c553489d2a3c4f8f9998f4523ce666905da5c Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 14 Nov 2024 11:03:03 -0800 Subject: [PATCH 1/5] Update hyrax pulls in ref: - https://github.com/samvera/hyrax/commit/a9c8e9cd3c59cbad77cf39f816181d7f9610c281 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 79526d476..4af174c94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,7 +120,7 @@ GIT GIT remote: https://github.com/samvera/hyrax.git - revision: faae072ddcbb1089552400183ad01bc74a60c452 + revision: a9c8e9cd3c59cbad77cf39f816181d7f9610c281 branch: main specs: hyrax (5.0.1) From ce3754d2648e3e006e2615739b41bb9d9ba5c3e5 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Thu, 14 Nov 2024 11:50:42 -0800 Subject: [PATCH 2/5] rubocop fix this was a lint failure in main --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 94a15f300..6691a6ac2 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -50,7 +50,7 @@ config.force_ssl = true config.ssl_options = { redirect: { - exclude: -> request { request.path == '/healthz' } + exclude: ->(request) { request.path == '/healthz' } } } # Use the lowest log level to ensure availability of diagnostic information From cf65195f751c6dce42d9bdba361a6f8d846e592d Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Fri, 15 Nov 2024 09:20:23 -0800 Subject: [PATCH 3/5] removing code that was moved into Hyrax ref: - https://github.com/samvera/hyrax/commit/a9c8e9cd3c59cbad77cf39f816181d7f9610c281#diff-843d5f344066ba9de62a999cf88a87b29479b10988676c0bc474f4853e2adaf4 --- app/jobs/migrate_resources_job.rb | 28 ------------ app/services/migrate_resource_service.rb | 55 ------------------------ spec/jobs/migrate_resources_job_spec.rb | 44 ------------------- 3 files changed, 127 deletions(-) delete mode 100644 app/jobs/migrate_resources_job.rb delete mode 100644 app/services/migrate_resource_service.rb delete mode 100644 spec/jobs/migrate_resources_job_spec.rb diff --git a/app/jobs/migrate_resources_job.rb b/app/jobs/migrate_resources_job.rb deleted file mode 100644 index 128f75779..000000000 --- a/app/jobs/migrate_resources_job.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -# migrates models from AF to valkyrie -class MigrateResourcesJob < ApplicationJob - attr_accessor :errors - # input [Array>>String] Array of ActiveFedora model names to migrate to valkyrie objects - # defaults to AdminSet & Collection models if empty - def perform(models: ['AdminSet', 'Collection'], ids: []) - errors = [] - if ids.blank? - models.each do |model| - model.constantize.find_each do |item| - resource = Hyrax.query_service.find_by(id: item.id) - result = MigrateResourceService.new(resource: resource).call - errors << result unless result.success? - end - end - else - ids.each do |id| - resource = Hyrax.query_service.find_by(id: id) - next unless resource.wings? # this resource has already been converted - result = MigrateResourceService.new(resource: resource).call - errors << result unless result.success? - end - end - raise errors.inspect if errors.present? - end -end diff --git a/app/services/migrate_resource_service.rb b/app/services/migrate_resource_service.rb deleted file mode 100644 index a8d2b2b41..000000000 --- a/app/services/migrate_resource_service.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true - -# migrates models from AF to valkyrie -class MigrateResourceService - attr_accessor :resource - def initialize(resource:) - @resource = resource - end - - def model - @model || Wings::ModelRegistry.lookup(resource.class).to_s - end - - def call - prep_resource - Hyrax::Transactions::Container[model_events(model)] - .with_step_args(**model_steps(model)).call(resource_form) - end - - def prep_resource - case model - when 'FileSet' - resource.creator << ::User.batch_user.email if resource.creator.blank? - end - end - - def resource_form - @resource_form ||= Hyrax::Forms::ResourceForm.for(resource: resource) - end - - 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 - - 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 -end diff --git a/spec/jobs/migrate_resources_job_spec.rb b/spec/jobs/migrate_resources_job_spec.rb deleted file mode 100644 index 4eb7102f3..000000000 --- a/spec/jobs/migrate_resources_job_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -require 'freyja/persister' -RSpec.describe MigrateResourcesJob, clean: true do - before do - ActiveJob::Base.queue_adapter = :test - FactoryBot.create(:group, name: "public") - end - - after do - clear_enqueued_jobs - end - - let(:account) { create(:account_with_public_schema) } - let(:af_file_set) { create(:file_set, title: ['TestFS']) } - - let!(:af_admin_set) do - as = AdminSet.new(title: ['AF Admin Set']) - as.save - AdminSet.find(as.id) - end - - describe '#perform' do - it "migrates admin sets to valkyrie", active_fedora_to_valkyrie: true do - expect(Valkyrie::Persistence::Postgres::ORM::Resource.find_by(id: af_admin_set.id.to_s)).to be_nil - - ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true - switch!(account) - MigrateResourcesJob.perform_now - - expect(Valkyrie::Persistence::Postgres::ORM::Resource.find_by(id: af_admin_set.id.to_s)).to be_present - end - - it "migrates a file set by its id", active_fedora_to_valkyrie: true do - expect(Valkyrie::Persistence::Postgres::ORM::Resource.find_by(id: af_file_set.id.to_s)).to be_nil - - ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true - switch!(account) - MigrateResourcesJob.perform_now(ids: [af_file_set.id]) - - expect(Valkyrie::Persistence::Postgres::ORM::Resource.find_by(id: af_file_set.id.to_s)).to be_present - end - end -end From 09e2deb19ebd92287b6469ebf537853e9153f994 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 15 Nov 2024 14:09:04 -0500 Subject: [PATCH 4/5] Temporary switch branch of Hyrax --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 68f8f7f6b..b6ca58b1d 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,7 @@ gem 'good_job', '~> 2.99' gem 'googleauth', '~> 1.9.0' gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux gem 'grpc', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux -gem 'hyrax', github: 'samvera/hyrax', branch: 'main' +gem 'hyrax', github: 'samvera/hyrax', branch: 'send-string-ids-to-job' gem 'hyrax-doi', github: 'samvera-labs/hyrax-doi', branch: 'rails_hyrax_upgrade' gem 'hyrax-iiif_av', github: 'samvera-labs/hyrax-iiif_av', branch: 'rails_hyrax_upgrade' gem 'i18n-debug', require: false, group: %i[development test] diff --git a/Gemfile.lock b/Gemfile.lock index 4af174c94..b14b462d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,8 +120,8 @@ GIT GIT remote: https://github.com/samvera/hyrax.git - revision: a9c8e9cd3c59cbad77cf39f816181d7f9610c281 - branch: main + revision: e56340c729064b95611452211e3235a5eb5f85b1 + branch: send-string-ids-to-job specs: hyrax (5.0.1) active-fedora (~> 14.0) From 38a32e82b82f11d6685963c437c9273c39c91a4f Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Fri, 15 Nov 2024 14:53:55 -0500 Subject: [PATCH 5/5] Revert to using Hyrax main branch --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b6ca58b1d..68f8f7f6b 100644 --- a/Gemfile +++ b/Gemfile @@ -53,7 +53,7 @@ gem 'good_job', '~> 2.99' gem 'googleauth', '~> 1.9.0' gem 'google-protobuf', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux gem 'grpc', force_ruby_platform: true # required because google-protobuf is not compatible with Alpine linux -gem 'hyrax', github: 'samvera/hyrax', branch: 'send-string-ids-to-job' +gem 'hyrax', github: 'samvera/hyrax', branch: 'main' gem 'hyrax-doi', github: 'samvera-labs/hyrax-doi', branch: 'rails_hyrax_upgrade' gem 'hyrax-iiif_av', github: 'samvera-labs/hyrax-iiif_av', branch: 'rails_hyrax_upgrade' gem 'i18n-debug', require: false, group: %i[development test] diff --git a/Gemfile.lock b/Gemfile.lock index b14b462d4..03ff39836 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,8 +120,8 @@ GIT GIT remote: https://github.com/samvera/hyrax.git - revision: e56340c729064b95611452211e3235a5eb5f85b1 - branch: send-string-ids-to-job + revision: abd5955f325b966ebd21d0de8d96b61cf0421cf3 + branch: main specs: hyrax (5.0.1) active-fedora (~> 14.0)