Skip to content

Child works should be able to have slugs#945

Merged
laritakr merged 4 commits intomainfrom
support-slugs-for-child-works
Apr 21, 2025
Merged

Child works should be able to have slugs#945
laritakr merged 4 commits intomainfrom
support-slugs-for-child-works

Conversation

@laritakr
Copy link
Copy Markdown
Member

@laritakr laritakr commented Apr 19, 2025

Story

Creating child works with slugs did not correctly build and display the works and relationships. Creating through the UI did not show the relationships, but creating through Bulkrax did not work at all.

Member relationships use the object's id. However the solr document is indexed with the slug as the id. We have to ensure that we search the appropriate terms in the solr document when we are searching by id.

This commit fixes two aspects of child works with slugs:

  1. It ensures that a work can find its child works with slugs.
  2. It ensures that a work with slugs can find its parent work.

This preparation is needed before bulkrax relationship fixes are incorporated into the application, as they would break the UI if they used slugs.

Note: The AdlSolrDocumentDecorator required refactoring in order to use prepend to have the instance method override Hyrax's SolrDocument. Previously methods were added via include, and nothing was overridden.

Expected Behavior Before Changes

When creating a child work with a slug in the UI, the relationship was not shown.
Child works and parent works could not form relationships through Bulkrax.

Expected Behavior After Changes

Parent works include child works both with and without slugs in the items list.
Child works with slugs show their parent work in the relationships section.
Filesets still show correctly as part of the work in the items list.

Screenshots / Video

Work with 2 child works

This is a work that has a slugs. It has two child works, one with a slug and one with a UUID. It also has a fileset. It correctly finds its parent work which also has a slug.

Screenshot 2025-04-19 at 4 56 09 PM

Notes

This commit fixes two aspects of child works with slugs:
1. It ensures that a work can find its child works with slugs.
2. It ensures that a work with slugs can find its parent work.

Member relationshps use the object's id. However the solr document is
indexed with the slug as the id. We have to ensure that we search
the appropriate terms in the solr document when we are searching by id.
@laritakr laritakr marked this pull request as draft April 19, 2025 21:26
@laritakr laritakr marked this pull request as ready for review April 19, 2025 22:16
@ShanaLMoore ShanaLMoore requested a review from Copilot April 21, 2025 14:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR resolves issues related to child works with slugs by ensuring proper relationship lookups through both the UI and Bulkrax. It refactors the presenter factory to support multiple ID types and updates the Solr document decorator to use prepend for method overrides.

  • Updated member presenter logic to query by various ID fields (resource_id_ssi, fedora_id_ssi, id).
  • Refactored AdlSolrDocumentDecorator to use prepend and introduced a load_parent_docs method.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
app/presenters/hyrax/pcdm_member_presenter_factory_decorator.rb Updated member presenter lookup logic and fallback querying to support child works with slugs.
app/models/solr_document_decorator.rb Refactored decorator inclusion and added load_parent_docs to correctly handle slugs in parent-child relationships.
Comments suppressed due to low confidence (1)

app/presenters/hyrax/pcdm_member_presenter_factory_decorator.rb:15

  • [nitpick] Consider renaming the variable 'indx' to 'index' for improved clarity.
indx = results.index { |doc| id == doc['resource_id_ssi'] || id == doc['fedora_id_ssi'] || id == doc['id'] }

Comment thread app/models/solr_document_decorator.rb Outdated
Fix typo

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@laritakr laritakr merged commit d094a33 into main Apr 21, 2025
6 checks passed
@laritakr laritakr deleted the support-slugs-for-child-works branch April 21, 2025 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants