From 3a447d6746427fa05f2bf060cfc5ece2c2d539b7 Mon Sep 17 00:00:00 2001 From: LaRita Robinson Date: Tue, 25 Jun 2024 13:11:53 -0400 Subject: [PATCH] Add resource type for child works Resource_type is handled similarly to title, outside of attributes in Hyrax's BatchCreateJob. A required resource_type attribute causes the child work creation to fail, but resource_type cannot be passed via attributes. --- app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb b/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb index 866f7ef1..b5907b5b 100644 --- a/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb +++ b/app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb @@ -87,7 +87,7 @@ def split_pdf(original_pdf_path, user, child_model, pdf_file_set) ) BatchCreateJob.perform_later(user, @child_work_titles, - {}, + @resource_types, @uploaded_files, attributes.merge!(model: child_model.to_s, split_from_pdf_id: @split_from_pdf_id).with_indifferent_access, operation) @@ -99,6 +99,7 @@ def split_pdf(original_pdf_path, user, child_model, pdf_file_set) def prepare_import_data(original_pdf_path, image_files, user) @uploaded_files = [] @child_work_titles = {} + @resource_types = {} number_of_pages_in_pdf = image_files.size image_files.each_with_index do |image_path, page_number| file_id = create_uploaded_file(user, image_path).to_s @@ -111,6 +112,7 @@ def prepare_import_data(original_pdf_path, image_files, user) page_padding: number_of_digits(nbr: number_of_pages_in_pdf) ) + @resource_types[file_id] = resource_types @uploaded_files << file_id @child_work_titles[file_id] = child_title # save child work info to create the member relationships @@ -144,10 +146,14 @@ def create_uploaded_file(user, path) uf.id end - # TODO: what attributes do we need to fill in from the parent work? What about AllinsonFlex? def attributes IiifPrint.config.child_work_attributes_function.call(parent_work: @parent_work, admin_set_id: @child_admin_set_id) end + + # TODO: Does this method need to be configurable? + def resource_types + @parent_work.try(:resource_type) + end end end end