Skip to content

Commit

Permalink
Merge pull request #654 from UCLALibrary/import_visibility
Browse files Browse the repository at this point in the history
Add visibility field to importer. Story 679
  • Loading branch information
little9 authored Jun 20, 2019
2 parents a2355cc + db634ca commit 17b2428
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 10 deletions.
15 changes: 15 additions & 0 deletions app/assets/markdown/importer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* [Subject](#subject)
* [Type.genre](#type.genre)
* [Type.typeOfResource](#type.typeofresource)
* [Visibility](#visibility)

## Required Fields

Expand Down Expand Up @@ -139,3 +140,17 @@ accepts AltTitle.translated
### Subject
### Type.genre
### Type.typeOfResource

### Visibility

A single-value field that must contain one of the allowed values.

This field is not required. If you omit this column or leave the value blank, it will default to `private` visibility (to avoid accidentally exposing records that should be restricted).

Examples:

* `public` - All users can view the record
* `authenticated` - Logged in users can view the record
* `discovery` - All users can view the metadata, but not the files
* `private` - Only admin users or users who have been granted special permission may view the record

22 changes: 20 additions & 2 deletions app/importers/californica_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize(attributes = {})
# What columns are allowed in the CSV
def self.allowed_headers
CALIFORNICA_TERMS_MAP.values +
['File Name', 'Parent ARK', 'Project Name', 'Object Type', 'Item Sequence']
['File Name', 'Parent ARK', 'Project Name', 'Object Type', 'Item Sequence', 'Visibility']
end

# What columns must exist in the CSV
Expand Down Expand Up @@ -101,7 +101,25 @@ def remote_files
end

def visibility
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
value_from_csv = metadata['Visibility']&.squish&.downcase
visibility_mapping.fetch(value_from_csv, Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE)
end

# The visibility values have different values when
# they are calculated or indexed in solr than the
# values that appear in the UI edit form. We should
# accept both.
def visibility_mapping
{
'private' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE,
'restricted' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE,
'discovery' => ::Work::VISIBILITY_TEXT_VALUE_DISCOVERY,
'authenticated' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED,
'registered' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED,
'ucla' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED,
'open' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC,
'public' => Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
}.freeze
end

def ark
Expand Down
3 changes: 2 additions & 1 deletion app/uploaders/csv_manifest_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
'Rights.servicesContact',
'Subject',
'Type.genre',
'Type.typeOfResource'
'Type.typeOfResource',
'Visibility'
].freeze

CONTROLLED_VOCABULARIES = {
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/coordinates_example.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Project Name,Parent ARK,Item ARK,Subject,Type.typeOfResource,Rights.copyrightStatus,Type.genre,Name.subject,Coverage.geographic,Relation.isPartOf,Publisher.publisherName,Rights.countryCreation,Rights.rightsHolderContact,Name.architect,Name.photographer,Name.repository,Date.normalized,AltIdentifier.local,Title,Date.creation,Format.extent,Format.medium,Format.dimensions,Description.note,Description.fundingNote,Description.longitude,Description.latitude,Description.caption,File Name,AltTitle.other,AltTitle.translated,Place of origin,AltTitle.uniform
Los Angeles Daily News Negatives,111/222,13030/hb338nb26f,"Altars|~|Mass|~|Communion table|~|Mexican American Catholics|~|Festivals|~|Guadalupe, Our Lady of|~|Historic buildings $z California $z Los Angeles|~|Churches $z California $z Los Angeles|~|Religion|~|Catholic churches $z California $z Los Angeles ",still image,copyrighted,news photographs,"Plaza Church (Los Angeles, Calif.)",Los Angeles (Calif.)|~|Los Angeles (Calif.),"Los Angeles Daily News Negatives. Department of Special Collections, Charles E. Young Research Library, University of California at Los Angeles.",Los Angeles Daily News,US,"UCLA Charles E. Young Research Library Department of Special Collections, A1713 Young Research Library, Box 951575, Los Angeles, CA 90095-1575. E-mail: [email protected]. Phone: (310)825-4988",Imhotep,Famous Photographer,,1942/1952,uclamss_1387_b112_40911-1,"Communion at Plaza Church, Los Angeles, 1942-1952",[between 1942-1947],Fake Extent,Fake Medium,200x200,"A woman takes Communion during a Plaza Church mass for the fiesta of Nuestra Senora de Guadalupe.|~|Our Lady Queen of Los Angeles Catholic Church, (aka La Iglesia de Nuestra Señora la Reina de Los Ángeles, and The Church of Our Lady the Queen of the Angels), was built in 1822 and is the oldest church in Los Angeles.",Fake Funding Note,-118.239577,34.05707,Fake Caption,clusc_1_1_00010432a.tif,"Communion table","Mesa de Comunión",Los Angeles,Mexican American Catholics
Project Name,Parent ARK,Item ARK,Visibility,Subject,Type.typeOfResource,Rights.copyrightStatus,Type.genre,Name.subject,Coverage.geographic,Relation.isPartOf,Publisher.publisherName,Rights.countryCreation,Rights.rightsHolderContact,Name.architect,Name.photographer,Name.repository,Date.normalized,AltIdentifier.local,Title,Date.creation,Format.extent,Format.medium,Format.dimensions,Description.note,Description.fundingNote,Description.longitude,Description.latitude,Description.caption,File Name,AltTitle.other,AltTitle.translated,Place of origin,AltTitle.uniform
Los Angeles Daily News Negatives,111/222,13030/hb338nb26f,public,"Altars|~|Mass|~|Communion table|~|Mexican American Catholics|~|Festivals|~|Guadalupe, Our Lady of|~|Historic buildings $z California $z Los Angeles|~|Churches $z California $z Los Angeles|~|Religion|~|Catholic churches $z California $z Los Angeles ",still image,copyrighted,news photographs,"Plaza Church (Los Angeles, Calif.)",Los Angeles (Calif.)|~|Los Angeles (Calif.),"Los Angeles Daily News Negatives. Department of Special Collections, Charles E. Young Research Library, University of California at Los Angeles.",Los Angeles Daily News,US,"UCLA Charles E. Young Research Library Department of Special Collections, A1713 Young Research Library, Box 951575, Los Angeles, CA 90095-1575. E-mail: [email protected]. Phone: (310)825-4988",Imhotep,Famous Photographer,,1942/1952,uclamss_1387_b112_40911-1,"Communion at Plaza Church, Los Angeles, 1942-1952",[between 1942-1947],Fake Extent,Fake Medium,200x200,"A woman takes Communion during a Plaza Church mass for the fiesta of Nuestra Senora de Guadalupe.|~|Our Lady Queen of Los Angeles Catholic Church, (aka La Iglesia de Nuestra Señora la Reina de Los Ángeles, and The Church of Our Lady the Queen of the Angels), was built in 1822 and is the oldest church in Los Angeles.",Fake Funding Note,-118.239577,34.05707,Fake Caption,clusc_1_1_00010432a.tif,Communion table,Mesa de Comunión,Los Angeles,Mexican American Catholics
67 changes: 62 additions & 5 deletions spec/importers/californica_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
.to contain_exactly(url: match(/clusc_1_1_00010432a\.tif/))
end

it "maps visibility to open" do
expect(mapper.visibility)
.to eq Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
end

context 'with a blank filename' do
let(:metadata) do
{ "Item ARK" => "21198/zz0002nq4w",
Expand Down Expand Up @@ -323,4 +318,66 @@
end
end
end

describe '#visibility' do
subject { mapper.visibility }

let(:private_vis) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
let(:disc_vis) { ::Work::VISIBILITY_TEXT_VALUE_DISCOVERY }
let(:auth_vis) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED }
let(:public_vis) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC }

context 'when visibility field is blank' do
let(:metadata) { {} }

it 'defaults to private visibility' do
expect(mapper.visibility).to eq private_vis
end
end

context 'visibility: private' do
let(:metadata) { { 'Visibility' => 'private' } }
it { is_expected.to eq private_vis }
end

context 'visibility: restricted' do
let(:metadata) { { 'Visibility' => 'restricted' } }
it { is_expected.to eq private_vis }
end

context 'visibility: discovery' do
let(:metadata) { { 'Visibility' => 'discovery' } }
it { is_expected.to eq disc_vis }
end

context 'visibility: authenticated' do
let(:metadata) { { 'Visibility' => 'authenticated' } }
it { is_expected.to eq auth_vis }
end

context 'visibility: registered' do
let(:metadata) { { 'Visibility' => 'registered' } }
it { is_expected.to eq auth_vis }
end

context 'visibility: UCLA' do
let(:metadata) { { 'Visibility' => 'UCLA' } }
it { is_expected.to eq auth_vis }
end

context 'visibility: public' do
let(:metadata) { { 'Visibility' => 'public' } }
it { is_expected.to eq public_vis }
end

context 'visibility: open' do
let(:metadata) { { 'Visibility' => 'open' } }
it { is_expected.to eq public_vis }
end

context 'with different capitalization and whitespace' do
let(:metadata) { { 'Visibility' => ' Public ' } }
it { is_expected.to eq public_vis }
end
end
end

0 comments on commit 17b2428

Please sign in to comment.