Class: GeoblacklightAdmin::RemoveParentDctReferencesUriJob

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

Overview

Job to remove a specific DCT references URI from the parent asset.

This job is queued with a priority level and is responsible for removing a DCT references URI from the parent of a given asset.

Instance Method Summary collapse

Instance Method Details

#perform(asset) ⇒ Object

Performs the job of removing the DCT references URI from the parent asset.

This method checks if the asset has a ‘dct_references_uri_key` present. If present, it deletes the URI from the parent’s ‘dct_references_s` array if it matches the asset’s full file URL, and then saves the parent asset.

Parameters:

  • asset (Object)

    The asset whose parent’s DCT references URI is to be removed.

Raises:

  • (StandardError)

    Logs an error if an exception occurs during the process.



23
24
25
26
27
28
29
30
# File 'app/jobs/geoblacklight_admin/remove_parent_dct_references_uri_job.rb', line 23

def perform(asset)
  if asset.dct_references_uri_key.present?
    asset.parent.dct_references_s.delete_if { |i| i.value == asset.full_file_url }
    asset.parent.save!
  end
rescue => e
  Rails.logger.error "\nError - Removing parent dct_references URI: #{e.message} \n"
end