Skip to content

Commit

Permalink
Fix Based Near functionality (#855)
Browse files Browse the repository at this point in the history
# Story

Refs #851

# Expected Behavior Before Changes

Using based near crashes the app.

# Expected Behavior After Changes

Based Near attributes save, display, and edit appropriately

# Screenshots / Video

<details>
<summary></summary>

</details>

# Notes
  • Loading branch information
laritakr authored Oct 25, 2024
2 parents 8b9e86e + be7ca83 commit 3560ec0
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 89 deletions.
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@
# later load the dog biscuits translations.
HykuKnapsack::Engine.load_translations!

# @todo remove this and list index properties individually
index_props = DogBiscuits.config.index_properties.collect do |prop|
{ prop => CatalogController.send(:index_options, prop, DogBiscuits.config.property_mappings[prop]) }
end
CatalogController.send(:add_index_field, config, index_props)
config.add_index_field 'all_text_tsimv', label: "Item contents", highlight: true, helper_method: :render_ocr_snippets, if: :query_present?
config.add_index_field 'based_near_label_tesim', itemprop: 'contentLocation', link_to_facet: 'based_near_label_sim'

config.search_fields.delete('all_fields')
config.add_search_field('all_fields',
Expand Down
4 changes: 1 addition & 3 deletions app/forms/conference_item_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class ConferenceItemResourceForm < Hyrax::Forms::ResourceForm(ConferenceItemResource)
# Commented out basic_metadata because these terms were added to conference_item_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:adl_metadata)
include Hyrax::FormFields(:conference_item_resource)
include Hyrax::FormFields(:bulkrax_metadata)
Expand All @@ -16,7 +15,6 @@ class ConferenceItemResourceForm < Hyrax::Forms::ResourceForm(ConferenceItemReso
include Hyrax::FormFields(:slug_metadata)
include VideoEmbedBehavior::Validation
include(SlugBugValkyrie)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field
Expand Down
4 changes: 1 addition & 3 deletions app/forms/dataset_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class DatasetResourceForm < Hyrax::Forms::ResourceForm(DatasetResource)
# Commented out basic_metadata because these terms were added to data_set_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:adl_metadata)
include Hyrax::FormFields(:dataset_resource)
include Hyrax::FormFields(:bulkrax_metadata)
Expand All @@ -16,7 +15,6 @@ class DatasetResourceForm < Hyrax::Forms::ResourceForm(DatasetResource)
include Hyrax::FormFields(:slug_metadata)
include VideoEmbedBehavior::Validation
include(SlugBugValkyrie)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field
Expand Down
4 changes: 1 addition & 3 deletions app/forms/exam_paper_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class ExamPaperResourceForm < Hyrax::Forms::ResourceForm(ExamPaperResource)
# Commented out basic_metadata because these terms were added to exam_paper_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:adl_metadata)
include Hyrax::FormFields(:exam_paper_resource)
include Hyrax::FormFields(:bulkrax_metadata)
Expand All @@ -16,7 +15,6 @@ class ExamPaperResourceForm < Hyrax::Forms::ResourceForm(ExamPaperResource)
include Hyrax::FormFields(:slug_metadata)
include VideoEmbedBehavior::Validation
include(SlugBugValkyrie)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field
Expand Down
4 changes: 1 addition & 3 deletions app/forms/journal_article_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class JournalArticleResourceForm < Hyrax::Forms::ResourceForm(JournalArticleResource)
# Commented out basic_metadata because these terms were added to journal_article_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:adl_metadata)
include Hyrax::FormFields(:journal_article_resource)
include Hyrax::FormFields(:bulkrax_metadata)
Expand All @@ -16,7 +15,6 @@ class JournalArticleResourceForm < Hyrax::Forms::ResourceForm(JournalArticleReso
include Hyrax::FormFields(:slug_metadata)
include VideoEmbedBehavior::Validation
include(SlugBugValkyrie)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field
Expand Down
3 changes: 1 addition & 2 deletions app/forms/published_work_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class PublishedWorkResourceForm < Hyrax::Forms::ResourceForm(PublishedWorkResource)
# Commented out basic_metadata because these terms were added to published_work_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:adl_metadata)
include Hyrax::FormFields(:published_work_resource)
include Hyrax::FormFields(:bulkrax_metadata)
Expand All @@ -16,7 +16,6 @@ class PublishedWorkResourceForm < Hyrax::Forms::ResourceForm(PublishedWorkResour
include Hyrax::FormFields(:slug_metadata)
include VideoEmbedBehavior::Validation
include(SlugBugValkyrie)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field
Expand Down
4 changes: 1 addition & 3 deletions app/forms/thesis_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# @see https://github.com/samvera/hyrax/wiki/Hyrax-Valkyrie-Usage-Guide#forms
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
class ThesisResourceForm < Hyrax::Forms::ResourceForm(ThesisResource)
# Commented out basic_metadata because these terms were added to thesis_resource so we can customize it.
# include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:basic_metadata)
include Hyrax::FormFields(:adl_metadata)
include Hyrax::FormFields(:thesis_resource)
include Hyrax::FormFields(:bulkrax_metadata)
Expand All @@ -16,7 +15,6 @@ class ThesisResourceForm < Hyrax::Forms::ResourceForm(ThesisResource)
include Hyrax::FormFields(:slug_metadata)
include VideoEmbedBehavior::Validation
include(SlugBugValkyrie)

# Define custom form fields using the Valkyrie::ChangeSet interface
#
# property :my_custom_form_field
Expand Down
3 changes: 1 addition & 2 deletions app/models/conference_item_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Generated via
# `rails generate hyrax:work_resource ConferenceItemResource`
class ConferenceItemResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to conference_item_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:adl_metadata)
include Hyrax::Schema(:conference_item_resource)
include Hyrax::Schema(:bulkrax_metadata)
Expand Down
3 changes: 1 addition & 2 deletions app/models/dataset_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Generated via
# `rails generate hyrax:work_resource DatasetResource`
class DatasetResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to data_set_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:adl_metadata)
include Hyrax::Schema(:dataset_resource)
include Hyrax::Schema(:bulkrax_metadata)
Expand Down
3 changes: 1 addition & 2 deletions app/models/exam_paper_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Generated via
# `rails generate hyrax:work_resource ExamPaperResource`
class ExamPaperResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to exam_paper_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:adl_metadata)
include Hyrax::Schema(:exam_paper_resource)
include Hyrax::Schema(:bulkrax_metadata)
Expand Down
3 changes: 1 addition & 2 deletions app/models/journal_article_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Generated via
# `rails generate hyrax:work_resource JournalArticleResource`
class JournalArticleResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to journal_article_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:adl_metadata)
include Hyrax::Schema(:journal_article_resource)
include Hyrax::Schema(:bulkrax_metadata)
Expand Down
3 changes: 1 addition & 2 deletions app/models/published_work_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Generated via
# `rails generate hyrax:work_resource PublishedWorkResource`
class PublishedWorkResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to published_work_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:adl_metadata)
include Hyrax::Schema(:published_work_resource)
include Hyrax::Schema(:bulkrax_metadata)
Expand Down
3 changes: 1 addition & 2 deletions app/models/thesis_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Generated via
# `rails generate hyrax:work_resource ThesisResource`
class ThesisResource < Hyrax::Work
# Commented out basic_metadata because these terms were added to thesis_resource so we can customize it.
# include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:adl_metadata)
include Hyrax::Schema(:thesis_resource)
include Hyrax::Schema(:bulkrax_metadata)
Expand Down
3 changes: 1 addition & 2 deletions app/views/hyrax/base/_attribute_rows.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= presenter.attribute_to_html(:identifier, render_as: :linked, search_field: 'identifier_tesim') %>
<% end %>
<%= presenter.attribute_to_html(:keyword, render_as: :faceted) %>
<%= presenter.attribute_to_html(:based_near_label, render_as: :faceted) %>
<%= presenter.attribute_to_html(:based_near_label) %>
<%= presenter.attribute_to_html(:related_url, render_as: :external_link) %>
<% if can? :read, :admin_dashboard %>
<%= presenter.attribute_to_html(:resource_type, render_as: :faceted) %>
Expand Down Expand Up @@ -37,7 +37,6 @@
<%= presenter.attribute_to_html(:refereed, render_as: :faceted, label: I18n.t('dog_biscuits.fields.refereed')) %>
<%= presenter.attribute_to_html(:pagination, label: I18n.t('dog_biscuits.fields.pagination')) %>
<%= presenter.attribute_to_html(:doi, label: I18n.t('dog_biscuits.fields.doi')) %>
<%= presenter.attribute_to_html(:based_near, label: I18n.t('dog_biscuits.fields.based_near')) %>
<%= presenter.attribute_to_html(:resource_type_general, label: I18n.t('dog_biscuits.fields.resource_type_general')) %>
<%= presenter.attribute_to_html(:funder, label: I18n.t('dog_biscuits.fields.funder'), render_as: :faceted) %>
<%= presenter.attribute_to_html(:output_of, label: I18n.t('dog_biscuits.fields.output_of')) %>
Expand Down
11 changes: 1 addition & 10 deletions config/initializers/wings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,14 @@

