Sha256: 115712ca41def0a6fc59e8c3e6e30ea6377f8f3c9f379373704cb8f47a310d54

Contents?: true

Size: 522 Bytes

Versions: 2

Compression:

Stored size: 522 Bytes

Contents

module CurationConcerns
  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

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-0.5.0 app/services/curation_concerns/parent_service.rb
curation_concerns-0.4.0 app/services/curation_concerns/parent_service.rb