From 426a53804e1041968d97d49b7939006e3036669b Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Tue, 18 Jul 2023 19:29:14 -0500 Subject: [PATCH 1/4] works in a one step workflow are able to be approved by a manager. we needed to update Hyrax::ActiveFedoraDummyModel#to_global_id so that the gid created for valkyrie works matches what is found in the "sipity_entries" database table. now, when @query_cache is set/updated in active record, it can find the appropriate data. --- lib/hyrax/active_fedora_dummy_model.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/hyrax/active_fedora_dummy_model.rb b/lib/hyrax/active_fedora_dummy_model.rb index add9ffe8a8..72c5cd6fac 100644 --- a/lib/hyrax/active_fedora_dummy_model.rb +++ b/lib/hyrax/active_fedora_dummy_model.rb @@ -69,7 +69,11 @@ def to_partial_path ## # @api public def to_global_id - URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id + if Hyrax.config.use_valkyrie? + URI::GID.build app: GlobalID.app, model_name: Hyrax::ValkyrieGlobalIdProxy.to_s, model_id: @id + else + URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id + end end end end From ec902fc348c315a240e3ef339d0d2a89cac9aac4 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Wed, 26 Jul 2023 10:36:14 -0500 Subject: [PATCH 2/4] update the failing specs that rely on #to_global_id --- spec/models/concerns/hyrax/solr_document_behavior_spec.rb | 3 ++- spec/models/sipity_spec.rb | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/models/concerns/hyrax/solr_document_behavior_spec.rb b/spec/models/concerns/hyrax/solr_document_behavior_spec.rb index 68ba59dcff..b4801c19d2 100644 --- a/spec/models/concerns/hyrax/solr_document_behavior_spec.rb +++ b/spec/models/concerns/hyrax/solr_document_behavior_spec.rb @@ -167,7 +167,8 @@ end it 'gives the global id for the valkyrie class' do - expect(solr_document.to_model.to_global_id.to_s).to end_with('Monograph/123') + model_name = Hyrax.config.use_valkyrie? ? 'Hyrax::ValkyrieGlobalIdProxy' : 'Monograph' + expect(solr_document.to_model.to_global_id.to_s).to end_with("#{model_name}/123") end end end diff --git a/spec/models/sipity_spec.rb b/spec/models/sipity_spec.rb index 82fe4e1843..00fbebcf65 100644 --- a/spec/models/sipity_spec.rb +++ b/spec/models/sipity_spec.rb @@ -46,8 +46,11 @@ context "with a SolrDocument" do let(:object) { SolrDocument.new(id: '9999', has_model_ssim: ["GenericWork"]) } let(:workflow_state) { create(:workflow_state) } + let(:proxy_for_global_id) do + Hyrax.config.use_valkyrie? ? 'Hyrax::ValkyrieGlobalIdProxy' : 'GenericWork' + end let!(:entity) do - Sipity::Entity.create(proxy_for_global_id: "gid://#{GlobalID.app}/GenericWork/9999", + Sipity::Entity.create(proxy_for_global_id: "gid://#{GlobalID.app}/#{proxy_for_global_id}/9999", workflow_state: workflow_state, workflow: workflow_state.workflow) end From b21b51bffdecb4f33f16d51ffa410da91d366c50 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 27 Jul 2023 13:35:07 -0500 Subject: [PATCH 3/4] update #to_global_id to allow for a non Valkyrie::Resource created in Valkyrie, to also get the correct URI::GID set. co-authored-by: braydon --- lib/hyrax/active_fedora_dummy_model.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/hyrax/active_fedora_dummy_model.rb b/lib/hyrax/active_fedora_dummy_model.rb index 72c5cd6fac..0ae1dcb8de 100644 --- a/lib/hyrax/active_fedora_dummy_model.rb +++ b/lib/hyrax/active_fedora_dummy_model.rb @@ -69,7 +69,8 @@ def to_partial_path ## # @api public def to_global_id - if Hyrax.config.use_valkyrie? + # this covers the use case of creating a non Valkyrie::Resource, while using Valkyrie + if model_name.name.constantize <= Valkyrie::Resource URI::GID.build app: GlobalID.app, model_name: Hyrax::ValkyrieGlobalIdProxy.to_s, model_id: @id else URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id From 92ff4f4f21bfaa9c65e146323108a97ba49a153d Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 27 Jul 2023 19:17:30 -0500 Subject: [PATCH 4/4] fix the two specs that reverted to failing after updating #to_global_id to check whether the item being examined was a Valkyrie::Resource, and not whether Hyrax.config.use_valkyrie? is true. ref: #5573 --- spec/models/concerns/hyrax/solr_document_behavior_spec.rb | 3 +-- spec/models/sipity_spec.rb | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/models/concerns/hyrax/solr_document_behavior_spec.rb b/spec/models/concerns/hyrax/solr_document_behavior_spec.rb index b4801c19d2..d619e7cb09 100644 --- a/spec/models/concerns/hyrax/solr_document_behavior_spec.rb +++ b/spec/models/concerns/hyrax/solr_document_behavior_spec.rb @@ -167,8 +167,7 @@ end it 'gives the global id for the valkyrie class' do - model_name = Hyrax.config.use_valkyrie? ? 'Hyrax::ValkyrieGlobalIdProxy' : 'Monograph' - expect(solr_document.to_model.to_global_id.to_s).to end_with("#{model_name}/123") + expect(solr_document.to_model.to_global_id.to_s).to end_with('Hyrax::ValkyrieGlobalIdProxy/123') end end end diff --git a/spec/models/sipity_spec.rb b/spec/models/sipity_spec.rb index 00fbebcf65..82fe4e1843 100644 --- a/spec/models/sipity_spec.rb +++ b/spec/models/sipity_spec.rb @@ -46,11 +46,8 @@ context "with a SolrDocument" do let(:object) { SolrDocument.new(id: '9999', has_model_ssim: ["GenericWork"]) } let(:workflow_state) { create(:workflow_state) } - let(:proxy_for_global_id) do - Hyrax.config.use_valkyrie? ? 'Hyrax::ValkyrieGlobalIdProxy' : 'GenericWork' - end let!(:entity) do - Sipity::Entity.create(proxy_for_global_id: "gid://#{GlobalID.app}/#{proxy_for_global_id}/9999", + Sipity::Entity.create(proxy_for_global_id: "gid://#{GlobalID.app}/GenericWork/9999", workflow_state: workflow_state, workflow: workflow_state.workflow) end