Sha256: 33c932952d12c537483fb28460a834b7cc71a4f15a4688a5fca0fb9802104d86

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

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

  has_many :children, property: :is_part_of, class_name: 'Component'
  belongs_to :parent, property: :is_member_of_collection, class_name: 'Collection'

  alias_method :components, :children
  alias_method :component_ids, :child_ids

  alias_method :parts, :children
  alias_method :part_ids, :child_ids

  alias_method :collection, :parent
  alias_method :collection_id, :parent_id
  alias_method :collection=, :parent=

  def children_by_file_use
    file_uses = {}
    sort_key = "#{Ddr::IndexFields::FILE_USE} ASC, #{Ddr::IndexFields::ORDER} ASC"
    results = ActiveFedora::SolrService.query(association_query(:children), rows: 999999, sort: sort_key)
    objs = ActiveFedora::SolrService.lazy_reify_solr_results(results)
    objs.each do |obj|
      file_uses[obj.file_use] ||= []
      file_uses[obj.file_use] << obj
    end
    file_uses
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ddr-models-1.17.1 app/models/item.rb
ddr-models-1.17.0 app/models/item.rb
ddr-models-1.16.2 app/models/item.rb
ddr-models-2.0.0.pre.1 app/models/item.rb
ddr-models-1.16.1 app/models/item.rb
ddr-models-1.16.0 app/models/item.rb
ddr-models-1.15.0 app/models/item.rb
ddr-models-1.14.2 app/models/item.rb
ddr-models-1.14.1 app/models/item.rb
ddr-models-1.14.0 app/models/item.rb