Sha256: 7fd6458a7a1800c0557407f73aa6c2b42683e9b8ff85c61cdb07c0b39092dc93

Contents?: true

Size: 1.07 KB

Versions: 10

Compression:

Stored size: 1.07 KB

Contents

module Hyrax
  module WithFileSets
    extend ActiveSupport::Concern

    included do
      # The file_sets association and its accessor methods comes from Hydra::Works::AggregatesFileSets
      before_destroy :cleanup_file_sets
    end

    # Stopgap unil ActiveFedora ContainerAssociation includes an *_ids accessor.
    # At the moment, this is no more efficient than calling file_sets, but hopefully that will change in the future.
    def file_set_ids
      file_sets.map(&:id)
    end

    def cleanup_file_sets
      # Destroy the list source first.  This prevents each file_set from attemping to
      # remove itself individually from the work. If hundreds of files are attached,
      # this would take too long.

      # Get list of member file_sets from Solr
      fs = file_sets
      list_source.destroy
      # Remove Work from Solr after it was removed from Fedora
      ActiveFedora::SolrService.delete(id)
      fs.each(&:destroy)
    end

    def copy_visibility_to_files
      file_sets.each do |fs|
        fs.visibility = visibility
        fs.save!
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.1.0 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.5 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.4 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.3 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.2 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.1 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.0.rc2 app/models/concerns/hyrax/with_file_sets.rb
hyrax-1.0.0.rc1 app/models/concerns/hyrax/with_file_sets.rb
test_hyrax-0.0.1.alpha app/models/concerns/hyrax/with_file_sets.rb