Sha256: e4babc8d6a96a202e38cef569710382e4827fe8ba3731380bae513929323c6d7

Contents?: true

Size: 945 Bytes

Versions: 19

Compression:

Stored size: 945 Bytes

Contents

#
# An Item is a  member of a Collection -- i.e., a "work" -- the principal describable resource.
#
# Examples: photograph, book, article, sound recording, video, etc.
#
class Item < Ddr::Models::Base

  include Ddr::Models::HasChildren
  include Ddr::Models::HasStructMetadata

  has_many :children,
           predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf,
           class_name: "Component",
           as: :parent

  belongs_to :parent,
             predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isMemberOfCollection,
             class_name: "Collection"

  def publishable?
    parent.present? && parent.published?
  end

  def children_having_extracted_text
    item = self
    Ddr::Index::Query.new do
      is_part_of item
      where attached_files_having_content: "extractedText"
      fields :id, :extracted_text
    end
  end

  def all_text
    children_having_extracted_text.docs.map(&:extracted_text).flatten
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ddr-models-3.0.8 app/models/item.rb
ddr-models-3.0.7 app/models/item.rb
ddr-models-3.0.6 app/models/item.rb
ddr-models-3.0.5 app/models/item.rb
ddr-models-3.0.4 app/models/item.rb
ddr-models-3.0.3 app/models/item.rb
ddr-models-3.0.2 app/models/item.rb
ddr-models-3.0.1 app/models/item.rb
ddr-models-3.0.0 app/models/item.rb
ddr-models-3.0.0.rc6 app/models/item.rb
ddr-models-3.0.0.rc5 app/models/item.rb
ddr-models-3.0.0.rc4 app/models/item.rb
ddr-models-3.0.0.rc3 app/models/item.rb
ddr-models-3.0.0.rc2 app/models/item.rb
ddr-models-3.0.0.rc1 app/models/item.rb
ddr-models-3.0.0.beta.22 app/models/item.rb
ddr-models-3.0.0.beta.21 app/models/item.rb
ddr-models-3.0.0.beta.20 app/models/item.rb
ddr-models-3.0.0.beta.18 app/models/item.rb