Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Use Hyrax description property and add abstract property
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotjordan committed Mar 24, 2017
1 parent b9d69c9 commit bd5861e
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion app/adapters/remote_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def bibdata?(source_metadata_identifier)
def attributes
result = super
result[:date] = Array(result.delete(:date_created))
result[:description] = Array(result[:description]).first
result[:abstract] = Array(result[:abstract]).first
result.delete :heldBy # TODO: map codes to locations (see plum#1001)
result[:member_of_collections] = find_or_create(result.delete(:memberOf))
result
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def self.modified_field
end

config.add_search_field('description') do |field|
field.label = 'Abstract or Summary'
field.label = 'Description'
solr_name = solr_name('description', :stored_searchable, type: :string)
field.solr_local_parameters = {
qf: solr_name,
Expand Down
1 change: 0 additions & 1 deletion app/forms/collection_edit_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class CollectionEditForm < Hyrax::Forms::CollectionForm

def self.model_attributes(attrs)
attrs[:title] = Array(attrs[:title]) if attrs[:title]
attrs[:description] = Array(attrs[:description]) if attrs[:description]
super(attrs)
end

Expand Down
4 changes: 2 additions & 2 deletions app/forms/hyrax/geo_work_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class GeoWorkForm < Hyrax::HyraxForm
self.required_fields = [:title, :rights_statement, :coverage]

def primary_terms
terms = super + [:should_populate_metadata]
terms = super + [:description, :should_populate_metadata]
terms - [:holding_location, :pdf_type, :nav_date, :portion_note, :related_url]
end

Expand All @@ -28,7 +28,7 @@ def secondary_terms
end

def multiple?(field)
return false if ['description', 'rights_statement'].include?(field.to_s)
return false if ['rights_statement'].include?(field.to_s)
super
end
end
Expand Down
12 changes: 3 additions & 9 deletions app/forms/hyrax/hyrax_form.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Hyrax
class HyraxForm < Hyrax::Forms::WorkForm
self.terms += [:holding_location, :rights_statement, :rights_note, :source_metadata_identifier, :portion_note, :description, :state, :collection_ids, :ocr_language, :nav_date, :pdf_type, :start_canvas, :uploaded_files]
self.terms += [:holding_location, :rights_statement, :rights_note, :source_metadata_identifier, :portion_note, :description, :abstract, :state, :collection_ids, :ocr_language, :nav_date, :pdf_type, :start_canvas, :uploaded_files]
self.required_fields = [:title, :source_metadata_identifier, :rights_statement]
delegate :collection_ids, to: :model

Expand All @@ -9,9 +9,7 @@ def notable_rights_statement?
end

def self.multiple?(field)
if field.to_sym == :description
false
elsif field.to_sym == :pdf_type
if field.to_sym == :pdf_type
false
elsif field.to_sym == :rights_statement
false
Expand All @@ -36,10 +34,6 @@ def initialize_field(key)
super
end

def description
Array.wrap(super).first
end

def pdf_type
if self["pdf_type"].blank?
"gray"
Expand All @@ -57,7 +51,7 @@ def rights_statement
end

def primary_terms
super + [:rights_note, :holding_location, :pdf_type, :portion_note, :description, :nav_date]
super + [:rights_note, :holding_location, :pdf_type, :portion_note, :nav_date]
end

def secondary_terms
Expand Down
2 changes: 1 addition & 1 deletion app/forms/hyrax/multi_volume_work_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MultiVolumeWorkForm < ::Hyrax::HyraxForm
self.terms += [:viewing_direction, :viewing_hint]

def multiple?(field)
return false if ['description', 'rights_statement'].include?(field.to_s)
return false if ['abstract', 'rights_statement'].include?(field.to_s)
super
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/forms/hyrax/scanned_resource_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ScannedResourceForm < ::Hyrax::HyraxForm
self.terms += [:viewing_direction, :viewing_hint]

def multiple?(field)
return false if ['description', 'rights_statement'].include?(field.to_s)
return false if ['abstract', 'rights_statement'].include?(field.to_s)
super
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/schemas/plum_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class PlumSchema < ActiveTriples::Schema
property :sort_title, predicate: ::OpaqueMods.titleForSort, multiple: false
property :portion_note, predicate: ::RDF::Vocab::SKOS.scopeNote, multiple: false
property :description, predicate: ::RDF::Vocab::DC.abstract, multiple: false
property :abstract, predicate: ::RDF::Vocab::DC.abstract, multiple: false
property :identifier, predicate: ::RDF::Vocab::DC.identifier, multiple: false
property :replaces, predicate: ::RDF::Vocab::DC.replaces, multiple: false
property :rights_statement, predicate: ::RDF::Vocab::EDM.rights, multiple: false
Expand Down
2 changes: 1 addition & 1 deletion app/values/scanned_resource_pdf/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def metadata_hash
hsh[entry["label"].to_sym] = Array(entry["value"]).join(", ")
end
result[:Title] = Array(scanned_resource.title).join(", ") if scanned_resource.title
result[:Description] = Array(scanned_resource.description).join(", ") if scanned_resource.description
result[:Description] = scanned_resource.description.join(", ") if scanned_resource.description
result
end

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/hyrax/scanned_resources_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
end

describe 'update' do
let(:scanned_resource_attributes) { { portion_note: 'Section 2', description: 'a description', source_metadata_identifier: '2028405' } }
let(:scanned_resource_attributes) { { portion_note: 'Section 2', description: ['a description'], source_metadata_identifier: '2028405' } }
before do
sign_in user
end
Expand All @@ -170,7 +170,7 @@
post :update, params: { id: scanned_resource, scanned_resource: scanned_resource_attributes }
expect(reloaded.portion_note).to eq 'Section 2'
expect(reloaded.title).to eq ['Dummy Title']
expect(reloaded.description).to eq 'a description'
expect(reloaded.description).to eq ['a description']
end
it "can update the start_canvas" do
post :update, params: { id: scanned_resource, scanned_resource: { start_canvas: "1" } }
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/multi_volume_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title ["Test title"]
source_metadata_identifier "1234567"
rights_statement "http://rightsstatements.org/vocab/NKC/1.0/"
description "900 years of time and space, and I’ve never been slapped by someone’s mother."
description ["900 years of time and space, and I’ve never been slapped by someone’s mother."]
visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
state Vocab::FedoraResourceStatus.active

Expand Down
2 changes: 1 addition & 1 deletion spec/factories/scanned_resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
title ["Test title"]
source_metadata_identifier "1234567"
rights_statement "http://rightsstatements.org/vocab/NKC/1.0/"
description "900 years of time and space, and I’ve never been slapped by someone’s mother."
description ["900 years of time and space, and I’ve never been slapped by someone’s mother."]
visibility Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
state Vocab::FedoraResourceStatus.active
pdf_type ["gray"]
Expand Down
1 change: 0 additions & 1 deletion spec/features/edit_multi_volume_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
visit edit_polymorphic_path [multi_volume_work]
fill_in 'multi_volume_work_source_metadata_identifier', with: '1234568'
fill_in 'multi_volume_work_portion_note', with: 'new portion note'
fill_in 'multi_volume_work_description', with: 'new description'

click_button 'Save'
expect(page).to have_text("Test title")
Expand Down
1 change: 0 additions & 1 deletion spec/features/edit_scanned_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
visit edit_polymorphic_path [scanned_resource]
fill_in 'scanned_resource_source_metadata_identifier', with: '1234568'
fill_in 'scanned_resource_portion_note', with: 'new portion note'
fill_in 'scanned_resource_description', with: 'new description'
fill_in 'scanned_resource_nav_date', with: '2016-04-01T01:01:01Z'
select 'Color PDF', from: 'scanned_resource_pdf_type'

Expand Down
2 changes: 1 addition & 1 deletion spec/forms/hyrax/multi_volume_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
let(:work) { MultiVolumeWork.new }

it "doesn't initialize description" do
expect(subject.description).to eq nil
expect(subject.description).to eq []
end
end
19 changes: 12 additions & 7 deletions spec/models/multi_volume_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
subject { multi_volume_work }

describe 'has note fields' do
[:portion_note, :description].each do |note_type|
it "should let me set a #{note_type}" do
note = 'This is note text'
subject.send("#{note_type}=", note)
expect { subject.save }.to_not raise_error
expect(reloaded.send(note_type)).to eq note
end
it "lets me set a portion_note" do
note = 'This is note text'
subject.portion_note = note
expect { subject.save }.to_not raise_error
expect(reloaded.portion_note).to eq note
end

it "lets me set a description" do
note = 'This is note text'
subject.description = [note]
expect { subject.save }.to_not raise_error
expect(reloaded.description).to eq [note]
end
end

Expand Down
19 changes: 12 additions & 7 deletions spec/models/scanned_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
subject { scanned_resource }

describe 'has note fields' do
[:portion_note, :description].each do |note_type|
it "should let me set a #{note_type}" do
note = 'This is note text'
subject.send("#{note_type}=", note)
expect { subject.save }.to_not raise_error
expect(reloaded.send(note_type)).to eq note
end
it "lets me set a portion_note" do
note = 'This is note text'
subject.portion_note = note
expect { subject.save }.to_not raise_error
expect(reloaded.portion_note).to eq note
end

it "lets me set a description" do
note = 'This is note text'
subject.description = [note]
expect { subject.save }.to_not raise_error
expect(reloaded.description).to eq [note]
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/services/polymorphic_manifest_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def build_file_set(id)
expect(result['@id']).to eq "http://plum.com/concern/scanned_resources/1/manifest"
end
it "has a description" do
expect(result.description).to eq [record.description]
expect(result.description).to eq [record.description.first]
end
context "when it has a bibdata ID" do
it "links to seeAlso" do
Expand Down
2 changes: 1 addition & 1 deletion spec/values/scanned_resource_pdf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
r.ordered_members << file_set2
r.logical_order.order = order
r.title = ["Leonardo's Book é 祝 ي"]
r.description = "All about Leonardo."
r.description = ["All about Leonardo."]
r.author = ["Leonardo"]
solr.add r.to_solr
solr.add r.list_source.to_solr
Expand Down

0 comments on commit bd5861e

Please sign in to comment.