Class: ContentDepositorChangeEventJob

Inherits:
ContentEventJob show all
Defined in:
app/jobs/content_depositor_change_event_job.rb

Overview

A specific job to log a file deposit change to a user’s activity stream

This is a bit wierd becuase the job performs the depositor transfer along with logging the job

Instance Attribute Summary collapse

Attributes inherited from ContentEventJob

#generic_file_id

Attributes inherited from EventJob

#depositor_id

Instance Method Summary collapse

Methods inherited from ContentEventJob

#log_generic_file_event, #log_to_followers

Methods inherited from EventJob

#depositor, #event, #log_to_followers

Methods included from Sufia::SufiaHelperBehavior

#current_search_parameters, #display_user_name, #error_messages_for, #has_collection_search_parameters?, #iconify_auto_link, #iconify_link, #is_url?, #link_back_to_dashboard, #link_to_dashboard_query, #link_to_facet, #link_to_facet_list, #link_to_field, #link_to_profile, #link_to_telephone, #linkify_chat_id, #number_of_deposits, #orcid_label, #render_visibility_label, #render_visibility_link, #search_form_action, #show_transfer_request_title, #sufia_thumbnail_tag, #user_display_name_and_key, #zotero_label, #zotero_profile_url

Methods included from Sufia::BlacklightOverride

#render_bookmarks_control?, #render_constraints_query, #url_for_document

Constructor Details

#initialize(id, login, reset = false) ⇒ ContentDepositorChangeEventJob

Returns a new instance of ContentDepositorChangeEventJob.

Parameters:

  • id (String)

    identifier of the file to be transfered

  • login (String)

    the user key of the user the file is being transfered to.

  • reset (Boolean) (defaults to: false)

    (false) should the access controls be reset. This means revoking edit access from the depositor



18
19
20
21
22
23
# File 'app/jobs/content_depositor_change_event_job.rb', line 18

def initialize(id, , reset = false)
  super(id, )
  self.id = id
  self. = 
  self.reset = reset
end

Instance Attribute Details

#idString

identifier of the file to be transfered

Returns:

  • (String)

    the current value of id



8
9
10
# File 'app/jobs/content_depositor_change_event_job.rb', line 8

def id
  @id
end

#loginString

the user key of the user the file is being transfered to.

Returns:

  • (String)

    the current value of login



8
9
10
# File 'app/jobs/content_depositor_change_event_job.rb', line 8

def 
  @login
end

#resetBoolean

(false) should the access controls be reset. This means revoking edit access from the depositor

Returns:

  • (Boolean)

    the current value of reset



8
9
10
# File 'app/jobs/content_depositor_change_event_job.rb', line 8

def reset
  @reset
end

Instance Method Details

#actionObject



33
34
35
# File 'app/jobs/content_depositor_change_event_job.rb', line 33

def action
  "User #{link_to_profile generic_file.proxy_depositor} has transferred #{link_to generic_file.title.first, Sufia::Engine.routes.url_helpers.generic_file_path(generic_file)} to user #{link_to_profile }"
end

#generic_fileObject

overriding default to load from fedora and change the depositor



38
39
40
41
42
43
44
45
46
47
48
# File 'app/jobs/content_depositor_change_event_job.rb', line 38

def generic_file
  # TODO: This should be in its own job, not this event job
  @generic_file ||= begin
    file = ::GenericFile.find(id)
    file.proxy_depositor = file.depositor
    file.clear_permissions! if reset
    file.()
    file.save!
    file
  end
end

#log_user_eventObject

overriding default to log the event to the depositor instead of their profile



51
52
53
# File 'app/jobs/content_depositor_change_event_job.rb', line 51

def log_user_event
  depositor.log_event(event)
end

#queue_nameObject



9
10
11
# File 'app/jobs/content_depositor_change_event_job.rb', line 9

def queue_name
  :proxy_deposit
end

#runObject



25
26
27
28
29
30
31
# File 'app/jobs/content_depositor_change_event_job.rb', line 25

def run
  super

  # log the event to the proxy depositor's profile
  proxy_depositor = ::User.find_by_user_key(generic_file.proxy_depositor)
  proxy_depositor.log_profile_event(event)
end