Sha256: 3037f20ba0de79efe93b4f0710c8ad3bae3a977bd3a62586d88e5fc22bf20690

Contents?: true

Size: 1.11 KB

Versions: 61

Compression:

Stored size: 1.11 KB

Contents

# Copied from Curate
module CurationConcerns
  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

61 entries across 61 versions & 2 rubygems

Version Path
curation_concerns-1.7.8 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.7 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-2.0.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-2.0.0.rc2 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.6 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.5 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.4 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.3 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.2 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-2.0.0.rc1 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.1 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.7.0.beta1 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.6.3 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.6.2 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.6.1 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.6.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.5.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.4.0 app/models/concerns/curation_concerns/with_file_sets.rb
curation_concerns-1.3.3 app/models/concerns/curation_concerns/with_file_sets.rb