Sha256: 96398164c76f731999812aa6430d9300defa3f86ae2e5b2008be7407baeb0109

Contents?: true

Size: 923 Bytes

Versions: 48

Compression:

Stored size: 923 Bytes

Contents

# 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

48 entries across 48 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/jobs/create_work_job.rb
hyrax-2.9.5 app/jobs/create_work_job.rb
hyrax-2.9.4 app/jobs/create_work_job.rb
hyrax-2.9.3 app/jobs/create_work_job.rb
hyrax-2.9.2 app/jobs/create_work_job.rb
hyrax-2.9.1 app/jobs/create_work_job.rb
hyrax-2.9.0 app/jobs/create_work_job.rb
hyrax-2.8.0 app/jobs/create_work_job.rb
hyrax-2.7.2 app/jobs/create_work_job.rb
hyrax-2.7.1 app/jobs/create_work_job.rb
hyrax-2.7.0 app/jobs/create_work_job.rb
hyrax-2.6.0 app/jobs/create_work_job.rb
hyrax-3.0.0.pre.rc1 app/jobs/create_work_job.rb
hyrax-3.0.0.pre.beta3 app/jobs/create_work_job.rb
hyrax-2.5.1 app/jobs/create_work_job.rb
hyrax-2.5.0 app/jobs/create_work_job.rb
hyrax-3.0.0.pre.beta2 app/jobs/create_work_job.rb
hyrax-2.4.1 app/jobs/create_work_job.rb
hyrax-3.0.0.pre.beta1 app/jobs/create_work_job.rb
hyrax-2.4.0 app/jobs/create_work_job.rb