Class: Hyrax::GraphExporter

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/graph_exporter.rb

Overview

Retrieves the graph for an object with the internal triples removed and the uris translated to external uris.

Defined Under Namespace

Classes: ListSourceExporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solr_document, hostname:) ⇒ GraphExporter

Returns a new instance of GraphExporter.

Parameters:

  • solr_document (SolrDocument, #id)

    idea here is that in the future, ActiveFedora may serialize the object as JSON+LD

  • request (ActionDispatch::Request)

    the http request context

  • hostname (String)

    the current http host



13
14
15
16
17
18
# File 'app/services/hyrax/graph_exporter.rb', line 13

def initialize(solr_document, hostname:)
  @solr_document = solr_document
  @hostname = hostname
  @additional_resources = []
  @visited_subresources = Set.new
end

Instance Attribute Details

#additional_resourcesArray<RDF::Graph>, ActionDispatch::Request (readonly)

Returns:

  • (Array<RDF::Graph>)
  • (ActionDispatch::Request)


28
# File 'app/services/hyrax/graph_exporter.rb', line 28

attr_reader :solr_document, :additional_resources, :hostname

#hostnameObject (readonly)



28
# File 'app/services/hyrax/graph_exporter.rb', line 28

attr_reader :solr_document, :additional_resources, :hostname

#solr_document#id (readonly)

Returns:

  • (#id)


28
29
30
# File 'app/services/hyrax/graph_exporter.rb', line 28

def solr_document
  @solr_document
end

Instance Method Details

#fetchRDF::Graph

Returns:

  • (RDF::Graph)


32
33
34
35
36
37
38
39
# File 'app/services/hyrax/graph_exporter.rb', line 32

def fetch
  clean_graph_repository.find(solr_document.id).tap do |g|
    additional_resources.each { |subgraph| g << subgraph }
  end
rescue Ldp::NotFound
  # this error is handled with a 404 page.
  raise Hyrax::ObjectNotFoundError
end