Class: Zizia::RecordImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/zizia/record_importer.rb

Direct Known Subclasses

HyraxRecordImporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#batch_idString

Returns an optional batch id for this import run.

Returns:

  • (String)

    an optional batch id for this import run



12
13
14
# File 'lib/zizia/record_importer.rb', line 12

def batch_id
  @batch_id
end

#failure_countInteger

Returns a count of the records that failed import.

Returns:

  • (Integer)

    a count of the records that failed import



12
# File 'lib/zizia/record_importer.rb', line 12

attr_accessor :batch_id, :success_count, :failure_count

#success_countInteger

Returns a count of the records that were successfully created.

Returns:

  • (Integer)

    a count of the records that were successfully created



12
# File 'lib/zizia/record_importer.rb', line 12

attr_accessor :batch_id, :success_count, :failure_count

Instance Method Details

#import(record:) ⇒ void

This method returns an undefined value.

Parameters:

  • record (ImportRecord)


18
19
20
21
22
23
24
25
# File 'lib/zizia/record_importer.rb', line 18

def import(record:)
  create_for(record: record)
rescue Faraday::ConnectionFailed, Ldp::HttpError => e
  Rails.logger.error "[zizia] #{e}"
rescue RuntimeError => e
  Rails.logger.error "[zizia] #{e}"
  raise e
end

#import_typeObject



27
28
29
30
31
32
# File 'lib/zizia/record_importer.rb', line 27

def import_type
  raise 'No curation_concern found for import' unless
    defined?(Hyrax) && Hyrax&.config&.curation_concerns&.any?

  Hyrax.config.curation_concerns.first
end