From a59259753d58f7541b991ec2824a713f564c0498 Mon Sep 17 00:00:00 2001 From: Jamie Little Date: Fri, 23 Mar 2018 14:21:56 -0500 Subject: [PATCH] Add alexandria url prefix to identifier for OAI This adds a url prefix to the identifier element in the OAI-PMH feed. The rules in Primo are setup so that they check for the http prefix to create links. This creates a configuration option to set the prefix and concats the prefix to existing identifier element in the solr document via the `ObjectIndexer`. --- app/indexers/object_indexer.rb | 3 +++ app/models/solr_document.rb | 4 ++-- config/application.yml | 1 + spec/requests/oai_spec.rb | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/indexers/object_indexer.rb b/app/indexers/object_indexer.rb index bd6323ea3..ced03535f 100644 --- a/app/indexers/object_indexer.rb +++ b/app/indexers/object_indexer.rb @@ -57,6 +57,9 @@ def generate_solr_document s.respond_to?(:rdf_label) ? s.rdf_label : s end.flatten + solr_doc["uri_ssm"] = + "#{Settings.oai_identifier_prefix}#{object.identifier.first}" + yield(solr_doc) if block_given? end end diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 1b6bc2d50..e13a974fc 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -37,9 +37,9 @@ class SolrDocument creator: "creator_tesim", date: "date_si", format: "form_of_work_label_tesim", - identifier: "identifier_ssm", + identifier: "uri_ssm", publisher: "publisher_tesim", - relation: %w[collection_label_ssim square_thumbnail_url_ssm], + relation: "collection_label_ssim", rights: "license_tesim", type: "work_type_label_tesim" ) diff --git a/config/application.yml b/config/application.yml index 7c841515f..b82def273 100644 --- a/config/application.yml +++ b/config/application.yml @@ -27,6 +27,7 @@ defaults: &defaults oai_repository_name: "Alexandria Digital Research Library" oai_repository_url: "https://alexandria.ucsb.edu/catalog/oai" oai_record_prefix: "oai:ucsb" + oai_identifier_prefix: "https://alexandria.ucsb.edu/lib/" uploads_dir: <%= ENV['ADRL_UPLOADS'] || Rails.root.join("tmp", "uploads") %> development: diff --git a/spec/requests/oai_spec.rb b/spec/requests/oai_spec.rb index 1f4da92f2..c053f32e2 100644 --- a/spec/requests/oai_spec.rb +++ b/spec/requests/oai_spec.rb @@ -38,8 +38,9 @@ expect(response.body).to match(%r{.*<\/dc:title>}) end - it "has a record in the repo with a dc identifier" do + it "has a record in the repo with a dc identifier with an http prefix" do get "/catalog/oai?verb=ListRecords&metadataPrefix=oai_dc" - expect(response.body).to match(%r{.*<\/dc:identifier>}) + prefix_id = %r{https://alexandria.ucsb.edu/lib/.*<\/dc:identifier>} + expect(response.body).to match(prefix_id) end end