Sha256: df8222ce8ece566a0eeeb09468ee959e3fe822ec867dc095c660d6b77a96dcdd

Contents?: true

Size: 1.5 KB

Versions: 34

Compression:

Stored size: 1.5 KB

Contents

module Hyrax
  module Collections
    module NestedCollectionPersistenceService
      # @api public
      #
      # Responsible for persisting the relationship between the parent and the child.
      # @see Hyrax::Collections::NestedCollectionQueryService
      #
      # @param parent [Collection]
      # @param child [Collection]
      # @note There is odd permission arrangement based on the NestedCollectionQueryService:
      #       You can nest the child within a parent if you can edit the parent and read the child.
      #       See https://wiki.duraspace.org/display/samvera/Samvera+Tech+Call+2017-08-23 for tech discussion.
      # @note Adding the member_of_collections method doesn't trigger reindexing of the child so we have to do it manually.
      #       However it save and reindexes the parent unnecessarily!!
      def self.persist_nested_collection_for(parent:, child:)
        parent.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
        child.member_of_collections.push(parent)
        child.update_nested_collection_relationship_indices
      end

      # @note Removing the member_of_collections method doesn't trigger reindexing of the child so we have to do it manually.
      #       However it doesn't save and reindex the parent, as it does when a parent is added!!
      def self.remove_nested_relationship_for(parent:, child:)
        child.member_of_collections.delete(parent)
        child.update_nested_collection_relationship_indices
        true
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.9.5 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.9.4 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.9.3 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.9.2 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.9.1 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.9.0 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.8.0 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.7.2 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.7.1 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.7.0 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.6.0 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-3.0.0.pre.rc1 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-3.0.0.pre.beta3 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.5.1 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.5.0 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-3.0.0.pre.beta2 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.4.1 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-3.0.0.pre.beta1 app/services/hyrax/collections/nested_collection_persistence_service.rb
hyrax-2.4.0 app/services/hyrax/collections/nested_collection_persistence_service.rb