class GalterIrExporter::Export::VersionGraphConverter

Convert a graph of versions from a GenericFile into a list of POROs so that the metadata

(including pointers to the version content) can be exported in json format using to_json

@attr_reader [Array<VersionConverter] versions list of VersionConverters extracted from the graph

Attributes

versions[R]

Public Class Methods

new(version_graph) click to toggle source

Create an instance of a GenericFile version graph containing all the metadata for each version

@param [ActiveFedora::VersionsGraph] version_graph the graph of versions associated with one GenericFile (gf.content.versions)

# File lib/galter_ir_exporter/export/version_graph_converter.rb, line 13
def initialize(version_graph)
  @versions = []
  parse(version_graph)
end

Private Instance Methods

find_uris(graph) click to toggle source
# File lib/galter_ir_exporter/export/version_graph_converter.rb, line 26
def find_uris(graph)
  uris = []
  graph.query(predicate: RDF::Vocab::Fcrepo4.hasVersion).each do |triple|
    uris << triple.object.to_s
  end
  uris
end
parse(graph) click to toggle source
# File lib/galter_ir_exporter/export/version_graph_converter.rb, line 20
def parse(graph)
  find_uris(graph).each do |uri|
    versions << VersionConverter.new(uri, graph)
  end
end