Skip to content

Commit

Permalink
Add alexandria url prefix to identifier for OAI
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
little9 authored and dunn committed Mar 28, 2018
1 parent fce00cf commit a592597
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions app/indexers/object_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
1 change: 1 addition & 0 deletions config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions spec/requests/oai_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
expect(response.body).to match(%r{<dc:title>.*<\/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>.*<\/dc:identifier>})
prefix_id = %r{<dc:identifier>https://alexandria.ucsb.edu/lib/.*<\/dc:identifier>}
expect(response.body).to match(prefix_id)
end
end

0 comments on commit a592597

Please sign in to comment.