From d85952bd49922ef34b1d65965b3e0dd4b756357c Mon Sep 17 00:00:00 2001 From: "Michael J. Giarlo" Date: Tue, 8 Aug 2017 16:14:20 -0700 Subject: [PATCH] Changes necessary to get simple CSV import to run Refs #1164 --- bin/import_from_csv | 4 ++++ lib/importer/factory/with_associated_collection.rb | 1 + spec/fixtures/csv/simple.csv | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 spec/fixtures/csv/simple.csv diff --git a/bin/import_from_csv b/bin/import_from_csv index ff6309884..f3fd50dbc 100755 --- a/bin/import_from_csv +++ b/bin/import_from_csv @@ -38,6 +38,10 @@ def main(hostname, csv_file, files_directory) puts "Imported #{size} records." end +def logger + Rails.logger +end + def usage $stderr.puts "Usage: #{$PROGRAM_NAME} " end diff --git a/lib/importer/factory/with_associated_collection.rb b/lib/importer/factory/with_associated_collection.rb index 04926fb91..e40edd98a 100644 --- a/lib/importer/factory/with_associated_collection.rb +++ b/lib/importer/factory/with_associated_collection.rb @@ -6,6 +6,7 @@ module WithAssociatedCollection # Strip out the :collection key, and add the member_of_collection_ids, # which is used by Hyrax::Actors::AddAsMemberOfCollectionsActor def create_attributes + return super if attributes[:collection].nil? super.except(:collection).merge(member_of_collection_ids: [collection.id]) end diff --git a/spec/fixtures/csv/simple.csv b/spec/fixtures/csv/simple.csv new file mode 100644 index 000000000..4f3baa71c --- /dev/null +++ b/spec/fixtures/csv/simple.csv @@ -0,0 +1,2 @@ +id,type,title,description,subject,subject,subject,subject,subject,subject,resource_type,contributor,contributor,contributor,contributor,contributor,contributor,contributor,contributor,contributor,contributor,contributor,date_created,file +wg827ks1643,Image,Work in Progress - A Framework for Building Interactive Learning Modules,"The development of good quality educational software is expensive, time-consuming and faces some underlying issues. In order to deal with such issues, many attempts were made, mainly on code reuse. Following a similar approach, the development of an application framework for implementing a family of interactivity-intense educational software called Interactive Learning Modules – iLM is presented. The framework main goal is to reduce development efforts while being part of a Software Product Line – SPL, an innovative technique regarding interactivity-intense educational software. The framework specification is presented by analyzing the common features of existing iLM. Therefore, the resulting component architecture is outlined. Currently, the design phase is finished and the implementation ongoing. Also, its instantiation is planned for an existing iLM, as a proof of concept.", -- educational software, -- software product line, -- application framework,,,,text,"Dalmon, Danilo","Brandao, Leonidas","Brandao, Anarosa","Isotani, Seiji",,,,,,,,2011,4-20.png