class Krikri::Mapper::Agent
A SoftwareAgent
to run mapping processes.
@example to map the records harvested by the harvest activity with ID 1:
Krikri::Mapper::Agent.enqueue(name: :scdl_qdc, generator_uri: 'http://ldp.local.dp.la/ldp/activity/1')
@see: Krikri::SoftwareAgent
, Krikri::Activity
Attributes
name[R]
@!attribute [r] name
@return [Symbol]
Public Class Methods
new(opts = {})
click to toggle source
@param opts [Hash] @option opts [#to_sym] name the symbol naming the mapping to use
# File lib/krikri/mapper.rb, line 110 def initialize(opts = {}) @name = opts.fetch(:name).to_sym @entity_behavior = self.class.entity_behavior assign_generator_activity!(opts) end
queue_name()
click to toggle source
@return [Symbol] the default queue for jobs using this agent
# File lib/krikri/mapper.rb, line 95 def self.queue_name :mapping end
Public Instance Methods
entity_behavior()
click to toggle source
@see Krikri::Activity#entities @see Krikri::EntityBehavior
@see Krikri::SoftwareAgent#entity_behavior
# File lib/krikri/mapper.rb, line 103 def entity_behavior @entity_behavior ||= Krikri::AggregationEntityBehavior end
run(activity_uri = nil)
click to toggle source
@param activity_uri [RDF::URI] the uri of the activity to attribute
for provenance purposes (default: nil)
@see SoftwareAgent#run
# File lib/krikri/mapper.rb, line 120 def run(activity_uri = nil) Krikri::Mapper.map(name, entities).each do |rec| begin rec.mint_id! if rec.node? activity_uri ? rec.save_with_provenance(activity_uri) : rec.save rescue => e Rails.logger.error("Error saving record: #{rec.try(:rdf_subject)}\n" \ "#{e.message}\n#{e.backtrace}") end end end