Class: CreateWorkJob

Inherits:
Hyrax::ApplicationJob show all
Defined in:
app/jobs/create_work_job.rb

Overview

This is a job spawned by the BatchCreateJob

Instance Method Summary collapse

Instance Method Details

#perform(user, model, attributes, operation) ⇒ Object

This copies metadata from the passed in attribute to all of the works that are members of the given upload set

Parameters:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/jobs/create_work_job.rb', line 17

def perform(user, model, attributes, operation)
  operation.performing!
  work = model.constantize.new
  if model.constantize < ActiveFedora::Base
    status = batch_create_af_work(work, attributes, user)
    errors = work.errors
  else
    result = batch_create_valkyrie_work(work, attributes, user)
    status = result.success?
    errors = result.failure&.last
  end

  return operation.success! if status
  operation.fail!(errors.full_messages.join(' '))
end