Class: Bulkrax::DeleteAndImportJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/bulkrax/delete_and_import_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(entry, importer_run) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/jobs/bulkrax/delete_and_import_job.rb', line 7

def perform(entry, importer_run)
  # Delete the object if it exists, then reimport it.
  # If the object doesn't exist, just reimport it.
  begin
    status = self.class::DELETE_CLASS.perform_now(entry, importer_run)
    reimport(entry, importer_run) if status.status_message == "Deleted"
  rescue Bulkrax::ObjectFactoryInterface::ObjectNotFoundError
    reimport(entry, importer_run)
  end

rescue => e
  entry.set_status_info(e)
  # this causes caught exception to be reraised
  raise
end

#reimport(entry, importer_run) ⇒ Object



23
24
25
26
# File 'app/jobs/bulkrax/delete_and_import_job.rb', line 23

def reimport(entry, importer_run)
  entry = Bulkrax::Entry.find(entry.id) # maximum reload
  self.class::IMPORT_CLASS.perform_now(entry.id, importer_run.id)
end