Class: Hyrax::ParentService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/parent_service.rb

Class Method Summary collapse

Class Method Details

.ordered_by_ids(id) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/services/hyrax/parent_service.rb', line 10

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

.parent_for(id) ⇒ ActiveFedora::Base

Returns the parent object.

Parameters:

  • id (String)
    • the id of a child FileSet

Returns:

  • (ActiveFedora::Base)

    the parent object



5
6
7
8
# File 'app/services/hyrax/parent_service.rb', line 5

def self.parent_for(id)
  ids = ordered_by_ids(id)
  ActiveFedora::Base.find(ordered_by_ids(id).first) if ids.present?
end