class Zizia::RecordImporter
Attributes
batch_id[RW]
@!attribute [rw] batch_id
@return [String] an optional batch id for this import run
@!attribute [rw] success_count
@return [Integer] a count of the records that were successfully created
@!attribute [rw] failure_count
@return [Integer] a count of the records that failed import
failure_count[RW]
@!attribute [rw] batch_id
@return [String] an optional batch id for this import run
@!attribute [rw] success_count
@return [Integer] a count of the records that were successfully created
@!attribute [rw] failure_count
@return [Integer] a count of the records that failed import
success_count[RW]
@!attribute [rw] batch_id
@return [String] an optional batch id for this import run
@!attribute [rw] success_count
@return [Integer] a count of the records that were successfully created
@!attribute [rw] failure_count
@return [Integer] a count of the records that failed import
Public Instance Methods
import(record:)
click to toggle source
@param record [ImportRecord]
@return [void]
# 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_type()
click to toggle source
# 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
Private Instance Methods
create_for(record:)
click to toggle source
# File lib/zizia/record_importer.rb, line 36 def create_for(record:) Rails.logger.info "[zizia] Creating record: #{record.respond_to?(:title) ? record.title : record}." created = import_type.create(record.attributes) Rails.logger.info "[zizia] Record created at: #{created.id}" end