Class: Krikri::Mapper::Agent
- Inherits:
-
Object
- Object
- Krikri::Mapper::Agent
- Includes:
- EntityConsumer, SoftwareAgent
- Defined in:
- lib/krikri/mapper.rb
Overview
A SoftwareAgent to run mapping processes.
@see: Krikri::SoftwareAgent, Krikri::Activity
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #entity_behavior ⇒ Object
-
#initialize(opts = {}) ⇒ Agent
constructor
A new instance of Agent.
- #run(activity_uri = nil) ⇒ Object
Methods included from EntityConsumer
Methods included from SoftwareAgent
Constructor Details
#initialize(opts = {}) ⇒ Agent
Returns a new instance of Agent.
109 110 111 112 |
# File 'lib/krikri/mapper.rb', line 109 def initialize(opts = {}) @name = opts.fetch(:name).to_sym assign_generator_activity!(opts) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
95 96 97 |
# File 'lib/krikri/mapper.rb', line 95 def name @name end |
Class Method Details
.queue_name ⇒ Object
97 98 99 |
# File 'lib/krikri/mapper.rb', line 97 def self.queue_name :mapping end |
Instance Method Details
#entity_behavior ⇒ Object
105 106 107 |
# File 'lib/krikri/mapper.rb', line 105 def entity_behavior @entity_behavior ||= Krikri::AggregationEntityBehavior end |
#run(activity_uri = nil) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/krikri/mapper.rb', line 114 def run(activity_uri = nil) harvest_records = generator_activity.entities Krikri::Mapper.map(name, harvest_records).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.}\n#{e.backtrace}") end end end |