Class: Hyrax::FileSet
- Inherits:
-
Resource
- Object
- Resource
- Hyrax::FileSet
show all
- 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/transcripts.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.
- 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.
- 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
Defined Under Namespace
Modules: BelongsToWorks, Characterization, Derivatives, Indexing, Querying, Transcripts
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.file_set? ⇒ Boolean
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
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..], mime_type: fm.mime_type,
name: name,
use: use
}
end
end
|
100
101
102
103
104
|
# File 'app/models/hyrax/file_set.rb', line 100
def
Hyrax.custom_queries.(file_set: self)
rescue Valkyrie::Persistence::ObjectNotFoundError
nil
end
|
107
108
109
|
# File 'app/models/hyrax/file_set.rb', line 107
def
&.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
|
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
|
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
|