Class: BulkOps::WorkJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- BulkOps::WorkJob
- Defined in:
- lib/bulk_ops/work_job.rb
Overview
require ‘hydra/access_controls’ require ‘hyrax/workflow/activate_object’
Direct Known Subclasses
Instance Attribute Summary collapse
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
writeonly
Sets the attribute type.
-
#work ⇒ Object
Returns the value of attribute work.
Instance Method Summary collapse
Instance Attribute Details
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/bulk_ops/work_job.rb', line 5 def status @status end |
#type=(value) ⇒ Object
Sets the attribute type
5 6 7 |
# File 'lib/bulk_ops/work_job.rb', line 5 def type=(value) @type = value end |
#work ⇒ Object
Returns the value of attribute work.
5 6 7 |
# File 'lib/bulk_ops/work_job.rb', line 5 def work @work end |
Instance Method Details
#perform(workClass, user_email, attributes, work_proxy_id, visibility = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bulk_ops/work_job.rb', line 45 def perform(workClass,user_email,attributes,work_proxy_id,visibility=nil) return if status == "complete" update_status "starting", "Initializing the job" attributes['visibility']= visibility if visibility.present? attributes['title'] = ['Untitled'] if attributes['title'].blank? @work_proxy = BulkOps::WorkProxy.find(work_proxy_id) unless @work_proxy report_error("Cannot find work proxy with id: #{work_proxy_id}") return end return unless (work_action = define_work(workClass)) user = User.find_by_email(user_email) update_status "running", "Started background task at #{DateTime.now.strftime("%d/%m/%Y %H:%M")}" ability = Ability.new(user) env = Hyrax::Actors::Environment.new(@work, ability, attributes) update_status "complete", Hyrax::CurationConcern.actor.send(work_action,env) end |