From 63338e73463bfc75c431e95f0c23289bd12003cb Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Wed, 17 Jan 2024 11:03:30 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A7=B9=20Add=20specs=20for=20custom?= =?UTF-8?q?=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../find_by_bulkrax_identifier_spec.rb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/services/hyrax/custom_queries/find_by_bulkrax_identifier_spec.rb diff --git a/spec/services/hyrax/custom_queries/find_by_bulkrax_identifier_spec.rb b/spec/services/hyrax/custom_queries/find_by_bulkrax_identifier_spec.rb new file mode 100644 index 000000000..8f6ef1295 --- /dev/null +++ b/spec/services/hyrax/custom_queries/find_by_bulkrax_identifier_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Hyrax::CustomQueries::FindByBulkraxIdentifier do + describe '.queries' do + subject { described_class.queries } + let(:query_name) { :find_by_bulkrax_identifier } + + it { is_expected.to include(query_name) } + + it 'is registered with the Hyrax.query_service' do + expect(Hyrax.query_service.custom_queries).to respond_to(query_name) + end + + context ':find_by_bulkrax_identifier query' do + it 'is valid SQL' do + expect do + Hyrax.query_service.custom_queries.find_by_bulkrax_identifier(identifier: "testing-bulkrax-1-2-3") + end.not_to raise_error + end + end + end +end From f2fca7776631a48f844b7e2afff679624cd28407 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Wed, 17 Jan 2024 11:10:27 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=B9=20Update=20docs=20and=20switch?= =?UTF-8?q?=20to=20Hyrax::SolrService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wings/custom_queries/find_by_bulkrax_identifier.rb | 7 +++---- lib/oai/provider/metadata_format/hyku_dublin_core.rb | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/services/wings/custom_queries/find_by_bulkrax_identifier.rb b/app/services/wings/custom_queries/find_by_bulkrax_identifier.rb index 2867dcfeb..aa86a35a9 100644 --- a/app/services/wings/custom_queries/find_by_bulkrax_identifier.rb +++ b/app/services/wings/custom_queries/find_by_bulkrax_identifier.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true module Wings module CustomQueries + # Custom query override specific to Wings + # Use: + # Hyrax.custom_queries.find_by_bulkrax_identifier(identifier: identifier, models: [ModelClass]) class FindByBulkraxIdentifier - # Custom query override specific to Wings - # Use: - # Hyrax.custom_queries.find_bulkrax_id(identifier: identifier, models: [ModelClass]) - def self.queries [:find_by_bulkrax_identifier] end diff --git a/lib/oai/provider/metadata_format/hyku_dublin_core.rb b/lib/oai/provider/metadata_format/hyku_dublin_core.rb index 02998e3c3..9cdc0452c 100644 --- a/lib/oai/provider/metadata_format/hyku_dublin_core.rb +++ b/lib/oai/provider/metadata_format/hyku_dublin_core.rb @@ -51,7 +51,7 @@ def add_public_file_urls(xml, record) return if record[:file_set_ids_ssim].blank? fs_ids = record[:file_set_ids_ssim].join('" OR "') - public_fs_ids = ActiveFedora::SolrService.query( + public_fs_ids = Hyrax::SolrService.query( "id:(\"#{fs_ids}\") AND " \ "has_model_ssim:FileSet AND " \ "visibility_ssi:#{Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC}", From 33a5b164c21aea4c54ae2fe9a2daefdabd7c88fd Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Wed, 17 Jan 2024 11:13:45 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A7=B9=20Favor=20Hyrax::AdminSetCreat?= =?UTF-8?q?eService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `Hyrax::AdminSetCreateService.find_or_create_default_admin_set` will create a permission template; as such we don't need to include that logic below. Further, the newly used service is Valkyrized and more fault tolerant. --- db/seeds.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index a3b84dae7..5d1829e6d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -16,8 +16,8 @@ end AccountElevator.switch!(single_tenant_default.cname) - puts "\n== Creating default admin set" - admin_set = AdminSet.find(Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id) + puts "\n== Creating default admin set with permission template" + Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id puts "\n== Creating default collection types" Hyrax::CollectionType.find_or_create_default_collection_type @@ -28,14 +28,6 @@ errors = Hyrax::Workflow::WorkflowImporter.load_errors abort("Failed to process all workflows:\n #{errors.join('\n ')}") unless errors.empty? - puts "\n== Creating permission template" - begin - permission_template = admin_set.permission_template - # If the permission template is missing we will need to run the creete service - rescue - Hyrax::AdminSetCreateService.new(admin_set: admin_set, creating_user: nil).create - end - puts "\n== Finished creating single tenant resources" end