Sha256: d5066363e6d8566ec5ef2d11a056b9d7b3ed6a2db1ff6e0f51db47ab1a5998ea
Contents?: true
Size: 1.76 KB
Versions: 9
Compression:
Stored size: 1.76 KB
Contents
class BatchCreateJob < 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 [Hash<String => String>] titles # @param [Hash<String => String>] resource_types # @param [Array<String>] uploaded_files Hyrax::UploadedFile IDs # @param [Hash] attributes attributes to apply to all works, including :model # @param [Hyrax::BatchCreateOperation] operation def perform(user, titles, resource_types, uploaded_files, attributes, operation) operation.performing! titles ||= {} resource_types ||= {} create(user, titles, resource_types, uploaded_files, attributes, operation) end private def create(user, titles, resource_types, uploaded_files, attributes, operation) model = attributes.delete(:model) || attributes.delete('model') raise ArgumentError, 'attributes must include "model" => ClassName.to_s' unless model uploaded_files.each do |upload_id| title = [titles[upload_id]] if titles[upload_id] resource_type = Array.wrap(resource_types[upload_id]) if resource_types[upload_id] attributes = attributes.merge(uploaded_files: [upload_id], title: title, resource_type: resource_type) child_operation = Hyrax::Operation.create!(user: user, operation_type: "Create Work", parent: operation) CreateWorkJob.perform_later(user, model, attributes, child_operation) end end end
Version data entries
9 entries across 9 versions & 1 rubygems