Class: Hyrax::Characterization::ValkyrieCharacterizationService
- Inherits:
-
Object
- Object
- Hyrax::Characterization::ValkyrieCharacterizationService
- Defined in:
- app/services/hyrax/characterization/valkyrie_characterization_service.rb
Instance Attribute Summary collapse
-
#mapping ⇒ Object
Returns the value of attribute mapping.
- #metadata ⇒ Hyrax::FileMetadata
- #parser ⇒ Hydra::Works::Characterization::FitsDocument
- #source ⇒ Valkyrie::StorageAdapter::StreamFile
-
#tools ⇒ Symbol
can be :fits, :fits_servlet, :ffprobe or any other service added to HydraFileCharacterization note that ffprope is faster but only works on AV files.
Class Method Summary collapse
Instance Method Summary collapse
-
#characterize ⇒ void
private
Coerce given source into a type that can be passed to Hydra::FileCharacterization Use Hydra::FileCharacterization to extract metadata (an OM XML document) Get the terms (and their values) from the extracted metadata Assign the values of the terms to the properties of the metadata object.
-
#initialize(metadata:, file:, characterizer: Hydra::FileCharacterization, parser_mapping: Hydra::Works::Characterization.mapper, parser: Hydra::Works::Characterization::FitsDocument.new, ch12n_tool: :fits) ⇒ ValkyrieCharacterizationService
constructor
private
A new instance of ValkyrieCharacterizationService.
Constructor Details
#initialize(metadata:, file:, characterizer: Hydra::FileCharacterization, parser_mapping: Hydra::Works::Characterization.mapper, parser: Hydra::Works::Characterization::FitsDocument.new, ch12n_tool: :fits) ⇒ ValkyrieCharacterizationService
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ValkyrieCharacterizationService.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 42 def initialize( # rubocop:disable Metrics/ParameterLists metadata:, file:, characterizer: Hydra::FileCharacterization, parser_mapping: Hydra::Works::Characterization.mapper, parser: Hydra::Works::Characterization::FitsDocument.new, ch12n_tool: :fits ) @characterizer = characterizer @metadata = @source = file @mapping = parser_mapping @parser = parser @tools = ch12n_tool end |
Instance Attribute Details
#mapping ⇒ Object
Returns the value of attribute mapping.
38 39 40 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38 def mapping @mapping end |
#metadata ⇒ Hyrax::FileMetadata
38 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38 attr_accessor :mapping, :metadata, :parser, :source, :tools |
#parser ⇒ Hydra::Works::Characterization::FitsDocument
38 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38 attr_accessor :mapping, :metadata, :parser, :source, :tools |
#source ⇒ Valkyrie::StorageAdapter::StreamFile
38 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38 attr_accessor :mapping, :metadata, :parser, :source, :tools |
#tools ⇒ Symbol
can be :fits, :fits_servlet, :ffprobe or any other service added to HydraFileCharacterization note that ffprope is faster but only works on AV files.
38 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38 attr_accessor :mapping, :metadata, :parser, :source, :tools |
Class Method Details
.run(metadata:, file:, user: ::User.system_user, **options) ⇒ void
This method returns an undefined value.
14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 14 def self.run(metadata:, file:, user: ::User.system_user, **) new(metadata: , file: file, **).characterize saved = Hyrax.persister.save(resource: ) Hyrax.publisher.publish('file.metadata.updated', metadata: saved, user: user) Hyrax.publisher.publish('file.characterized', file_set: Hyrax.query_service.find_by(id: saved.file_set_id), file_id: saved.id.to_s, path_hint: saved.file_identifier.to_s) end |
Instance Method Details
#characterize ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Coerce given source into a type that can be passed to Hydra::FileCharacterization Use Hydra::FileCharacterization to extract metadata (an OM XML document) Get the terms (and their values) from the extracted metadata Assign the values of the terms to the properties of the metadata object
67 68 69 70 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 67 def characterize terms = ((content)) (terms) end |