class ActiveFedora::Aggregation::ListSource

Attributes

ordered_self[W]

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

graph should contain.

Public Instance Methods

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

@deprecated use changes_applied instead

# File lib/active_fedora/aggregation/list_source.rb, line 17
def clear_changed_attributes
  Deprecation.warn self.class, "#clear_changed_attributes is deprecated, use ActiveModel::Dirty#changes_applied instead."

  clear_changes_information
end
create_date() click to toggle source

Not useful and slows down indexing.

# File lib/active_fedora/aggregation/list_source.rb, line 52
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 62
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 57
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 29
def ordered_self
  @ordered_self ||= ordered_list_factory.new(resource, head_subject, tail_subject)
end
save(*args) click to toggle source
Calls superclass method ActiveFedora::Validations#save
# 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/samvera/active_fedora/blob/master/lib/active_fedora/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 ActiveFedora::Indexing#to_solr
# 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 91
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 95
def head_subject
  head_id.first
end
ordered_list_factory() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 103
def ordered_list_factory
  ActiveFedora::Orders::OrderedList
end
persist_ordered_self() click to toggle source
# File lib/active_fedora/aggregation/list_source.rb, line 68
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
  head_will_change!
  tail_will_change!
  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.
  # See https://github.com/samvera/active_fedora/issues/1337
  resource.set_value(:nodes, [])
  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 99
def tail_subject
  tail_id.first
end