Sha256: 900aadf89dd410d439a3cc55429340eb2080dbd99794c942bbfca87df353392f

Contents?: true

Size: 526 Bytes

Versions: 2

Compression:

Stored size: 526 Bytes

Contents

module CurationConcerns
  class ParentService
    # @param [String] the id of a child GenericFile
    # @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

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-0.3.0 app/services/curation_concerns/parent_service.rb
curation_concerns-0.2.0 app/services/curation_concerns/parent_service.rb