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, 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

#mappingObject

Returns the value of attribute mapping.



38
39
40
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 38

def mapping
  @mapping
end

#metadataHyrax::FileMetadata

Returns:



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

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

#parserHydra::Works::Characterization::FitsDocument

Returns:

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


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

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

#sourceValkyrie::StorageAdapter::StreamFile

Returns:

  • (Valkyrie::StorageAdapter::StreamFile)


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

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

#toolsSymbol

can be :fits, :fits_servlet, :ffprobe or any other service added to HydraFileCharacterization note that ffprope is faster but only works on AV files.

Returns:

  • (Symbol)


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.

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
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, **options)
  new(metadata: , file: file, **options).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

#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



67
68
69
70
# File 'app/services/hyrax/characterization/valkyrie_characterization_service.rb', line 67

def characterize
  terms = ((content))
  (terms)
end