Sha256: 7e9420ff3013c7e4f8cd33948f990eda97d307939511cfbcc5e0e01a6c7bd6b8

Contents?: true

Size: 816 Bytes

Versions: 9

Compression:

Stored size: 816 Bytes

Contents

class CreateWorkJob < ActiveJob::Base
  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
    actor = work_actor(work, user)
    status = actor.create(attributes)
    return operation.success! if status
    operation.fail!(work.errors.full_messages.join(' '))
  end

  private

    def work_actor(work, user)
      Hyrax::CurationConcern.actor(work, user)
    end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/jobs/create_work_job.rb
hyrax-1.1.0 app/jobs/create_work_job.rb
hyrax-1.0.5 app/jobs/create_work_job.rb
hyrax-1.0.4 app/jobs/create_work_job.rb
hyrax-1.0.3 app/jobs/create_work_job.rb
hyrax-1.0.2 app/jobs/create_work_job.rb
hyrax-1.0.1 app/jobs/create_work_job.rb
hyrax-1.0.0.rc2 app/jobs/create_work_job.rb
hyrax-1.0.0.rc1 app/jobs/create_work_job.rb