Class: GeoblacklightAdmin::SetParentDctReferencesUriJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb

Overview

Job to set the parent DCT references URI for a given asset.

This job is responsible for creating a new reference for the asset’s DCT references URI key and appending it to the parent asset’s ‘dct_references_s` array. It then saves the parent asset.

If an error occurs during the process, it logs the error message.

Instance Method Summary collapse

Instance Method Details

#perform(asset) ⇒ void

This method returns an undefined value.

Performs the job to set the parent DCT references URI.



24
25
26
27
28
29
30
31
32
33
34
# File 'app/jobs/geoblacklight_admin/set_parent_dct_references_uri_job.rb', line 24

def perform(asset)
  if asset.dct_references_uri_key.present?
    reference = Document::Reference.new
    reference.category = asset.dct_references_uri_key
    reference.value = asset.full_file_url
    asset.parent.dct_references_s << reference
    asset.parent.save!
  end
rescue => e
  Rails.logger.error "\nError - Setting parent DCT references URI: #{e.message}\n"
end