Module: IiifPrint::Actors::FileSetActorDecorator

Defined in:
app/actors/iiif_print/actors/file_set_actor_decorator.rb

Instance Method Summary collapse

Instance Method Details

#attach_to_work(work, file_set_params = {}) ⇒ Object

Override to add PDF splitting



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/actors/iiif_print/actors/file_set_actor_decorator.rb', line 28

def attach_to_work(work, file_set_params = {})
  # Locks to ensure that only one process is operating on the list at a time.
  super

  # when we are importing a remote_url, this method is called before the file is attached.
  # We want to short-circuit the process and prevent unnecessarily confusing logging.
  return unless @file

  args = { file_set: file_set, work: work, file: @file, user: @user }
  returned_value = service.conditionally_enqueue(**args)
  Rails.logger.info("Result of #{returned_value} for conditional enqueueing of #{args.inspect}")
  true
end

#create_content(file, relation = :original_file, from_url: false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/actors/iiif_print/actors/file_set_actor_decorator.rb', line 10

def create_content(file, relation = :original_file, from_url: false)
  # Spawns asynchronous IngestJob unless ingesting from URL
  super

  if from_url
    # in this case, the file that came in is a temp file, and we need to use the actual file.
    # the file was attached to the file_set in Hyrax::ImportUrlJob so we can just access it.
    args = { file_set: file_set, file: file_set.files.first, import_url: file_set.import_url, user: @user }
    returned_value = service.conditionally_enqueue(**args)
    Rails.logger.info("Result of #{returned_value} for conditional enqueueing of #{args.inspect}")
    true
  else
    # we don't have the parent yet... save the paths for later use
    @file = file
  end
end

#destroyObject

Clean up children when removing the fileset



47
48
49
50
51
52
53
54
55
# File 'app/actors/iiif_print/actors/file_set_actor_decorator.rb', line 47

def destroy
  # we destroy the children before the file_set, because we need the parent relationship
  IiifPrint::SplitPdfs::DestroyPdfChildWorksService.conditionally_destroy_spawned_children_of(
    file_set: file_set,
    work: IiifPrint.parent_for(file_set)
  )
  # and now back to your regularly scheduled programming
  super
end

#serviceObject



42
43
44
# File 'app/actors/iiif_print/actors/file_set_actor_decorator.rb', line 42

def service
  IiifPrint::SplitPdfs::ChildWorkCreationFromPdfService
end