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.
126 127 128 129 |
# File 'lib/krikri/mapper.rb', line 126 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.
112 113 114 |
# File 'lib/krikri/mapper.rb', line 112 def name @name end |
Class Method Details
.queue_name ⇒ Object
114 115 116 |
# File 'lib/krikri/mapper.rb', line 114 def self.queue_name :mapping end |
Instance Method Details
#entity_behavior ⇒ Object
122 123 124 |
# File 'lib/krikri/mapper.rb', line 122 def entity_behavior @entity_behavior ||= Krikri::AggregationEntityBehavior end |
#run(activity_uri = nil) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/krikri/mapper.rb', line 131 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.message}\n#{e.backtrace}") end end end |