Skip to content

Commit

Permalink
Merge pull request #361 from scientist-softserv/palni-i1-iiif_print-n…
Browse files Browse the repository at this point in the history
…ot-splitting

Add resource type for child works
  • Loading branch information
laritakr authored Jun 25, 2024
2 parents fb07dcd + 3a447d6 commit 0fa95f9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/jobs/iiif_print/jobs/child_works_from_pdf_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 0fa95f9

Please sign in to comment.