Sha256: d88a06071cfbffd39e2cb15a0a03b0c3e538ef37c2d3a8a1dcfe89b2720628d4

Contents?: true

Size: 738 Bytes

Versions: 3

Compression:

Stored size: 738 Bytes

Contents

module NewspaperWorks
  # Create child page works for issue
  class CreateIssuePagesJob < NewspaperWorks::ApplicationJob
    def perform(work, pdf_paths, user, admin_set_id)
      # we will need depositor set on work, if it is nil
      work.depositor ||= user
      # if we do not have admin_set_id yet, set it on the issue work:
      work.admin_set_id ||= admin_set_id
      # create child pages for each page within each PDF uploaded:
      pdf_paths.each do |path|
        adapter = NewspaperWorks::Ingest::NewspaperIssueIngest.new(work)
        adapter.load(path)
        adapter.create_child_pages
      end
      # re-save pages so that parent and sibling relationships are indexed
      work.pages.each(&:save)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 app/jobs/newspaper_works/create_issue_pages_job.rb
newspaper_works-1.0.0 app/jobs/newspaper_works/create_issue_pages_job.rb
newspaper_works-0.1.0 app/jobs/newspaper_works/create_issue_pages_job.rb