Class: UploadSetUpdateJob
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- UploadSetUpdateJob
- Includes:
- CurationConcerns::Messages, Hydra::PermissionsQuery
- Defined in:
- app/jobs/upload_set_update_job.rb
Instance Attribute Summary collapse
-
#denied ⇒ Object
Returns the value of attribute denied.
-
#file_attributes ⇒ Object
Returns the value of attribute file_attributes.
-
#login ⇒ Object
Returns the value of attribute login.
-
#saved ⇒ Object
Returns the value of attribute saved.
-
#title ⇒ Object
Returns the value of attribute title.
-
#upload_set_id ⇒ Object
Returns the value of attribute upload_set_id.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
-
#work_attributes ⇒ Object
Returns the value of attribute work_attributes.
Attributes included from CurationConcerns::Messages
Instance Method Summary collapse
- #perform(login, upload_set_id, title, file_attributes, visibility) ⇒ Object
- #update_file(file, user) ⇒ Object
Methods included from CurationConcerns::Messages
#failure_subject, #file_list, #link_to_file, #multiple_failure, #multiple_success, #single_failure, #single_success, #success_subject
Instance Attribute Details
#denied ⇒ Object
Returns the value of attribute denied.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def denied @denied end |
#file_attributes ⇒ Object
Returns the value of attribute file_attributes.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def file_attributes @file_attributes end |
#login ⇒ Object
Returns the value of attribute login.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def login @login end |
#saved ⇒ Object
Returns the value of attribute saved.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def saved @saved end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def title @title end |
#upload_set_id ⇒ Object
Returns the value of attribute upload_set_id.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def upload_set_id @upload_set_id end |
#visibility ⇒ Object
Returns the value of attribute visibility.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def visibility @visibility end |
#work_attributes ⇒ Object
Returns the value of attribute work_attributes.
7 8 9 |
# File 'app/jobs/upload_set_update_job.rb', line 7 def work_attributes @work_attributes end |
Instance Method Details
#perform(login, upload_set_id, title, file_attributes, visibility) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/jobs/upload_set_update_job.rb', line 9 def perform(login, upload_set_id, title, file_attributes, visibility) @login = login @title = title || {} @file_attributes = file_attributes @visibility = visibility @work_attributes = file_attributes.merge(visibility: visibility) @upload_set_id = upload_set_id @saved = [] @denied = [] upload_set = UploadSet.find_or_create(self.upload_set_id) user = User.find_by_user_key(self.login) upload_set.file_sets.each do |file| update_file(file, user) end upload_set.update(status: ["Complete"]) if denied.empty? unless saved.empty? if CurationConcerns.config.callback.set?(:after_upload_set_update_success) login = upload_set.depositor user = User.find_by_user_key(login) CurationConcerns.config.callback.run(:after_upload_set_update_success, user, upload_set, log.created_at) end return true end else if CurationConcerns.config.callback.set?(:after_upload_set_update_failure) login = upload_set.depositor user = User.find_by_user_key(login) CurationConcerns.config.callback.run(:after_upload_set_update_failure. user, upload_set, log.created_at) end return false end end |
#update_file(file, user) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/jobs/upload_set_update_job.rb', line 47 def update_file(file, user) unless user.can? :edit, file ActiveFedora::Base.logger.error "User #{user.user_key} DENIED access to #{file.id}!" denied << file return end # update the file using the actor after setting the title file.title = title[file.id] if title[file.id] CurationConcerns::FileSetActor.new(file, user).(file_attributes.merge(visibility: visibility)) # update the work to the same metadata as the file. # NOTE: For the moment we are assuming copied metadata. This is likely to change. # NOTE2: TODO: stop assuming that files only belong to one work work = file.in_works.first unless work.nil? work.title = title[file.id] if title[file.id] CurationConcerns::GenericWorkActor.new(work, user, work_attributes).update end saved << file end |