Class: SdrClient::Deposit::Process

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

Overview

The process for doing a deposit

Instance Method Summary collapse

Constructor Details

#initialize(metadata:, grouping_strategy: SingleFileGroupingStrategy, connection:, files: [], accession:, logger: Logger.new(STDOUT)) ⇒ Process

rubocop:disable Metrics/ParameterLists

Parameters:

  • metadata (Request)

    information about the object

  • grouping_strategy (Class) (defaults to: SingleFileGroupingStrategy)

    class whose run method groups an array of uploads

  • connection (String)

    the server 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



17
18
19
20
21
22
23
24
25
# File 'lib/sdr_client/deposit/process.rb', line 17

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

Instance Method Details

#runString

rubocop:disable Metrics/AbcSize

Returns:

  • (String)

    job id for the background job result



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/sdr_client/deposit/process.rb', line 30

def run
  check_files_exist

   = UploadFilesMetadataBuilder.build(files: files, mime_types: mime_types)
  upload_responses = UploadFiles.upload(file_metadata: ,
                                        logger: logger,
                                        connection: connection)
   = MetadataBuilder.new(metadata: ,
                                         grouping_strategy: grouping_strategy,
                                         logger: logger)
  request = .with_uploads(upload_responses)
  model = Cocina::Models.build_request(request.as_json.with_indifferent_access)
  CreateResource.run(accession: @accession,
                     metadata: model,
                     logger: logger,
                     connection: connection)
end