Rails.application.config.after_initialize do
# Add all concerns that are migrating from ActiveFedora here
CONCERNS = [ConferenceItem, Dataset, ExamPaper, GenericWork, Image, JournalArticle, PublishedWork, Thesis].freeze
CONCERNS = [ConferenceItem, Dataset, Etd, ExamPaper, GenericWork, Image, JournalArticle, PublishedWork, Thesis].freeze

CONCERNS.each do |klass|
Wings::ModelRegistry.register("#{klass}Resource".constantize, klass)
# we register itself so we can pre-translate the class in Freyja instead of having to translate in each query_service
Wings::ModelRegistry.register(klass, klass)
end

Wings::ModelRegistry.register(ConferenceItemResource, ConferenceItem)
Wings::ModelRegistry.register(DatasetResource, Dataset)
Wings::ModelRegistry.register(ExamPaperResource, ExamPaper)
Wings::ModelRegistry.register(GenericWorkResource, GenericWork)
Wings::ModelRegistry.register(ImageResource, Image)
Wings::ModelRegistry.register(JournalArticleResource, JournalArticle)
Wings::ModelRegistry.register(PublishedWorkResource, PublishedWork)
Wings::ModelRegistry.register(ThesisResource, Thesis)

Valkyrie.config.resource_class_resolver = lambda do |resource_klass_name|
# TODO: Can we use some kind of lookup.
klass_name = resource_klass_name.gsub(/Resource$/, '')
Expand Down
9 changes: 0 additions & 9 deletions config/metadata/adl_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,6 @@ attributes:
# - "alternative_title_sim"
# - "alternative_title_tesim"
predicate: http://purl.org/dc/terms/alternative
based_near:
type: string
multiple: true
form:
primary: false
index_keys:
- "based_near_sim"
- "based_near_tesim"
predicate: http://xmlns.com/foaf/0.1/based_near
bibliographic_citation:
type: string
multiple: true
Expand Down
11 changes: 10 additions & 1 deletion config/metadata/basic_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,13 @@
# Each model will have its own model resource metadata.yaml
# that includes basic metadata for more customizations

