From 2f032f0086145a18e723aa807525da6013e5e7fa Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 27 Jan 2022 16:32:29 -0600 Subject: [PATCH 1/3] do not sort the records before mapping the metadata --- app/models/bulkrax/csv_entry.rb | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/models/bulkrax/csv_entry.rb b/app/models/bulkrax/csv_entry.rb index 23d2ef94..6e8d6317 100644 --- a/app/models/bulkrax/csv_entry.rb +++ b/app/models/bulkrax/csv_entry.rb @@ -39,6 +39,7 @@ def build_metadata raise StandardError, "Missing required elements, missing element(s) are: #{importerexporter.parser.missing_elements(keys_without_numbers(record.keys)).join(', ')}" unless importerexporter.parser.required_elements?(keys_without_numbers(record.keys)) self.parsed_metadata = {} + binding.pry add_identifier add_metadata_for_model add_visibility @@ -46,6 +47,32 @@ def build_metadata add_rights_statement add_collections add_local + # { + # "identifier"=>["ULUA Cardinal 19261001", "ULUA Cardinal 19261001"], + # "file"=>[], + # "admin_set_id"=>"admin_set/default", + # "visibility"=>"open", + # "collection_information"=>["https://archivescatalog.library.louisville.edu/resources/louisville-cardinal-newspaper"], + # "contributor"=>[""], + # "date_digital"=>"1/28/2019", + # "date_created"=>["10/1/1926"], + # "description"=> + # ["The University of Louisville’s undergraduate newspaper. The title of this publication has varied over the years, but with the exception of the period 1928-1930, when it was known as the U. of L. News, the title has always been a variation of The Cardinal."], + # "digitization_specification"=>"", + # "format"=>["application/pdf"], + # "language"=>["English"], + # "media_type"=>["Text"], + # "model"=>"Text", + # "resource_type"=>["Newspapers"], + # "ordering_information"=>"To inquire about reproductions, permissions, or for information about prices see: https://library.louisville.edu/archives/order. Please cite the Item Number when ordering.", + # "publisher"=>["University of Louisville Archives and Special Collections"], + # "searchable_text"=>"", + # "source"=>["Scanned from microfilm in the Louisville Cardinal newspapers collection. Item Number ULUA Cardinal 19261001"], + # "subject"=>["Newspapers", "College student newspapers and periodicals", "University of Louisville--Students--Periodicals"], + # "title"=>["The Cardinal News, October 1, 1926."], + # "volume"=>"I", + # "rights_statement"=>[""] + # } self.parsed_metadata end @@ -68,7 +95,9 @@ def add_ingested_metadata 'Creating Collections using the collection_field_mapping will no longer be supported as of Bulkrax version 3.0.' \ ' Please configure Bulkrax to use related_parents_field_mapping and related_children_field_mapping instead.' ) - record.sort.each do |key, value| + # we do not want to sort the values in the record before adding the metadata. + # if we do, the factory_class will be set to the default_work_type for all values that come before "model" or "work type" + record.each do |key, value| next if self.parser.collection_field_mapping.to_s == key_without_numbers(key) index = key[/\d+/].to_i - 1 if key[/\d+/].to_i != 0 From 57df7499e33d074588b3f7fb4326175dbff08753 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 27 Jan 2022 16:51:36 -0600 Subject: [PATCH 2/3] remove testing things --- app/factories/bulkrax/object_factory.rb | 2 ++ app/models/bulkrax/csv_entry.rb | 27 --------------------- app/models/concerns/bulkrax/has_matchers.rb | 2 ++ 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/app/factories/bulkrax/object_factory.rb b/app/factories/bulkrax/object_factory.rb index c58fa175..c74eb452 100644 --- a/app/factories/bulkrax/object_factory.rb +++ b/app/factories/bulkrax/object_factory.rb @@ -54,6 +54,7 @@ def update destroy_existing_files if @replace_files && klass != Collection attrs = attribute_update run_callbacks :save do + # binding.pry klass == Collection ? update_collection(attrs) : work_actor.update(environment(attrs)) end log_updated(object) @@ -93,6 +94,7 @@ def create object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX run_callbacks :save do run_callbacks :create do + # binding.pry klass == Collection ? create_collection(attrs) : work_actor.create(environment(attrs)) end end diff --git a/app/models/bulkrax/csv_entry.rb b/app/models/bulkrax/csv_entry.rb index 6e8d6317..a5ed82be 100644 --- a/app/models/bulkrax/csv_entry.rb +++ b/app/models/bulkrax/csv_entry.rb @@ -39,7 +39,6 @@ def build_metadata raise StandardError, "Missing required elements, missing element(s) are: #{importerexporter.parser.missing_elements(keys_without_numbers(record.keys)).join(', ')}" unless importerexporter.parser.required_elements?(keys_without_numbers(record.keys)) self.parsed_metadata = {} - binding.pry add_identifier add_metadata_for_model add_visibility @@ -47,32 +46,6 @@ def build_metadata add_rights_statement add_collections add_local - # { - # "identifier"=>["ULUA Cardinal 19261001", "ULUA Cardinal 19261001"], - # "file"=>[], - # "admin_set_id"=>"admin_set/default", - # "visibility"=>"open", - # "collection_information"=>["https://archivescatalog.library.louisville.edu/resources/louisville-cardinal-newspaper"], - # "contributor"=>[""], - # "date_digital"=>"1/28/2019", - # "date_created"=>["10/1/1926"], - # "description"=> - # ["The University of Louisville’s undergraduate newspaper. The title of this publication has varied over the years, but with the exception of the period 1928-1930, when it was known as the U. of L. News, the title has always been a variation of The Cardinal."], - # "digitization_specification"=>"", - # "format"=>["application/pdf"], - # "language"=>["English"], - # "media_type"=>["Text"], - # "model"=>"Text", - # "resource_type"=>["Newspapers"], - # "ordering_information"=>"To inquire about reproductions, permissions, or for information about prices see: https://library.louisville.edu/archives/order. Please cite the Item Number when ordering.", - # "publisher"=>["University of Louisville Archives and Special Collections"], - # "searchable_text"=>"", - # "source"=>["Scanned from microfilm in the Louisville Cardinal newspapers collection. Item Number ULUA Cardinal 19261001"], - # "subject"=>["Newspapers", "College student newspapers and periodicals", "University of Louisville--Students--Periodicals"], - # "title"=>["The Cardinal News, October 1, 1926."], - # "volume"=>"I", - # "rights_statement"=>[""] - # } self.parsed_metadata end diff --git a/app/models/concerns/bulkrax/has_matchers.rb b/app/models/concerns/bulkrax/has_matchers.rb index f4b41d7e..56a79ca8 100644 --- a/app/models/concerns/bulkrax/has_matchers.rb +++ b/app/models/concerns/bulkrax/has_matchers.rb @@ -52,6 +52,7 @@ def add_metadata(node_name, node_content, index = nil) single_metadata(node_content) end + # binding.pry if name == 'format' object_name.present? ? set_parsed_object_data(object_multiple, object_name, name, index, value) : set_parsed_data(name, value) end end @@ -159,6 +160,7 @@ def multiple?(field) #{related_parents_parsed_mapping} #{related_children_parsed_mapping} ] + binding.pry if field == 'format' return true if @multiple_bulkrax_fields.include?(field) return false if field == 'model' From 6f16743aeaa606002e72498c490dca6f503b7413 Mon Sep 17 00:00:00 2001 From: Alisha Evans Date: Thu, 27 Jan 2022 16:52:46 -0600 Subject: [PATCH 3/3] lets try this again --- app/factories/bulkrax/object_factory.rb | 2 -- app/models/concerns/bulkrax/has_matchers.rb | 2 -- 2 files changed, 4 deletions(-) diff --git a/app/factories/bulkrax/object_factory.rb b/app/factories/bulkrax/object_factory.rb index c74eb452..c58fa175 100644 --- a/app/factories/bulkrax/object_factory.rb +++ b/app/factories/bulkrax/object_factory.rb @@ -54,7 +54,6 @@ def update destroy_existing_files if @replace_files && klass != Collection attrs = attribute_update run_callbacks :save do - # binding.pry klass == Collection ? update_collection(attrs) : work_actor.update(environment(attrs)) end log_updated(object) @@ -94,7 +93,6 @@ def create object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX run_callbacks :save do run_callbacks :create do - # binding.pry klass == Collection ? create_collection(attrs) : work_actor.create(environment(attrs)) end end diff --git a/app/models/concerns/bulkrax/has_matchers.rb b/app/models/concerns/bulkrax/has_matchers.rb index 56a79ca8..f4b41d7e 100644 --- a/app/models/concerns/bulkrax/has_matchers.rb +++ b/app/models/concerns/bulkrax/has_matchers.rb @@ -52,7 +52,6 @@ def add_metadata(node_name, node_content, index = nil) single_metadata(node_content) end - # binding.pry if name == 'format' object_name.present? ? set_parsed_object_data(object_multiple, object_name, name, index, value) : set_parsed_data(name, value) end end @@ -160,7 +159,6 @@ def multiple?(field) #{related_parents_parsed_mapping} #{related_children_parsed_mapping} ] - binding.pry if field == 'format' return true if @multiple_bulkrax_fields.include?(field) return false if field == 'model'