Sha256: 756dfc8dbc0e0d6e9b75ddac42b121dae64fbed332228ea2d58e1c38d1bb6c1f

Contents?: true

Size: 534 Bytes

Versions: 1

Compression:

Stored size: 534 Bytes

Contents

module Hyrax
  class ParentService
    # @param [String] the id of a child FileSet
    # @return [ActiveFedora::Base] the parent object
    def self.parent_for(id)
      ids = ordered_by_ids(id)
      ActiveFedora::Base.find(ordered_by_ids(id).first) if ids.present?
    end

    def self.ordered_by_ids(id)
      if id.present?
        ActiveFedora::SolrService.query("{!join from=proxy_in_ssi to=id}ordered_targets_ssim:#{id}")
                                 .map { |x| x["id"] }
      else
        []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
test_hyrax-0.0.1.alpha app/services/hyrax/parent_service.rb