module Ddr class Item < Resource include HasChildren include HasParent include HasStructMetadata alias_method :collection_id, :parent_id alias_method :collection, :parent alias_method :components, :children self.parent_class = Ddr::Collection ### DDRevo ##################### # TODO: We may want to revisit this alternate implementation once ddr-core is more fully baked # or it may be fine just as it is ### DDRevo ##################### def children_having_extracted_text # Ddr::Index::Query.build(self) do |item| # is_part_of item # where attached_files_having_content: "extractedText" # fields :id, :extracted_text # end children.select { |child| child.attached_files_having_content.include?(:extracted_text) } end ### DDRevo ##################### # TODO: We may want to revisit this alternate implementation once ddr-core is more fully baked # or it may be fine just as it is ### DDRevo ##################### def all_text # children_having_extracted_text.docs.map(&:extracted_text).flatten children_having_extracted_text.map { |child| child.extracted_text.content }.to_a.flatten end end end