Sha256: 8208316bd551fc8a2e18c8c7ace0609613a77b716b18212e84676ef94bff7c27

Contents?: true

Size: 891 Bytes

Versions: 10

Compression:

Stored size: 891 Bytes

Contents

# This module is mixed into classes that declare 'aggregates ...'
#
module ActiveFedora::Aggregation
  module AggregationExtension
    extend ActiveSupport::Concern
    include PersistLinks

    included do
      after_destroy :remove_aggregation_proxies_from_solr

      # Doesn't use after_save because we need this callback to come after the autosave callback
      after_create :persist_aggregation_links
      after_update :persist_aggregation_links
    end

    private

      # The proxies, being nested under the object, are automatically destroyed
      # this cleans up their records from solr.
      def remove_aggregation_proxies_from_solr
        query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(proxyIn: id, has_model: Proxy.to_class_uri)
        ActiveFedora::SolrService.instance.conn.delete_by_query(query, params: {'softCommit' => true})
      end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
activefedora-aggregation-0.9.0 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.8.1 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.8.0 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.7.0 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.6.0 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.5.0 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.4.2 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.4.1 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.4.0 lib/active_fedora/aggregation/aggregation_extension.rb
activefedora-aggregation-0.3.0 lib/active_fedora/aggregation/aggregation_extension.rb