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
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) ⇒ 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) ⇒ 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.
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38 def initialize(metadata:, # rubocop:disable Metrics/ParameterLists file:, characterizer: Hydra::FileCharacterization, parser_mapping: Hydra::Works::Characterization.mapper, parser: Hydra::Works::Characterization::FitsDocument.new) @characterizer = characterizer @metadata = @source = file @mapping = parser_mapping @parser = parser @tools = :fits end |
Instance Attribute Details
#mapping ⇒ Object
Returns the value of attribute mapping.
34 35 36 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34 def mapping @mapping end |
#metadata ⇒ Hyrax::FileMetadata
34 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34 attr_accessor :mapping, :metadata, :parser, :source, :tools |
#parser ⇒ Hydra::Works::Characterization::FitsDocument
34 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34 attr_accessor :mapping, :metadata, :parser, :source, :tools |
#source ⇒ Valkyrie::StorageAdapter::StreamFile
34 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34 attr_accessor :mapping, :metadata, :parser, :source, :tools |
#tools ⇒ Symbol
clarify what this is for. it gets passed to #characterize on the characterizer, but it’s not clear how to customize effectively.
34 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34 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 |
# 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) 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
60 61 62 63 |
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 60 def characterize terms = ((content)) (terms) end |