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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solr_document, request) ⇒ GraphExporter

Returns a new instance of GraphExporter.

Parameters:

  • solr_document (SolrDocument)

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

  • request (ActionDispatch::Request)

    the http request context


7
8
9
10
11
12
# File 'app/services/hyrax/graph_exporter.rb', line 7

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

Instance Attribute Details

#additional_resourcesObject (readonly)

Returns the value of attribute additional_resources


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

def additional_resources
  @additional_resources
end

#requestObject (readonly)

Returns the value of attribute request


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

def request
  @request
end

#solr_documentObject (readonly)

Returns the value of attribute solr_document


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

def solr_document
  @solr_document
end

Instance Method Details

#fetchRDF::Graph

Returns:

  • (RDF::Graph)

17
18
19
20
21
22
23
24
# File 'app/services/hyrax/graph_exporter.rb', line 17

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 ActiveFedora::ObjectNotFoundError
end