attributes: {}
attributes:
based_near:
type: string
multiple: true
form:
primary: false
index_keys:
- "based_near_sim"
- "based_near_tesim"
predicate: http://xmlns.com/foaf/0.1/based_near
9 changes: 0 additions & 9 deletions config/metadata/collection_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,6 @@ attributes:
- "alternative_title_sim"
- "alternative_title_tesim"
predicate: http://purl.org/dc/terms/alternative
based_near:
type: string
multiple: true
form:
primary: false
index_keys:
- "based_near_sim"
- "based_near_tesim"
predicate: http://xmlns.com/foaf/0.1/based_near
bibliographic_citation:
type: string
multiple: true
Expand Down
11 changes: 1 addition & 10 deletions config/metadata/file_set_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,6 @@ attributes:
# primary: false
# missing: access_right
# missing: alternative_title
based_near:
type: string
multiple: true
form:
primary: false
index_keys:
- "based_near_sim"
- "based_near_tesim"
predicate: http://xmlns.com/foaf/0.1/based_near
# missing: bibliograpic_citation
contributor:
type: string
Expand Down Expand Up @@ -157,4 +148,4 @@ attributes:
primary: false
predicate: https://b2.adventistdigitallibrary.org/terms/overrideDefaultThumbnail
index_keys:
- "override_default_thumbnail_ssi"
- "override_default_thumbnail_ssi"
9 changes: 0 additions & 9 deletions config/metadata/generic_work_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,6 @@ attributes:
# - "alternative_title_sim"
# - "alternative_title_tesim"
predicate: http://purl.org/dc/terms/alternative
based_near:
type: string
multiple: true
form:
primary: false
index_keys:
- "based_near_sim"
- "based_near_tesim"
predicate: http://xmlns.com/foaf/0.1/based_near
bibliographic_citation:
type: string
multiple: true
Expand Down
9 changes: 0 additions & 9 deletions config/metadata/image_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ attributes:
# - "alternative_title_sim"
# - "alternative_title_tesim"
predicate: http://purl.org/dc/terms/alternative
based_near:
type: string
multiple: true
form:
primary: false
index_keys:
- "based_near_sim"
- "based_near_tesim"
predicate: http://xmlns.com/foaf/0.1/based_near
bibliographic_citation:
type: string
multiple: true
Expand Down

0 comments on commit 3560ec0

Please sign in to comment.