Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate CoreMetadata#physical_medium #format #1142

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-09-04 19:26:55 UTC using RuboCop version 1.28.2.
# on 2024-09-10 18:25:52 UTC using RuboCop version 1.28.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -24,7 +24,7 @@ Layout/LineLength:
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods, inherit_mode.
# IgnoredMethods: refine
Metrics/BlockLength:
Max: 58
Max: 61

# Offense count: 5
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Expand Down
2 changes: 1 addition & 1 deletion app/forms/hyrax/image_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ImageForm < ::Spot::Forms::WorkForm
:location,
:language,
:source,
:physical_medium,
:format,
:original_item_extent,
:repository_location,
:requested_by,
Expand Down
2 changes: 1 addition & 1 deletion app/forms/hyrax/publication_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PublicationForm < ::Spot::Forms::WorkForm
:subject,
:keyword,
:language,
:physical_medium,
:format,
:location,
:note,
:related_resource,
Expand Down
7 changes: 7 additions & 0 deletions app/models/concerns/spot/core_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ module CoreMetadata
index.as :stored_searchable
end

# Free text: The file format, physical medium, or dimensions of the resource.
# @replaces :physical_medium
property :format, predicate: ::RDF::Vocab::DC.format do |index|
index.as :stored_searchable, :facetable
end

# Both standard and local identifiers. Values should have an prefix declaring the source.
# @see {Spot::Identifier}
property :identifier, predicate: ::RDF::Vocab::DC.identifier do |index|
Expand Down Expand Up @@ -65,6 +71,7 @@ module CoreMetadata
end

# A physical material or carrier. Examples include paper, canvas, or DVD.
# @deprecated use :format instead
property :physical_medium, predicate: ::RDF::Vocab::DC.PhysicalMedium do |index|
index.as :stored_searchable, :facetable
end
Expand Down
1 change: 1 addition & 0 deletions app/models/concerns/spot/solr_document_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module SolrDocumentAttributes
attribute :creator, ::Blacklight::Types::Array, 'creator_tesim'
attribute :description, ::Blacklight::Types::Array, 'description_tesim'
attribute :identifier, ::Blacklight::Types::Array, 'identifier_ssim'
attribute :format, ::Blacklight::Types::Array, 'format_tesim'
attribute :keyword, ::Blacklight::Types::Array, 'keyword_tesim'
attribute :language, ::Blacklight::Types::Array, 'language_ssim'
attribute :language_label, ::Blacklight::Types::Array, 'language_label_ssim'
Expand Down
7 changes: 6 additions & 1 deletion app/presenters/spot/base_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BasePresenter < ::Hyrax::WorkShowPresenter
# delegate common properties to solr_document, so descendents only need
# to add their unique fields
delegate :contributor, :creator, :description, :identifier, :keyword, :language,
:language_label, :location, :note, :permalink, :physical_medium,
:language_label, :location, :note, :permalink,
:publisher, :registered?, :related_resource, :resource_type, :rights_holder, :rights_statement,
:source, :subject, :subtitle, :title_alternative, :title,
:visibility, :citation_journal_title, :citation_volume, :citation_issue,
Expand Down Expand Up @@ -50,6 +50,11 @@ def export_formats
%i[csv ttl nt jsonld]
end

# Combine :format with :physical_medium while migrating fields
def format
(solr_document.format + solr_document.physical_medium).uniq
end

# @return [Array<Spot::Identifier>]
def local_identifier
@local_identifier ||= solr_document.local_identifier.map { |id| Spot::Identifier.from_string(id) }
Expand Down
15 changes: 12 additions & 3 deletions app/services/spot/work_csv_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def csv
def content
::CSV.generate do |csv|
csv << terms.map do |term|
values = work.respond_to?(term) ? work.send(term) : ''
values = values.respond_to?(:to_a) ? values.to_a : [values]
value = work_has_property?(term) ? work.public_send(term) : ''
values = Array.wrap(value)
values = values.map(&:to_s)
values.join(multi_value_separator)
end
Expand All @@ -59,7 +59,7 @@ def default_terms
editor
source
resource_type
physical_medium
format
language
abstract
description
Expand All @@ -77,5 +77,14 @@ def default_terms
visibility
]
end

def work_has_property?(term)
case work
when ActiveFedora::Base
work.class.properties.include?(term)
else
work.respond_to?(term)
end
end
end
end
2 changes: 1 addition & 1 deletion app/views/hyrax/images/_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<%= presenter.attribute_to_html(:date_scope_note) %>

