Class: SdrClient::Deposit::ModelProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/deposit/model_process.rb

Overview

The process for doing a deposit from a Cocina Model

Instance Method Summary collapse

Constructor Details

#initialize(request_dro:, connection:, files: [], accession:, logger: Logger.new(STDOUT)) ⇒ ModelProcess

Returns a new instance of ModelProcess.

Parameters:

  • request_dro (Cocina::Model::RequestDRO)

    for depositing

  • connection (Connection)

    the connection to use

  • files (Array<String>) (defaults to: [])

    a list of file names to upload

  • accession (Boolean)

    should the accessionWF be started

  • logger (Logger) (defaults to: Logger.new(STDOUT))

    the logger to use



14
15
16
17
18
19
20
21
# File 'lib/sdr_client/deposit/model_process.rb', line 14

def initialize(request_dro:, connection:,
               files: [], accession:, logger: Logger.new(STDOUT))
  @files = files
  @connection = connection
  @request_dro = request_dro
  @logger = logger
  @accession = accession
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sdr_client/deposit/model_process.rb', line 23

def run
  check_files_exist
  child_files_match

   = UploadFilesMetadataBuilder.build(files: files, mime_types: mime_types)
  upload_responses = UploadFiles.upload(file_metadata: ,
                                        logger: logger,
                                        connection: connection)
  new_request_dro = UpdateDroWithFileIdentifiers.update(request_dro: request_dro, upload_responses: upload_responses)
  CreateResource.run(accession: @accession,
                     metadata: new_request_dro,
                     logger: logger,
                     connection: connection)
end