Module: IiifPrint::LineageService
- Defined in:
- lib/iiif_print/lineage_service.rb
Overview
The purpose of this module is to encode lineage related services:
The ancestor and descendent_file_sets are useful for ensuring we index together related items. For example, when I have a work that is a book, and one file set per page of that book, when I search the book I want to find the text within the given book’s pages.
The methods of this module should be considered as defining an interface.
Class Method Summary collapse
- .ancestor_ids_for(object) ⇒ Array<String>
-
.ancestry_identifier_for(work) ⇒ String
Given the :work return it’s identifier.
-
.descendent_member_ids_for(object) ⇒ Array<String>
(also: descendent_file_set_ids_for)
github.com/samvera/hyrax/blob/2b807fe101176d594129ef8a8fe466d3d03a372b/app/indexers/hyrax/work_indexer.rb#L15-L18 for “clarification” of the comingling of file_set_ids and member_ids.
Class Method Details
.ancestor_ids_for(object) ⇒ Array<String>
18 19 20 21 22 23 24 25 |
# File 'lib/iiif_print/lineage_service.rb', line 18 def self.ancestor_ids_for(object) ancestor_ids ||= [] object.in_works.each do |work| ancestor_ids << ancestry_identifier_for(work) ancestor_ids += ancestor_ids_for(work) if work.is_child end ancestor_ids.flatten.compact.uniq end |
.ancestry_identifier_for(work) ⇒ String
Given the :work return it’s identifier
34 35 36 |
# File 'lib/iiif_print/lineage_service.rb', line 34 def self.ancestry_identifier_for(work) IiifPrint.config.ancestory_identifier_function.call(work) end |
.descendent_member_ids_for(object) ⇒ Array<String> Also known as: descendent_file_set_ids_for
github.com/samvera/hyrax/blob/2b807fe101176d594129ef8a8fe466d3d03a372b/app/indexers/hyrax/work_indexer.rb#L15-L18 for “clarification” of the comingling of file_set_ids and member_ids
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/iiif_print/lineage_service.rb', line 45 def self.descendent_member_ids_for(object) # enables us to return parents when searching for child OCR # # https://github.com/samvera/hydra-works/blob/c9b9dd0cf11de671920ba0a7161db68ccf9b7f6d/lib/hydra/works/models/concerns/work_behavior.rb#L90-L92 # # The Hydara::Works implementation of file_set_ids is "members.select(&:file_set?).map(&:id)"; # so no sense doing `object.file_set_ids + object.member_ids` file_set_ids = object.member_ids object.ordered_works&.each do |child| file_set_ids += descendent_member_ids_for(child) end file_set_ids.flatten.uniq.compact end |