class Hyrax::Ingest::Runner

Attributes

config[R]

Public Class Methods

new(config_file_path:, sip_path: nil, shared_sip_path: nil, iteration: 0, depositor: nil) click to toggle source
# File lib/hyrax/ingest/runner.rb, line 40
def initialize(config_file_path:, sip_path: nil, shared_sip_path: nil, iteration: 0, depositor: nil)
  self.sip = SIP.new(path: sip_path) if sip_path
  self.shared_sip = shared_sip_path != nil ? SIP.new(path: shared_sip_path) : nil
  self.iteration = iteration.to_i
  self.depositor = depositor
  @config = Hyrax::Ingest::Configuration.new(config_file_path: config_file_path)
end

Public Instance Methods

ingested_ids_by_type() click to toggle source

TODO: Does not yet return IDs of associated objects that were ingested as assocaited objects (i.e. objects that are nested under other objects in the ingest configuration). It only returns IDs for objects that are ingested per the top-level of ingest configuration.

# File lib/hyrax/ingest/runner.rb, line 56
def ingested_ids_by_type
  {}.tap do |h|
    ingesters.each do |ingester|
      if ingester.respond_to? :af_model
        h[ingester.af_model.class] ||= []
        h[ingester.af_model.class] << ingester.af_model.id
      end
    end
  end
end
run!() click to toggle source
# File lib/hyrax/ingest/runner.rb, line 48
def run!
  ingesters.collect { |ingester| ingester.run! }
end

Private Instance Methods

ingesters() click to toggle source
# File lib/hyrax/ingest/runner.rb, line 84
def ingesters
  @ingesters ||= config.ingester_configs.map do |ingester_config|
    # TODO: Better way to handle invalid config than throwing big
    # error msgs from here.
    raise Hyrax::Ingest::Errors::InvalidConfig.new('Ingester config must be a single key value pair, where the key is the name of the ingester, and the value is the ingester configuration.') unless ingester_config.respond_to? :keys
    ingester_name = ingester_config.keys.first
    ingester_options = ingester_config.values.first
    Hyrax::Ingest::Ingester.factory(ingester_name, ingester_options).tap do |ingester|
      ingester.sip = sip if ingester.respond_to? :sip=
      ingester.shared_sip = shared_sip if ingester.respond_to? :shared_sip=
      ingester.iteration = iteration if ingester.respond_to? :iteration=
      ingester.logger = logger if ingester.respond_to? :logger=
      ingester.report = report if ingester.respond_to? :report=
      ingester.depositor = depositor if ingester.respond_to? :depositor=
    end
  end
end