class ActiveFedora::Aggregation::ListSource

Public Instance Methods

changed?() click to toggle source
Calls superclass method
# File lib/active_fedora/aggregation/list_source.rb, line 21
def changed?
  super || ordered_self.changed?
end
clear_changed_attributes() click to toggle source

Overriding so that we don’t track previously_changed, which was rather expensive.

# File lib/active_fedora/aggregation/list_source.rb, line 17
def clear_changed_attributes
  @changed_attributes.clear
end
create_date() click to toggle source

Not useful and slows down indexing.

# File lib/active_fedora/aggregation/list_source.rb, line 54
def create_date
  nil
end
has_model() click to toggle source

Not useful, slows down indexing.

# File lib/active_fedora/aggregation/list_source.rb, line 64
def has_model
  ["ActiveFedora::Aggregation::ListSource"]
end
modified_date() click to toggle source

Not useful, slows down indexing.

# File lib/active_fedora/aggregation/list_source.rb, line 59
def modified_date
  nil
end
ordered_self() click to toggle source

Ordered list representation of proxies in graph. @return [Array<ListNode>]

# File lib/active_fedora/aggregation/list_source.rb, line 27
def ordered_self
  @ordered_self ||= ordered_list_factory.new(resource, head_subject, tail_subject)
end
ordered_self=(new_ordered_self) click to toggle source

Allow this to be set so that -=, += will work. @param [ActiveFedora::Orders::OrderedList] An ordered list object this

graph should contain.
# File lib/active_fedora/aggregation/list_source.rb, line 34
def ordered_self=(new_ordered_self)
  @ordered_self = new_ordered_self
end
save(*args) click to toggle source
Calls superclass method
# File lib/active_fedora/aggregation/list_source.rb, line 9
def save(*args)
  return true if has_unpersisted_proxy_for? || !changed?
  persist_ordered_self if ordered_self.changed?
  super
end
serializable_hash(options=nil) click to toggle source

Serializing head/tail/nodes slows things down CONSIDERABLY, and is not useful. @note This method is used by ActiveFedora::Base upstream for indexing,

at https://github.com/projecthydra/active_fedora/blob/master/lib/active_fedora/profile_indexing_service.rb.
# File lib/active_fedora/aggregation/list_source.rb, line 42
def serializable_hash(options=nil)
  {}
end
to_solr(solr_doc={}) click to toggle source
Calls superclass method
# File lib/active_fedora/aggregation/list_source.rb, line 46
def to_solr(solr_doc={})
  super.merge({
    ordered_targets_ssim: ordered_self.target_ids,
    proxy_in_ssi: ordered_self.proxy_in.to_s
  })
end

Private Instance Methods

has_unpersisted_proxy_for?() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 90
def has_unpersisted_proxy_for?
  ordered_self.select(&:new_record?).map(&:target).find{|x| x.respond_to?(:uri)}
end
head_subject() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 94
def head_subject
  head_id.first
end
ordered_list_factory() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 102
def ordered_list_factory
  ActiveFedora::Orders::OrderedList
end
persist_ordered_self() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 70
def persist_ordered_self
  nodes_will_change!
  # Delete old statements
  subj = resource.subjects.to_a.select{|x| x.to_s.split("/").last.to_s.include?("#g")}
  subj.each do |s|
    resource.delete [s, nil, nil]
  end
  # Assert head and tail
  self.head = ordered_self.head.next.rdf_subject
  self.tail = ordered_self.tail.prev.rdf_subject
  graph = ordered_self.to_graph
  resource << graph
  # Set node subjects to a term in AF JUST so that AF will persist the
  # sub-graphs.
  # TODO: Find a way to fix this.
  self.nodes = nil
  self.nodes += graph.subjects.to_a
  ordered_self.changes_committed!
end
tail_subject() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 98
def tail_subject
  tail_id.first
end