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
# File 'app/services/hyrax/graph_exporter.rb', line 7

def initialize(solr_document, request)
  @solr_document = solr_document
  @request = request
  @additional_resources = []
end

Instance Attribute Details

#additional_resourcesObject (readonly)

Returns the value of attribute additional_resources.



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

def additional_resources
  @additional_resources
end

#requestObject (readonly)

Returns the value of attribute request.



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

def request
  @request
end

#solr_documentObject (readonly)

Returns the value of attribute solr_document.



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

def solr_document
  @solr_document
end

Instance Method Details

#fetchRDF::Graph

Returns:

  • (RDF::Graph)


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

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