Skip to content

Commit

Permalink
Resolves #682 mongraph.subject should be multi-value
Browse files Browse the repository at this point in the history
The importer splits monograph.subject on the semi-colon into an array
  • Loading branch information
sethaj committed Jan 19, 2017
1 parent dadc0b7 commit 0ca5d89
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Expand Up @@ -47,6 +47,3 @@

# Ignore all files ending in "swp", vim swap files
**/*.swp

# Ingnore import directory
import/
2 changes: 1 addition & 1 deletion lib/import.rb
Expand Up @@ -23,7 +23,7 @@ module Import
MONOGRAPH_FIELDS =
[
{ field_name: 'Publisher', metadata_name: 'publisher', multivalued: :yes },
{ field_name: 'Subject', metadata_name: 'subject', multivalued: :yes },
{ field_name: 'Subject', metadata_name: 'subject', multivalued: :yes_split },
{ field_name: 'ISBN (hardcover)', metadata_name: 'isbn', multivalued: :yes },
{ field_name: 'ISBN (paper)', metadata_name: 'isbn_paper', multivalued: :yes },
{ field_name: 'ISBN (ebook)', metadata_name: 'isbn_ebook', multivalued: :yes },
Expand Down
30 changes: 15 additions & 15 deletions spec/fixtures/csv/import_sections/tempest_sections.csv
@@ -1,18 +1,18 @@
File Name,Title,Resource Type,Content Type,Language,Externally Hosted Resource,Book and Platform (BP) or Platform-only (P),Rights Granted - Creative Commons,Primary Creator Last Name,Primary Creator First Name,Additional Creator(s),Keywords,Section
File Name,Title,Resource Type,Content Type,Language,Externally Hosted Resource,Book and Platform (BP) or Platform-only (P),Rights Granted - Creative Commons,Primary Creator Last Name,Primary Creator First Name,Additional Creator(s),Keywords,Section,Subject
,"Title of the object
A name given to the resource. Examples: title of a painting, photo, video.",,,,,,,"An entity primarily responsible for making the resource. Examples: Author/authors; artists; photographers; institutional authors or producers, such as university or federal agency.
",,,,
://:MONOGRAPH://:,The Tempest; A Subtitle,,,,,,, Shakespeare,William,Christopher Marlowe; Sir Francis Bacon,,://:MONOGRAPH://:
shipwreck.jpg,Monograph Shipwreck,image,portrait,English,No,BP,"Creative Commons Attribution-ShareAlike license, 3.0 Unported",Smith,Benjamin ,,,
miranda.jpg,Monograph Miranda, image,audience materials,English; German,no,P,Creative Commons Zero license (implies pd),Waterhouse,John William,,,
ファイル.txt,日本語のファイル ,text,portrait; illustration,Japanese,no,P,Creative Commons Zero license (implies pd),,,,,
shipwreck1.jpg,Section 1 Shipwreck,image,audience materials,Russian,No,P,Creative Commons Zero license (implies pd),Smith,,,keyword1; keyword2;,Act 1: Calm Waters
miranda1.jpg,Section 1 Miranda,image,portrait,Russian; German; French,no,P,Creative Commons Zero license (implies pd),Waterhouse,John William,,regular; _italicized_,Act 1: Calm Waters
shipwreck2.jpg,Section 2 Shipwreck,image,audience materials,French,No,P,Creative Commons Zero license (implies pd),Smith,,,,Act 2: Stirrin' Up
miranda2.jpg,Section 2 Miranda,image,illustration,English,no,P,Creative Commons Zero license (implies pd),Waterhouse,John William,,,Act 2: Stirrin' Up
shipwreck1.jpg,Previous Shipwreck File (Again),image,portrait; photograph,Latin,No,P,Creative Commons Zero license (implies pd),Smith,,,,Act 2: Stirrin' Up
,,,,,,,,,,,,
,,,,,,,,,,,,
,,,,,,,,,,,,
,,,,,,,,,,,,
,c,,,,,,,,,,,
://:MONOGRAPH://:,The Tempest; A Subtitle,,,,,,, Shakespeare,William,Christopher Marlowe; Sir Francis Bacon,,://:MONOGRAPH://:,Dog;Cat;Mouse
shipwreck.jpg,Monograph Shipwreck,image,portrait,English,No,BP,"Creative Commons Attribution-ShareAlike license, 3.0 Unported",Smith,Benjamin ,,,,
miranda.jpg,Monograph Miranda, image,audience materials,English; German,no,P,Creative Commons Zero license (implies pd),Waterhouse,John William,,,,
ファイル.txt,日本語のファイル ,text,portrait; illustration,Japanese,no,P,Creative Commons Zero license (implies pd),,,,,,
shipwreck1.jpg,Section 1 Shipwreck,image,audience materials,Russian,No,P,Creative Commons Zero license (implies pd),Smith,,,keyword1; keyword2;,Act 1: Calm Waters,
miranda1.jpg,Section 1 Miranda,image,portrait,Russian; German; French,no,P,Creative Commons Zero license (implies pd),Waterhouse,John William,,regular; _italicized_,Act 1: Calm Waters,
shipwreck2.jpg,Section 2 Shipwreck,image,audience materials,French,No,P,Creative Commons Zero license (implies pd),Smith,,,,Act 2: Stirrin' Up,
miranda2.jpg,Section 2 Miranda,image,illustration,English,no,P,Creative Commons Zero license (implies pd),Waterhouse,John William,,,Act 2: Stirrin' Up,
shipwreck1.jpg,Previous Shipwreck File (Again),image,portrait; photograph,Latin,No,P,Creative Commons Zero license (implies pd),Smith,,,,Act 2: Stirrin' Up,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
,c,,,,,,,,,,,,
1 change: 1 addition & 0 deletions spec/lib/import/csv_parser_spec.rb
Expand Up @@ -25,6 +25,7 @@
expect(subject['monograph']['creator_family_name']).to eq 'Shakespeare'
expect(subject['monograph']['creator_given_name']).to eq 'William'
expect(subject['monograph']['contributor']).to eq ['Christopher Marlowe', 'Sir Francis Bacon']
expect(subject['monograph']['subject']).to eq ['Dog', 'Cat', 'Mouse']
expect(subject['monograph']['files']).to eq ['shipwreck.jpg', 'miranda.jpg', 'ファイル.txt']
expect(subject['monograph']['files_metadata']).to eq [
{ 'title' => ['Monograph Shipwreck'],
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/import/monograph_builder_spec.rb
Expand Up @@ -9,7 +9,7 @@
'press' => 'umich',
'visibility' => public_vis,
'publisher' => ['Blah Press'],
'subject' => ['Stuff'],
'subject' => ['Stuff', 'Things'],
'description' => ['The Right Stuff'],
'isbn' => ['555-7-5432-1234-9'],
'isbn_paper' => ['555-7-5432-1235-0'],
Expand Down Expand Up @@ -52,6 +52,7 @@
expect(monograph.isbn_paper).to eq attrs['isbn_paper']
expect(monograph.isbn_ebook).to eq attrs['isbn_ebook']
expect(monograph.buy_url).to eq attrs['buy_url']
expect(monograph.subject.count).to eq 2

expect(monograph.ordered_member_ids.count).to eq 2
shipwreck, miranda = monograph.ordered_members.to_a
Expand Down

0 comments on commit 0ca5d89

Please sign in to comment.