<%= presenter.attribute_to_html(:resource_type, render_as: :faceted) %>
<%= presenter.attribute_to_html(:physical_medium) %>
<%= presenter.attribute_to_html(:format) %>
<%= presenter.attribute_to_html(:original_item_extent) %>
<%= presenter.attribute_to_html(:language_label,
render_as: :faceted,
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/images/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ json.ocm_classification(@curation_concern.subject_ocm.sort)
json.extract!(@curation_concern, :date, :date_scope_note, :date_associated, :date_uploaded, :date_modified)

# more descriptions
json.extract!(@curation_concern, :physical_medium, :original_item_extent, :repository_location, :related_resource, :research_assistance)
json.extract!(@curation_concern, :format, :original_item_extent, :repository_location, :related_resource, :research_assistance)

# rights info
json.rights_statement(map_uris(@curation_concern.rights_statement))
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/publications/_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<%= presenter.attribute_to_html(:date_issued) %>
<%= presenter.attribute_to_html(:date_available) %>
<%= presenter.attribute_to_html(:resource_type, render_as: :faceted) %>
<%= presenter.attribute_to_html(:physical_medium) %>
<%= presenter.attribute_to_html(:format) %>
<%= presenter.attribute_to_html(:language_label,
render_as: :faceted,
search_field: :language_label_ssim) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/publications/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ json.extract!(@curation_concern, :bibliographic_citation)
json.subject(map_uris(@curation_concern.subject))
json.extract!(@curation_concern, :keyword)
json.location(map_uris(@curation_concern.location))
json.extract!(@curation_concern, :identifier, :source, :language, :physical_medium, :related_resource)
json.extract!(@curation_concern, :identifier, :source, :language, :format, :related_resource)

# dates
json.extract!(@curation_concern, :date_issued, :date_available, :date_uploaded, :date_modified)
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/bulkrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
'creator' => { from: ['creator'] },
'contributor' => { from: ['contributor'] },
'editor' => { from: ['editor'] },
'format' => { from: ['format', 'physical_medium'] },
'abstract' => { from: ['abstract'] },
'description' => { from: ['description'] },
'inscription' => { from: ['inscription'] },
Expand All @@ -53,7 +54,6 @@
'license' => { from: ['license'] },
'location' => { from: ['location'] },
'note' => { from: ['note'] },
'physical_medium' => { from: ['physical_medium'] },
'publisher' => { from: ['publisher'] },
'related_resource' => { from: ['related_resource'] },
'resource_type' => { from: ['resource_type'], parsed: false },
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/qa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# our Solr suggestion authorities
solr_suggestion_authorities = %w[
bibliographic_citation
format
keyword
name
organization
physical_medium
publisher
source
]
Expand Down
1 change: 1 addition & 0 deletions config/locales/blacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ en:
embargo_release_date: Embargo Release Date
file_format: File Format
file_size: File Size
format: Format
has_model: LDR Type
inscription: Inscription
keyword: Keyword
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ en:
division: A major unit or section within a larger organization.
donor: A statement of any changes in ownership and custody of the resource since its creation that are significant for its authenticity, integrity, and interpretation.
editor: A person having managerial and sometimes policy-making responsibility for the editorial part of a publishing firm or of a newspaper, magazine, or other publication.
format: The file format, physical medium, or dimensions of the resource.
inscription: Text of an inscription on the object.
keyword: Words or phrases you select to describe what the work is about. These are used to search for content.
language: The language of the work's content.
Expand Down
6 changes: 3 additions & 3 deletions docker/solr/config/solrconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@
<str name="field">organization_sim</str>
</lst>
<lst name="suggester">
<str name="name">physical_medium</str>
<str name="name">format</str>
<str name="lookupImpl">AnalyzingInfixLookupFactory</str>
<str name="highlight">false</str>
<str name="dictionaryImpl">HighFrequencyDictionaryFactory</str>
<str name="indexPath">suggestion_index_physical_medium</str>
<str name="indexPath">suggestion_index_format</str>
<str name="suggestAnalyzerFieldType">textSuggest</str>
<str name="buildOnCommit">false</str>
<str name="field">physical_medium_sim</str>
<str name="field">format_sim</str>
</lst>
<lst name="suggester">
<str name="name">publisher</str>
Expand Down
2 changes: 1 addition & 1 deletion spec/authorities/qa/authorities/solr_suggest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

[
['bibliographic_citation', 'bibliographic_citation_sim'],
['format', 'format_sim'],
['keyword', 'keyword_sim'],
['name', 'name_suggest_ssim'],
['organization', 'organization_sim'],
['physical_medium', 'physical_medium_sim'],
['publisher', 'publisher_sim'],
['source', 'source_sim']
].each do |dict, field|
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/work_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
contributor { ['Contributor, First-Name', 'Person, Another'] }
creator { ['Creator, Anne'] }
description { ['An account of the resource'] }
format { ['Photograph'] }
identifier { ['hdl:10385/abc123'] }
keyword { ['photo'] }
language { ['en'] }
location { ['http://sws.geonames.org/5188140/'] }
note { ['Some staff-side information'] }
physical_medium { ['Photograph'] }
publisher { ['Lafayette College'] }
related_resource { ['http://another-resource.com'] }
resource_type { ['Other'] }
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
fill_in 'image_source', with: attrs[:source].first
expect(page).to have_css('.image_source .controls-add-text')

fill_in 'image_physical_medium', with: attrs[:physical_medium].first
expect(page).to have_css('.image_physical_medium .controls-add-text')
fill_in 'image_format', with: attrs[:format].first
expect(page).to have_css('.image_format .controls-add-text')

fill_in 'image_original_item_extent', with: attrs[:original_item_extent].first
expect(page).to have_css('.image_original_item_extent .controls-add-text')
Expand Down
4 changes: 2 additions & 2 deletions spec/forms/hyrax/image_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
it { is_expected.to include :location }
it { is_expected.to include :language }
it { is_expected.to include :source }
it { is_expected.to include :physical_medium }
it { is_expected.to include :format }
it { is_expected.to include :original_item_extent }
it { is_expected.to include :repository_location }
it { is_expected.to include :requested_by }
Expand Down Expand Up @@ -57,7 +57,7 @@
it { is_expected.to include(location: []) }
it { is_expected.to include(language: []) }
it { is_expected.to include(source: []) }
it { is_expected.to include(physical_medium: []) }
it { is_expected.to include(format: []) }
it { is_expected.to include(original_item_extent: []) }
it { is_expected.to include(repository_location: []) }
it { is_expected.to include(requested_by: []) }
Expand Down
2 changes: 1 addition & 1 deletion spec/forms/hyrax/publication_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
it { is_expected.to include(note: []) }
it { is_expected.to include(:date_issued) }
it { is_expected.to include(resource_type: []) }
it { is_expected.to include(physical_medium: []) }
it { is_expected.to include(format: []) }
it { is_expected.to include(language: []) }
it { is_expected.to include(keyword: []) }
it { is_expected.to include(bibliographic_citation: []) }
Expand Down
1 change: 1 addition & 0 deletions spec/indexers/image_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
repository_location: %w[ssim],
source: %w[tesim sim],
resource_type: %w[tesim sim],
format: %w[tesim sim],
physical_medium: %w[tesim sim],
original_item_extent: %w[tesim],
description: %w[tesim],
Expand Down
1 change: 1 addition & 0 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
editor: { type: Array, suffix: 'tesim' },
file_set_ids: { type: Array, suffix: 'ssim', value: ['abc123', 'def456'] },
file_size: { type: String, suffix: 'lts' },
format: { type: Array, suffix: 'tesim' },
identifier: { type: Array, suffix: 'ssim' },
inscription: { type: Array, suffix: 'tesim' },
keyword: { type: Array, suffix: 'tesim' },
Expand Down
1 change: 1 addition & 0 deletions spec/support/shared_examples/spot_core_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[:contributor, RDF::Vocab::DC11.contributor],
[:creator, RDF::Vocab::DC11.creator],
[:description, RDF::Vocab::DC11.description],
[:format, RDF::Vocab::DC.format],
[:identifier, RDF::Vocab::DC.identifier],
[:keyword, RDF::Vocab::SCHEMA.keywords],
[:language, RDF::Vocab::DC11.language],
Expand Down
14 changes: 12 additions & 2 deletions spec/support/shared_examples/spot_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
let(:solr_doc) { instance_double(SolrDocument) }

[
:contributor, :creator, :description, :identifier, :keyword, :note, :permalink,
:physical_medium, :publisher, :related_resource, :resource_type, :rights_holder,
:contributor, :creator, :description, :identifier, :keyword, :note,
:permalink, :publisher, :related_resource, :resource_type, :rights_holder,
:rights_statement, :source, :subtitle, :title_alternative, :title, :visibility,
:source_identifier
].each do |method_name|
Expand All @@ -31,6 +31,16 @@
end
end

describe '#format' do
subject { presenter.format }

let(:solr_data) { { 'physical_medium_tesim' => ['Carte postale', 'Postcard'], 'format_tesim' => ['Postcard'] } }

describe 'combines :format and :physical_medium values' do
it { is_expected.to eq ['Postcard', 'Carte postale'] }
end
end

describe '#export_formats' do
subject { presenter.export_formats }

Expand Down
Loading