Class: Krikri::Mapper::Agent

Inherits:
Object
  • Object
show all
Includes:
SoftwareAgent
Defined in:
lib/krikri/mapper.rb

Overview

A SoftwareAgent to run mapping processes.

@see: Krikri::SoftwareAgent, Krikri::Activity

Constant Summary

Constants included from SoftwareAgent

SoftwareAgent::Logger

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SoftwareAgent

#agent_name, #log

Constructor Details

#initialize(opts = {}) ⇒ Agent

Returns a new instance of Agent.



76
77
78
79
# File 'lib/krikri/mapper.rb', line 76

def initialize(opts = {})
  @name = opts.fetch(:name).to_sym
  @generator_uri = RDF::URI(opts.fetch(:generator_uri))
end

Instance Attribute Details

#generator_uriObject (readonly)

Returns the value of attribute generator_uri.



74
75
76
# File 'lib/krikri/mapper.rb', line 74

def generator_uri
  @generator_uri
end

#nameObject (readonly)

Returns the value of attribute name.



74
75
76
# File 'lib/krikri/mapper.rb', line 74

def name
  @name
end

Instance Method Details

#recordsObject



90
91
92
93
94
95
# File 'lib/krikri/mapper.rb', line 90

def records
  Krikri::ProvenanceQueryClient.find_by_activity(generator_uri)
    .execute.lazy.flat_map do |solution|
    OriginalRecord.load(solution.record.to_s)
  end
end

#run(activity_uri = nil) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/krikri/mapper.rb', line 81

def run(activity_uri = nil)
  Krikri::Mapper.map(name, records).each do |rec|
    rec.mint_id! if rec.node?
    rec << RDF::Statement(rec, RDF::PROV.wasGeneratedBy, activity_uri) if
      activity_uri
    rec.save
  end
end