Sha256: 199d9013d424db296bd6ca320eabd48fc63e480c1732863c77f60ef89d47e273

Contents?: true

Size: 947 Bytes

Versions: 21

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true
# This is a job spawned by the BatchCreateJob
class CreateWorkJob < Hyrax::ApplicationJob
  queue_as Hyrax.config.ingest_queue_name

  before_enqueue do |job|
    operation = job.arguments.last
    operation.pending_job(self)
  end

  # This copies metadata from the passed in attribute to all of the works that
  # are members of the given upload set
  # @param [User] user
  # @param [String] model
  # @param [Hash] attributes
  # @param [Hyrax::BatchCreateOperation] operation
  def perform(user, model, attributes, operation)
    operation.performing!
    work = model.constantize.new
    current_ability = Ability.new(user)
    env = Hyrax::Actors::Environment.new(work, current_ability, attributes)
    status = work_actor.create(env)
    return operation.success! if status
    operation.fail!(work.errors.full_messages.join(' '))
  end

  private

  def work_actor
    Hyrax::CurationConcern.actor
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
hyrax-5.0.0.rc1 app/jobs/create_work_job.rb
hyrax-3.6.0 app/jobs/create_work_job.rb
hyrax-4.0.0 app/jobs/create_work_job.rb
hyrax-4.0.0.rc3 app/jobs/create_work_job.rb
hyrax-4.0.0.rc2 app/jobs/create_work_job.rb
hyrax-4.0.0.rc1 app/jobs/create_work_job.rb
hyrax-3.5.0 app/jobs/create_work_job.rb
hyrax-4.0.0.beta2 app/jobs/create_work_job.rb
hyrax-3.4.2 app/jobs/create_work_job.rb
hyrax-4.0.0.beta1 app/jobs/create_work_job.rb
hyrax-3.4.1 app/jobs/create_work_job.rb
hyrax-3.4.0 app/jobs/create_work_job.rb
hyrax-3.3.0 app/jobs/create_work_job.rb
hyrax-3.2.0 app/jobs/create_work_job.rb
hyrax-3.1.0 app/jobs/create_work_job.rb
hyrax-3.0.2 app/jobs/create_work_job.rb
hyrax-3.0.1 app/jobs/create_work_job.rb
hyrax-3.0.0 app/jobs/create_work_job.rb
hyrax-3.0.0.pre.rc4 app/jobs/create_work_job.rb
hyrax-3.0.0.pre.rc3 app/jobs/create_work_job.rb