Child works should be able to have slugs#945
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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'] }
ShanaLMoore
approved these changes
Apr 21, 2025
Fix typo Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
prependto have the instance method override Hyrax's SolrDocument. Previously methods were added viainclude, 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.
Notes