Sha256: 5a2ea983ea461a5299bd2665168891d3f98b3c6a202dfd22404c5dc8d8914bc0

Contents?: true

Size: 539 Bytes

Versions: 21

Compression:

Stored size: 539 Bytes

Contents

module Hyrax
  class ParentService
    # @param [String] id - 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

21 entries across 21 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/services/hyrax/parent_service.rb
hyrax-2.0.3 app/services/hyrax/parent_service.rb
hyrax-1.1.0 app/services/hyrax/parent_service.rb
hyrax-2.0.2 app/services/hyrax/parent_service.rb
hyrax-2.0.1 app/services/hyrax/parent_service.rb
hyrax-2.0.0 app/services/hyrax/parent_service.rb
hyrax-2.0.0.rc3 app/services/hyrax/parent_service.rb
hyrax-2.0.0.rc2 app/services/hyrax/parent_service.rb
hyrax-2.0.0.rc1 app/services/hyrax/parent_service.rb
hyrax-1.0.5 app/services/hyrax/parent_service.rb
hyrax-2.0.0.beta5 app/services/hyrax/parent_service.rb
hyrax-2.0.0.beta4 app/services/hyrax/parent_service.rb
hyrax-2.0.0.beta3 app/services/hyrax/parent_service.rb
hyrax-2.0.0.beta2 app/services/hyrax/parent_service.rb
hyrax-2.0.0.beta1 app/services/hyrax/parent_service.rb
hyrax-1.0.4 app/services/hyrax/parent_service.rb
hyrax-1.0.3 app/services/hyrax/parent_service.rb
hyrax-1.0.2 app/services/hyrax/parent_service.rb
hyrax-1.0.1 app/services/hyrax/parent_service.rb
hyrax-1.0.0.rc2 app/services/hyrax/parent_service.rb