Class: BatchUpdateJob
- Inherits:
-
Object
- Object
- BatchUpdateJob
- Includes:
- Hydra::PermissionsQuery, Sufia::Messages
- Defined in:
- app/jobs/batch_update_job.rb
Overview
Resque job that updates files uploaded via the BatchController
Instance Attribute Summary collapse
-
#batch_id ⇒ Object
readonly
Returns the value of attribute batch_id.
-
#denied ⇒ Object
writeonly
Sets the attribute denied.
-
#file_attributes ⇒ Object
readonly
Returns the value of attribute file_attributes.
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#saved ⇒ Object
writeonly
Sets the attribute saved.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#visibility ⇒ Object
readonly
Returns the value of attribute visibility.
Attributes included from Sufia::Messages
Instance Method Summary collapse
-
#apply_metadata(gf) ⇒ Object
Updates the metadata for one file in the batch.
-
#initialize(login, batch_id, title, file_attributes, visibility) ⇒ BatchUpdateJob
constructor
Called from BatchController.
-
#queue_additional_jobs(gf) ⇒ Object
Queues jobs to run on each file.
- #queue_name ⇒ Object
- #run ⇒ Object
- #send_user_failure_message ⇒ Object
- #send_user_success_message ⇒ Object
Methods included from Sufia::Messages
#failure_subject, #file_list, #link_to_file, #multiple_failure, #multiple_success, #single_failure, #single_success, #success_subject
Constructor Details
#initialize(login, batch_id, title, file_attributes, visibility) ⇒ BatchUpdateJob
Called from BatchController
19 20 21 22 23 24 25 |
# File 'app/jobs/batch_update_job.rb', line 19 def initialize(login, batch_id, title, file_attributes, visibility) @login = login @batch_id = batch_id @title = title || {} @file_attributes = file_attributes @visibility = visibility end |
Instance Attribute Details
#batch_id ⇒ Object (readonly)
Returns the value of attribute batch_id.
10 11 12 |
# File 'app/jobs/batch_update_job.rb', line 10 def batch_id @batch_id end |
#denied=(value) ⇒ Object
Sets the attribute denied
11 12 13 |
# File 'app/jobs/batch_update_job.rb', line 11 def denied=(value) @denied = value end |
#file_attributes ⇒ Object (readonly)
Returns the value of attribute file_attributes.
10 11 12 |
# File 'app/jobs/batch_update_job.rb', line 10 def file_attributes @file_attributes end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
10 11 12 |
# File 'app/jobs/batch_update_job.rb', line 10 def login @login end |
#saved=(value) ⇒ Object
Sets the attribute saved
11 12 13 |
# File 'app/jobs/batch_update_job.rb', line 11 def saved=(value) @saved = value end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'app/jobs/batch_update_job.rb', line 10 def title @title end |
#visibility ⇒ Object (readonly)
Returns the value of attribute visibility.
10 11 12 |
# File 'app/jobs/batch_update_job.rb', line 10 def visibility @visibility end |
Instance Method Details
#apply_metadata(gf) ⇒ Object
Updates the metadata for one file in the batch. Override this method if you wish to perform additional operations to these files.
36 37 38 39 40 |
# File 'app/jobs/batch_update_job.rb', line 36 def (gf) gf.title = title[gf.id] if title[gf.id] gf.attributes = file_attributes gf.visibility = visibility end |
#queue_additional_jobs(gf) ⇒ Object
Queues jobs to run on each file. By default, this includes ContentUpdateEventJob, but can be augmented with additional custom jobs
45 46 47 48 |
# File 'app/jobs/batch_update_job.rb', line 45 def queue_additional_jobs(gf) Sufia.queue.push(ContentUpdateEventJob.new(gf.id, login)) Sufia.queue.push(ResolrizeGenericFileJob.new(gf.id)) unless Sufia.config.collection_facet.nil? end |
#queue_name ⇒ Object
6 7 8 |
# File 'app/jobs/batch_update_job.rb', line 6 def queue_name :batch_update end |
#run ⇒ Object
27 28 29 30 31 |
# File 'app/jobs/batch_update_job.rb', line 27 def run batch.generic_files.each { |gf| update_file(gf) } batch.update(status: ["Complete"]) end |
#send_user_failure_message ⇒ Object
55 56 57 58 |
# File 'app/jobs/batch_update_job.rb', line 55 def = denied.count > 1 ? multiple_failure(batch.id, denied) : single_failure(batch.id, denied.first) User.batchuser.(user, , failure_subject, false) end |
#send_user_success_message ⇒ Object
50 51 52 53 |
# File 'app/jobs/batch_update_job.rb', line 50 def = saved.count > 1 ? multiple_success(batch.id, saved) : single_success(batch.id, saved.first) User.batchuser.(user, , success_subject, false) end |