Class: ImportNexusJob

Inherits:
ApplicationJob show all
Includes:
Lib::Vendor::NexusParserHelper
Defined in:
app/jobs/import_nexus_job.rb

Instance Method Summary collapse

Instance Method Details

#document_to_nexus(nexus_doc_id, matrix, options) ⇒ Object



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
# File 'app/jobs/import_nexus_job.rb', line 19

def document_to_nexus(nexus_doc_id, matrix, options)
  begin
    Vendor::NexusParser.document_id_to_nexus(nexus_doc_id)
  rescue => e
    if e.class == ActiveRecord::RecordNotFound
      # ExceptionNotifier ignores RecordNotFound, so use TW::Error instead.
      bt = e.backtrace
      e = TaxonWorks::Error.new(e.message)
      e.set_backtrace(bt)
    end

    ExceptionNotifier.notify_exception(e,
      data: {
        nexus_document_id: nexus_doc_id,
        matrix_id: matrix&.id,
        user_id: Current.user_id,
        project_id: Current.project_id
      }
      .merge(options)
    )

    matrix&.destroy!
    raise
  end
end

#perform(nexus_doc_id, matrix, options, uid, project_id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/jobs/import_nexus_job.rb', line 5

def perform(nexus_doc_id, matrix, options, uid, project_id)
  Current.user_id = uid
  Current.project_id = project_id

  nf = document_to_nexus(nexus_doc_id, matrix, options)

  populate_matrix_with_nexus(
    nexus_doc_id,
    nf,
    matrix,
    options
  )
end