Skip to content

Commit

Permalink
Update headers for the downloadable CSV template
Browse files Browse the repository at this point in the history
* Remove system fields that should not be used
* Add a `files` header
  • Loading branch information
mark-dce committed Oct 16, 2019
1 parent dbdc19d commit 7adebb5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
19 changes: 11 additions & 8 deletions lib/zizia/hyrax/hyrax_basic_metadata_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HyraxBasicMetadataMapper < HashMapper
##
# @return [Enumerable<Symbol>] The fields the mapper can process.
def fields
core_fields + basic_fields + [:visibility]
core_fields + basic_fields + [:visibility, :files]
end

# Properties defined with `multiple: false` in
Expand Down Expand Up @@ -131,18 +131,21 @@ def matching_header(field_name)
end

# Properties defined in Hyrax::CoreMetadata
# Note that date_uploaded is NOT set here, even though it is defined in
# Hyrax::CoreMetadata. Hyrax expects to set date_uploaded itself, and
# sending a metadata value for that field interferes with Hyrax expected
# behavior.
# Note that depositor, date_uploaded and date_modified are NOT set here,
# even though they are defined in Hyrax::CoreMetadata.
# Hyrax expects to set these fields itself, and
# sending a metadata value for these fields interferes with
# Hyrax expected behavior.
def core_fields
[:depositor, :title, :date_modified]
[:title]
end

# Properties defined in Hyrax::BasicMetadata
# System related fields like :relative_path, and :import_url
# are not included here because we don't expect users to directly
# import them.
def basic_fields
[:label, :relative_path, :import_url,
:resource_type, :creator, :contributor,
[:resource_type, :creator, :contributor,
:description, :keyword, :license,
:rights_statement, :publisher, :date_created,
:subject, :language, :identifier,
Expand Down
1 change: 1 addition & 0 deletions spec/support/shared_contexts/with_work_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class Work < ActiveFedora::Base
attr_accessor :visibility
attr_accessor :based_near_attributes
attr_accessor :files
include ::Hyrax::CoreMetadata
include ::Hyrax::BasicMetadata
end
Expand Down
34 changes: 9 additions & 25 deletions spec/zizia/hyrax/hyrax_basic_metadata_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@

# Properties defined in Hyrax::CoreMetadata
let(:core_fields) do
[:depositor, :title, :date_modified]
[:title]
end

# Properties defined in Hyrax::BasicMetadata
let(:basic_fields) do
[:label, :relative_path, :import_url,
:resource_type, :creator, :contributor,
[:resource_type, :creator, :contributor,
:description, :keyword, :license,
:rights_statement, :publisher, :date_created,
:subject, :language, :identifier, :based_near,
:related_url, :bibliographic_citation, :source]
end

let(:tenejo_fields) do
[:visibility]
[:visibility, :files]
end

it_behaves_like 'a Zizia::Mapper' do
Expand All @@ -35,25 +34,20 @@
context 'with metadata, but some missing fields' do
before { mapper.metadata = metadata }
let(:metadata) do
{ 'depositor' => 'someone@example.org',
'title' => 'A Title',
{ 'title' => 'A Title',
'language' => 'English' }
end

it 'provides methods for the fields, even fields that aren\'t included in the metadata' do
expect(metadata).to include('title')
expect(mapper).to respond_to(:title)

expect(metadata).not_to include('label')
expect(mapper).to respond_to(:label)
expect(metadata).not_to include('source')
expect(mapper).to respond_to(:source)
end

it 'returns single values for single-value fields' do
expect(mapper.depositor).to eq 'someone@example.org'
expect(mapper.date_modified).to eq nil
expect(mapper.label).to eq nil
expect(mapper.relative_path).to eq nil
expect(mapper.import_url).to eq nil
expect(mapper.visibility).to eq 'restricted'
end

it 'returns array values for multi-value fields' do
Expand Down Expand Up @@ -91,12 +85,7 @@
{ 'Title' => 'A Title',
'Related URL' => 'http://example.com',
'Abstract or Summary' => 'desc1|~|desc2',
'visiBILITY' => 'open',
'Depositor' => 'someone@example.org',
'DATE_modified' => 'mod date',
'laBel' => 'label',
'relative_PATH' => 'rel path',
'import_URL' => 'imp url' }
'visiBILITY' => 'open' }
end

it 'matches the correct fields' do
Expand All @@ -105,11 +94,6 @@
expect(mapper.description).to eq ['desc1', 'desc2']
expect(mapper.creator).to eq []
expect(mapper.visibility).to eq 'open'
expect(mapper.depositor).to eq 'someone@example.org'
expect(mapper.date_modified).to eq 'mod date'
expect(mapper.label).to eq 'label'
expect(mapper.relative_path).to eq 'rel path'
expect(mapper.import_url).to eq 'imp url'
end
end

Expand Down Expand Up @@ -184,7 +168,7 @@
end

it 'doesn\'t raise an error for missing fields' do
expect(mapper.depositor).to eq nil
expect(mapper.source).to eq []
end
end
end
Expand Down

0 comments on commit 7adebb5

Please sign in to comment.