Skip to content

Commit

Permalink
feat: APPS-2471 Add a "Related Records" metadata field (#945)
Browse files Browse the repository at this point in the history
* add all related_record items

* change to ssm

* fix tests

* fix linting errors

* Add title and link

* fix: errors with related records

* fix: spec updated to reflect the correct work count and fix work indexer spec for related records

* fix: rspec errors for related records

* fix: rubocop errors of indentation

* fix: more rspec errors

* fix: rubocop error

* fix: update rspec to allow related work

* fix: update rspec to allow related work

* fix: last test error fixed

---------

Co-authored-by: pghorpade <pghorpade@library.ucla.edu>
  • Loading branch information
jendiamond and pghorpade authored Nov 9, 2023
1 parent 2058b72 commit 0317f84
Show file tree
Hide file tree
Showing 34 changed files with 188 additions and 34 deletions.
2 changes: 1 addition & 1 deletion app/assets/csv/import_manifest.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Object Type,Title,Item ARK,Parent ARK,Rights.copyrightStatus,File Name,AltIdentifier.local,AltTitle.other,Binding note,Condition note,Coverage.geographic,Date.creation,Date.normalized,Description.caption,Description.fundingNote,Description.latitude,Description.longitude,Description.note,Format.dimensions,Format.extent,Format.medium,Language,Name.architect,Name.photographer,Name.repository,Name.subject,Name.repository,Opac url,Project Name,Publisher.publisherName,Relation.isPartOf,Rights.countryCreation,Rights.rightsHolderContact,Subject,Type.genre,Type.typeOfResource,Place of origin,AltTitle.uniform,Support,Summary,Page layout,Text direction,viewingHint,IIIF Range,Illustrations note,Provenance; Description.history,Table of Contents; Description.tableOfContents,Subject.conceptTopic,Subject.descriptiveTopic,Collation,Foliation note,Foliation,Illuminator,Name.illuminator,Name.lyricist,Name.composer,Scribe,Name.scribe,Masthead,Representative image,Featured image,Tagline,Subject geographic,Subject temporal,Translator,Name.translator,Commentator,Name.commentator,Colophon,Finding Aid URL, Alt ID.url, Rubricator,Name.rubricator,License,Illustrator,Name.illustrator,Calligrapher,Name.calligrapher,Editor,Name.editor,Engraver,Name.engraver,Note,Printmaker,Name.printmaker,Contents note,Description.contents,Content disclaimer,Interviewer,Name.interviewer,Interviewee,Name.interviewee,Cartographer,Name.cartographer,Artist,Name.artist,Recipient,Name.recipient,Director,Name.director,Producer,Name.producer,Program,Subject.culturalObject,Subject.domainTopic,Series,Host,Name.host,Musician,Name.musician,Printer,Name.printer,Researcher,Name.researcher, Statement of Responsibility,References,AdminNote,Description.adminnote,Note.admin,Format,Related Items,Rights.statementLocal
Object Type,Title,Item ARK,Parent ARK,Rights.copyrightStatus,File Name,AltIdentifier.local,AltTitle.other,Binding note,Condition note,Coverage.geographic,Date.creation,Date.normalized,Description.caption,Description.fundingNote,Description.latitude,Description.longitude,Description.note,Format.dimensions,Format.extent,Format.medium,Language,Name.architect,Name.photographer,Name.repository,Name.subject,Name.repository,Opac url,Project Name,Publisher.publisherName,Relation.isPartOf,Rights.countryCreation,Rights.rightsHolderContact,Subject,Type.genre,Type.typeOfResource,Place of origin,AltTitle.uniform,Support,Summary,Page layout,Text direction,viewingHint,IIIF Range,Illustrations note,Provenance; Description.history,Table of Contents; Description.tableOfContents,Subject.conceptTopic,Subject.descriptiveTopic,Collation,Foliation note,Foliation,Illuminator,Name.illuminator,Name.lyricist,Name.composer,Scribe,Name.scribe,Masthead,Representative image,Featured image,Tagline,Subject geographic,Subject temporal,Translator,Name.translator,Commentator,Name.commentator,Colophon,Finding Aid URL, Alt ID.url, Rubricator,Name.rubricator,License,Illustrator,Name.illustrator,Calligrapher,Name.calligrapher,Editor,Name.editor,Engraver,Name.engraver,Note,Printmaker,Name.printmaker,Contents note,Description.contents,Content disclaimer,Interviewer,Name.interviewer,Interviewee,Name.interviewee,Cartographer,Name.cartographer,Artist,Name.artist,Recipient,Name.recipient,Director,Name.director,Producer,Name.producer,Program,Subject.culturalObject,Subject.domainTopic,Series,Host,Name.host,Musician,Name.musician,Printer,Name.printer,Researcher,Name.researcher,Statement of Responsibility,References,AdminNote,Description.adminnote,Note.admin,Format,Related Items,Rights.statementLocal,Related Records
11 changes: 7 additions & 4 deletions app/assets/markdown/importer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
- [Name.engraver](#nameengraver)
- [Name.illuminator](#nameilluminator)
- [Name.illustrator](#nameillustrator)
- [Name.interviewee](#nameinterviewee)
- [Name.interviewer](#nameinterviewer)
- [Name.interviewee](#nameinterviewee)
- [Name.interviewer](#nameinterviewer)
- [Name.lyricist](#namelyricist)
- [Name.musician](#namemusician)
- [Name.photographer](#namephotographer)
Expand All @@ -84,6 +84,7 @@
- [Project Name](#project-name)
- [Provenance](#provenance)
- [Publisher.publisherName](#publisherpublishername)
- [Related Records](#human_readable_related_record_title_ssm)
- [Related Items](#related_to)
- [References](# citation_source)
- [Relation.isPartOf](#relationispartof)
Expand Down Expand Up @@ -194,7 +195,7 @@ Examples:
## Other Supported Fields

#### AdminNote

Also accepts: `Description.adminnote`,`Note.admin`

#### AltTitle.other
Expand Down Expand Up @@ -350,7 +351,7 @@ Also accepts: `Commentator`

Also accepts: `Creator`

#### Name.director
#### Name.director

Also accepts: `Director`

Expand Down Expand Up @@ -442,6 +443,8 @@ DLCS collection name

#### Related Items

#### Related Records

#### Repository

Also accepts: `Name.repository`, `repository`, `Personal or Corporate Name.repository`
Expand Down
1 change: 1 addition & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def self.modified_field
config.add_show_field 'program_tesim'
config.add_show_field 'provenance_tesim'
config.add_show_field 'recipient_tesim'
config.add_show_field 'human_readable_related_record_title_ssm', label: 'Related Records', helper_method: :iconify_auto_link
config.add_show_field 'related_to_ssm', label: 'Related Items'
config.add_show_field 'repository_tesim'
config.add_show_field 'researcher_tesim'
Expand Down
2 changes: 2 additions & 0 deletions app/forms/hyrax/californica_collections_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class CalifornicaCollectionsForm < Hyrax::Forms::CollectionForm
:provenance,
:recipient,
:related_to,
:related_record,
:related_url,
:repository,
:representative_image,
Expand Down Expand Up @@ -174,6 +175,7 @@ def secondary_terms
:provenance,
:publisher,
:recipient,
:related_record,
:related_to,
:related_url,
:repository,
Expand Down
1 change: 1 addition & 0 deletions app/forms/hyrax/work_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class WorkForm < Hyrax::Forms::WorkForm
:program,
:provenance,
:recipient,
:related_record,
:related_to,
:repository,
:representative_image,
Expand Down
1 change: 1 addition & 0 deletions app/importers/californica_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class CalifornicaMapper < Darlingtonia::HashMapper
provenance: ["Provenance", "Description.history"],
publisher: "Publisher.publisherName",
recipient: ["Recipient", "Name.recipient"],
related_record: ['Related Records'],
related_to: ["Related Items"],
repository: ["Repository", "repository", "Name.repository",
"Personal or Corporate Name.repository"],
Expand Down
22 changes: 22 additions & 0 deletions app/indexers/work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,31 @@ def generate_solr_document
solr_doc['title_alpha_numeric_ssort'] = object.title.first
solr_doc['ursus_id_ssi'] = Californica::IdGenerator.blacklight_id_from_ark(object.ark)
solr_doc['year_isim'] = years
solr_doc['human_readable_related_record_title_ssm'] = find_related_records_titles_by_ark
end
end

# https://github.com/samvera/hyrax/blob/c728f537d1ccca9762a3f01e9f30a55983e8820d/app/indexers/hyrax/work_indexer.rb#L11
def find_related_records_titles_by_ark
if object.related_record
ark_titles = []
object.related_record.each do |ark_string|
# Assuming you want to call find_by_ark on each ark_string
result = Work.find_by_ark(ark_string)
if result
ursus_url = ::Ursus::Record.url_for_ark(result)
ark_titles.push("<a href='#{ursus_url}'>#{result.title.first}</a>")
end
end
ark_titles
end
end

def related_record_title_markup(ursus_url, title)
title_markup = '<a href="' + ursus_url + '">' + title + '</a>'
title_markup
end

def add_dates(solr_doc)
valid_dates = solr_dates
solr_doc['date_dtsim'] = valid_dates if valid_dates
Expand Down
8 changes: 8 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def host
self[:host_tesim]
end

def human_readable_related_record_title
self[:human_readable_related_record_title_ssm]
end

def iiif_manifest_url
self[:iiif_manifest_url_ssi] || ""
end
Expand Down Expand Up @@ -286,6 +290,10 @@ def recipient
self[:recipient_tesim]
end

def related_record
self[:related_record_ssm]
end

def related_to
self[:related_to_ssm]
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/ucla_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ module UclaMetadata
index.as :stored_sortable
end

property :related_record, predicate: ::RDF::URI.intern('http://id.loc.gov/ontologies/bibframe/accompaniedBy') do |index|
index.as :displayable
end

property :related_to, predicate: ::RDF::URI.intern('http://id.loc.gov/ontologies/bibframe/relatedTo') do |index|
index.as :displayable
end
Expand Down
1 change: 1 addition & 0 deletions app/presenters/hyrax/californica_collection_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def self.terms
:producer,
:publisher,
:recipient,
:related_record,
:related_to,
:related_url,
:representative_image,
Expand Down
2 changes: 2 additions & 0 deletions app/presenters/hyrax/work_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class WorkPresenter < Hyrax::WorkShowPresenter
:program,
:provenance,
:recipient,
:related_record,
:human_readable_related_record_title,
:related_to,
:repository,
:representative_image,
Expand Down
5 changes: 5 additions & 0 deletions app/services/ursus/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ def self.url_for(record)
return unless ursus_hostname
"#{protocol}#{ursus_hostname}/catalog/#{record.id}"
end

def self.url_for_ark(record)
return unless ursus_hostname
"#{protocol}#{ursus_hostname}/catalog/#{record.ark}"
end
end
end
17 changes: 17 additions & 0 deletions app/views/hyrax/base/_attribute_rows.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,24 @@
<%= presenter.attribute_to_html(:program, html_dl: true) %>
<%= presenter.attribute_to_html(:provenance, html_dl: true) %>
<%= presenter.attribute_to_html(:publisher, render_as: :faceted, html_dl: true) %>

<%= presenter.attribute_to_html(:recipient, html_dl: true) %>
<% if presenter.human_readable_related_record_title.present? %>
<div style="font-weight: 700">Related Records</div>

<% presenter.human_readable_related_record_title.each do | related_record_title | %>
<dd>
<dt>
<ul class="tabular">
<li class="attribute attribute-human_readable_related_record_title"><%= raw related_record_title %></li>
</ul>
<dt>
</dd>
<% end %>

<% end %>


<%= presenter.attribute_to_html(:related_to, html_dl: true, label: 'Related Items') %>
<%= presenter.attribute_to_html(:citation_source, html_dl: true, label: "References") %>
<%= presenter.attribute_to_html(:related_url, render_as: :external_link, html_dl: true) %>
Expand Down
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default: &default
adapter: <%= ENV['DATABASE_ADAPTER'] || 'mysql2' %>
pool: <%= ENV['DATABASE_POOL'] || 5 %>
timeout: 5000
timeout: 10000
host: <%= ENV['DATABASE_HOST'] || 'localhost' %>
min_messages: <%= ENV['DATABASE_MIN_MESSAGES'] || 'warning' %>
username: <%= ENV['DATABASE_USERNAME'] || 'californica' %>
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ services:

db:
image: uclalibrary/californica-mariadb:10.3
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1"]
interval: 10s
timeout: 5s
retries: 3
volumes:
- ./docker/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./docker/conf.d:/etc/mysql/conf.d
Expand Down
Loading

0 comments on commit 0317f84

Please sign in to comment.