class Darlingtonia::RecordImporter
Attributes
@!attribute [rw] error_stream
@return [#<<]
@!attribute [rw] info_stream
@return [#<<]
@!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
@!attribute [rw] error_stream
@return [#<<]
@!attribute [rw] info_stream
@return [#<<]
@!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
@!attribute [rw] error_stream
@return [#<<]
@!attribute [rw] info_stream
@return [#<<]
@!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
@!attribute [rw] error_stream
@return [#<<]
@!attribute [rw] info_stream
@return [#<<]
@!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
@!attribute [rw] error_stream
@return [#<<]
@!attribute [rw] info_stream
@return [#<<]
@!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 Class Methods
@param error_stream
[#<<]
# File lib/darlingtonia/record_importer.rb, line 20 def initialize(error_stream: Darlingtonia.config.default_error_stream, info_stream: Darlingtonia.config.default_info_stream) self.error_stream = error_stream self.info_stream = info_stream end
Public Instance Methods
@param record [ImportRecord]
@return [void]
# File lib/darlingtonia/record_importer.rb, line 30 def import(record:) create_for(record: record) rescue Faraday::ConnectionFailed, Ldp::HttpError => e error_stream << e rescue RuntimeError => e error_stream << e raise e end
# File lib/darlingtonia/record_importer.rb, line 39 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
# File lib/darlingtonia/record_importer.rb, line 48 def create_for(record:) info_stream << 'Creating record: ' \ "#{record.respond_to?(:title) ? record.title : record}." created = import_type.create(record.attributes) info_stream << "Record created at: #{created.id}" end