Class: IiifPrint::Listener

Inherits:
Object
  • Object
show all
Defined in:
app/listeners/iiif_print/listener.rb

Instance Method Summary collapse

Instance Method Details

#on_file_characterized(event, service: IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService) ⇒ Object

Responsible for conditionally enqueuing the creation of child works from a PDF.

Parameters:

  • event (#[])

    a hash like construct with keys :user and :file_set

  • service (#conditionally_enqueue) (defaults to: IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService)

See Also:

  • Hyrax::WorkUploadsHandler


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/listeners/iiif_print/listener.rb', line 14

def on_file_characterized(event, service: IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService)
  file_set = event[:file_set]
  return false unless file_set
  return false unless file_set.file_set?
  return false unless file_set.original_file&.respond_to?(:pdf?)
  return false unless file_set.original_file&.pdf?

  work = IiifPrint.parent_for(file_set)
  # A short-circuit to avoid fetching the underlying file.
  return false unless work

  user = work.depositor
  # TODO: Verify that this is the correct thing to be sending off for conditional enquing.  That
  # will require a more involved integration test.
  file = file_set.original_file
  service.conditionally_enqueue(file_set: file_set, work: work, file: file, user: user)
end