Class: Wings::FileMetadataBuilder Deprecated

Inherits:
Object
  • Object
show all
Includes:
Hyrax::Noid
Defined in:
lib/wings/services/file_metadata_builder.rb

Overview

Deprecated.

use ‘Hyrax.storage_adapter` instead

Stores a file and an associated Hyrax::FileMetadata

Defined Under Namespace

Classes: IoDecorator

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hyrax::Noid

#assign_id

Constructor Details

#initialize(storage_adapter:, persister:) ⇒ FileMetadataBuilder

Returns a new instance of FileMetadataBuilder.



11
12
13
14
15
# File 'lib/wings/services/file_metadata_builder.rb', line 11

def initialize(storage_adapter:, persister:)
  Deprecation.warn('This class is deprecated; use Wings::Valkyrie::Storage instead.')
  @storage_adapter = storage_adapter
  @persister = persister
end

Instance Attribute Details

#persisterObject (readonly)

Returns the value of attribute persister.



10
11
12
# File 'lib/wings/services/file_metadata_builder.rb', line 10

def persister
  @persister
end

#storage_adapterObject (readonly)

Returns the value of attribute storage_adapter.



10
11
12
# File 'lib/wings/services/file_metadata_builder.rb', line 10

def storage_adapter
  @storage_adapter
end

Instance Method Details

#attach_file_metadata(file_metadata:, file_set:) ⇒ Hyrax::FileMetadata

Returns the persisted metadata file_metadata that represents the file.

Parameters:

  • file_metadata (Hyrax::FileMetadata)

    the metadata to represent the file

  • file_set (Valkyrie::Resouce, Hydra::Works::FileSet)

    the associated FileSet # TODO: WINGS - Remove Hydra::Works::FileSet as a potential type when valkyrization is complete.

Returns:



40
41
42
# File 'lib/wings/services/file_metadata_builder.rb', line 40

def (file_metadata:, file_set:)
  file_set.is_a?(::Valkyrie::Resource) ? (, file_set) : 
end

#create(io_wrapper:, file_metadata:, file_set:) ⇒ Hyrax::FileMetadata

Deprecated.

use ‘Hyrax.storage_adapter` instead

Returns the persisted metadata file_metadata that represents the file.

Parameters:

  • io_wrapper (JobIOWrapper)

    with details about the uploaded file

  • file_metadata (Hyrax::FileMetadata)

    the metadata to represent the file

  • file_set (Valkyrie::Resouce, Hydra::Works::FileSet)

    the associated FileSet # TODO: WINGS - Remove Hydra::Works::FileSet as a potential type when valkyrization is complete.

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/wings/services/file_metadata_builder.rb', line 23

def create(io_wrapper:, file_metadata:, file_set:)
  Deprecation.warn('Use storage_adapter.upload, Fedora creates a `FileMetadata` (describedBy) implictly. ' \
                   'Query it with Hyrax.custom_queries.find_file_metadata_by(id: stored_file.id).')
  io_wrapper = build_file(io_wrapper, .type)
  stored_file = storage_adapter.upload(file: io_wrapper,
                                       original_filename: io_wrapper.original_filename,
                                       content_type: io_wrapper.content_type,
                                       resource: file_set,
                                       use: Array(.type).first,
                                       id_hint: assign_id)

  Hyrax.custom_queries.(id: stored_file.id)
end