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, request = nil, hostname: nil) ⇒ 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) (defaults to: nil)

    the http request context

  • hostname (String) (defaults to: nil)

    the current http host


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

def initialize(solr_document, request = nil, hostname: nil)
  Deprecation.warn('passing `request` is deprecated; pass a host as `hostname:` instead.') if request
  @solr_document = solr_document
  @request = request
  @hostname = hostname || request.host
  @additional_resources = []
  @visited_subresources = Set.new
end

Instance Attribute Details

#additional_resourcesArray<RDF::Graph> (readonly)

Returns:

  • (Array<RDF::Graph>)

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

attr_reader :solr_document, :request, :additional_resources, :hostname

#hostnameObject (readonly)


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

attr_reader :solr_document, :request, :additional_resources, :hostname

#requestActionDispatch::Request (readonly)

Deprecated.

use #hostname to access the host

Returns:

  • (ActionDispatch::Request)

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

attr_reader :solr_document, :request, :additional_resources, :hostname

#solr_document#id (readonly)

Returns:

  • (#id)

32
33
34
# File 'app/services/hyrax/graph_exporter.rb', line 32

def solr_document
  @solr_document
end

Instance Method Details

#fetchRDF::Graph

Returns:

  • (RDF::Graph)

37
38
39
40
41
42
43
44
# File 'app/services/hyrax/graph_exporter.rb', line 37

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