Class: Hyrax::FileSet
- Defined in:
- app/models/hyrax/file_set.rb,
app/models/concerns/hyrax/file_set/indexing.rb,
app/models/concerns/hyrax/file_set/querying.rb,
app/models/concerns/hyrax/file_set/derivatives.rb,
app/models/concerns/hyrax/file_set/belongs_to_works.rb,
app/models/concerns/hyrax/file_set/characterization.rb
Overview
Valkyrie model for ‘FileSet` domain objects in the Hydra Works model.
## Relationships
### FileSet and Work
-
Defined: The relationship is defined by the inverse relationship stored in the work’s ‘:member_ids` attribute.
-
Tested: The test for the Work class tests the relationship.
-
FileSet to Work: (n..1) A FileSet must be in one and only one work. A Work can have zero to many FileSets.
-
See Hyrax::Work for code to get and set file sets for the work.
### FileSet and FileMetadata
-
Defined: The relationship is defined by the FileSet’s ‘:file_ids` attribute.
-
FileSet to FileMetadata: (0..n) A FileSet can have many FileMetadatas. A FileMetadata must be in one and only one FileSet.
### FileMetadata and Files
-
Defined: The relationship is defined by the FileMetadata’s ‘:file_identifier` attribute.
-
FileMetadata to File: (1..1) A FileMetadata can have one and only one File
Direct Known Subclasses
Defined Under Namespace
Modules: BelongsToWorks, Characterization, Derivatives, Indexing, Querying
Class Method Summary collapse
-
.file_set? ⇒ Boolean
True.
- .model_name(name_class: Hyrax::Name) ⇒ Object
-
.pcdm_object? ⇒ Boolean
True.
Instance Method Summary collapse
-
#extensions_and_mime_types ⇒ Array
rubocop:disable Metrics/MethodLength.
- #extracted_text ⇒ Hyrax::FileMetadata?
- #extracted_text_id ⇒ Valkyrie::ID?
-
#iiif_id ⇒ String, Nil
Versioned identifier suitable for use in a IIIF manifest.
- #original_file ⇒ Hyrax::FileMetadata?
- #original_file_id ⇒ Valkyrie::ID?
- #representative_id ⇒ Valkyrie::ID
- #thumbnail ⇒ Hyrax::FileMetadata?
- #thumbnail_id ⇒ Valkyrie::ID?
Methods inherited from Resource
#==, acts_as_flexible_resource, collection?, #collection?, #file?, file?, #file_set?, #flexible?, flexible?, human_readable_type, inherited, pcdm_collection?, #pcdm_collection?, #pcdm_object?, #permission_manager, to_rdf_representation, #to_rdf_representation, #visibility, #visibility=, #wings?, work?, #work?
Methods included from WithEmbargoesAndLeases
#embargo, #embargo=, #lease, #lease=
Methods included from WithEvents
#event_class, #events, #log_event, #stream
Class Method Details
.file_set? ⇒ Boolean
Returns true.
144 145 146 |
# File 'app/models/hyrax/file_set.rb', line 144 def self.file_set? true end |
.model_name(name_class: Hyrax::Name) ⇒ Object
57 58 59 |
# File 'app/models/hyrax/file_set.rb', line 57 def self.model_name(name_class: Hyrax::Name) @_model_name ||= name_class.new(self, nil, 'FileSet') end |
.pcdm_object? ⇒ Boolean
Returns true.
150 151 152 |
# File 'app/models/hyrax/file_set.rb', line 150 def self.pcdm_object? true end |
Instance Method Details
#extensions_and_mime_types ⇒ Array
rubocop:disable Metrics/MethodLength
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'app/models/hyrax/file_set.rb', line 117 def extensions_and_mime_types return [] if file_ids.empty? Hyrax.custom_queries.find_files(file_set: self).each_with_object([]) do |fm, arr| next unless fm.original_filename extension = File.extname(fm.original_filename) next if extension.empty? use = fm.filtered_pcdm_use.first.to_s.split("#").last name = use == 'OriginalFile' ? nil : File.basename(fm.original_filename, extension).split('-').last arr << { id: fm.id.to_s, extension: extension[1..], # remove leading '.' mime_type: fm.mime_type, name: name, use: use } end # rubocop:enable Metrics/MethodLength end |
#extracted_text ⇒ Hyrax::FileMetadata?
100 101 102 103 104 |
# File 'app/models/hyrax/file_set.rb', line 100 def extracted_text Hyrax.custom_queries.find_extracted_text(file_set: self) rescue Valkyrie::Persistence::ObjectNotFoundError nil end |
#extracted_text_id ⇒ Valkyrie::ID?
107 108 109 |
# File 'app/models/hyrax/file_set.rb', line 107 def extracted_text_id extracted_text&.id end |
#iiif_id ⇒ String, Nil
Returns versioned identifier suitable for use in a IIIF manifest.
79 80 81 82 83 84 85 |
# File 'app/models/hyrax/file_set.rb', line 79 def iiif_id orig_file = original_file return nil if orig_file.nil? || orig_file.file_identifier.blank? latest_file = Hyrax::VersioningService.latest_version_of(orig_file) version = latest_file&.version_id ? Digest::MD5.hexdigest(latest_file.version_id) : nil "#{id}/files/#{orig_file.id}#{'/' + version if version}" end |
#original_file ⇒ Hyrax::FileMetadata?
67 68 69 70 71 |
# File 'app/models/hyrax/file_set.rb', line 67 def original_file Hyrax.custom_queries.find_original_file(file_set: self) rescue Valkyrie::Persistence::ObjectNotFoundError nil end |
#original_file_id ⇒ Valkyrie::ID?
74 75 76 |
# File 'app/models/hyrax/file_set.rb', line 74 def original_file_id original_file&.id end |
#representative_id ⇒ Valkyrie::ID
138 139 140 |
# File 'app/models/hyrax/file_set.rb', line 138 def representative_id id end |
#thumbnail ⇒ Hyrax::FileMetadata?
88 89 90 91 92 |
# File 'app/models/hyrax/file_set.rb', line 88 def thumbnail Hyrax.custom_queries.find_thumbnail(file_set: self) rescue Valkyrie::Persistence::ObjectNotFoundError nil end |
#thumbnail_id ⇒ Valkyrie::ID?
95 96 97 |
# File 'app/models/hyrax/file_set.rb', line 95 def thumbnail_id thumbnail&.id end |