Class: Hyrax::Characterization::ValkyrieCharacterizationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/characterization/valkyrie_characterization_service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#mappingObject

Returns the value of attribute mapping.



34
35
36
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34

def mapping
  @mapping
end

#metadataHyrax::FileMetadata

Returns:



34
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34

attr_accessor :mapping, :metadata, :parser, :source, :tools

#parserHydra::Works::Characterization::FitsDocument

Returns:

  • (Hydra::Works::Characterization::FitsDocument)


34
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34

attr_accessor :mapping, :metadata, :parser, :source, :tools

#sourceValkyrie::StorageAdapter::StreamFile

Returns:

  • (Valkyrie::StorageAdapter::StreamFile)


34
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 34

attr_accessor :mapping, :metadata, :parser, :source, :tools

#toolsSymbol

TODO:

clarify what this is for. it gets passed to #characterize on the characterizer, but it’s not clear how to customize effectively.

Returns:

  • (Symbol)


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.

Parameters:

  • metadata (Hyrax::FileMetadata)

    which has properties to recieve characterization values

  • source (Valkyrie::StorageAdapter::StreamFile)

    to run characterization against

  • options (Hash)

    the options pass to characterization

Options Hash (**options):

  • parser_mapping (Hash{Symbol => Symbol})
  • parser (Hydra::Works::Characterization::FitsDocument)
  • ch12n_tool (Symbol)


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, **options)
  new(metadata: , file: file, **options).characterize
  saved = Hyrax.persister.save(resource: )
  Hyrax.publisher.publish('file.metadata.updated', metadata: saved, user: user)
end

Instance Method Details

#characterizevoid

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