Sha256: 78cbd59bf0fffd55df8d048040b5dd5527dc8a0368406ed4cc545bffa6d0233f

Contents?: true

Size: 1.23 KB

Versions: 58

Compression:

Stored size: 1.23 KB

Contents

module Hyrax
  # Retrieves the graph for an object with the internal triples removed
  # and the uris translated to external uris.
  class ListSourceExporter
    # @param [String] id
    # @param [ActionDispatch::Request] request the http request context
    # @param [String] parent_url
    def initialize(id, request, parent_url)
      @id = id
      @request = request
      @parent_url = parent_url
    end

    attr_reader :id, :request, :parent_url

    # @return [RDF::Graph]
    def fetch
      clean_graph_repository.find(id)
    end

    private

      def clean_graph_repository
        Hydra::ContentNegotiation::CleanGraphRepository.new(connection, replacer)
      end

      def connection
        @connection ||= CleanConnection.new(ActiveFedora.fedora.connection)
      end

      # This method is called once for each statement in the graph.
      def replacer
        lambda do |resource_id, _graph|
          parent_id = ActiveFedora::Base.uri_to_id(parent_url)
          return parent_url + resource_id.sub(parent_id, '') if resource_id.start_with?(parent_id)
          Rails.application.routes.url_helpers.solr_document_url(resource_id, host: hostname)
        end
      end

      def hostname
        request.host
      end
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
hyrax-2.9.6 app/services/hyrax/list_source_exporter.rb
hyrax-2.9.5 app/services/hyrax/list_source_exporter.rb
hyrax-2.9.4 app/services/hyrax/list_source_exporter.rb
hyrax-2.9.3 app/services/hyrax/list_source_exporter.rb
hyrax-2.9.2 app/services/hyrax/list_source_exporter.rb
hyrax-2.9.1 app/services/hyrax/list_source_exporter.rb
hyrax-2.9.0 app/services/hyrax/list_source_exporter.rb
hyrax-2.8.0 app/services/hyrax/list_source_exporter.rb
hyrax-2.7.2 app/services/hyrax/list_source_exporter.rb
hyrax-2.7.1 app/services/hyrax/list_source_exporter.rb
hyrax-2.7.0 app/services/hyrax/list_source_exporter.rb
hyrax-2.6.0 app/services/hyrax/list_source_exporter.rb
hyrax-3.0.0.pre.rc1 app/services/hyrax/list_source_exporter.rb
hyrax-3.0.0.pre.beta3 app/services/hyrax/list_source_exporter.rb
hyrax-2.5.1 app/services/hyrax/list_source_exporter.rb
hyrax-2.5.0 app/services/hyrax/list_source_exporter.rb
hyrax-3.0.0.pre.beta2 app/services/hyrax/list_source_exporter.rb
hyrax-2.4.1 app/services/hyrax/list_source_exporter.rb
hyrax-3.0.0.pre.beta1 app/services/hyrax/list_source_exporter.rb
hyrax-2.4.0 app/services/hyrax/list_source_exporter.rb