Class: Dor::Services::Client::Process

Inherits:
VersionedService show all
Defined in:
lib/dor/services/client/process.rb

Overview

API calls around workflow process for an object.

Constant Summary

Constants inherited from VersionedService

VersionedService::EXCEPTION_CLASS, VersionedService::JSON_API_MIME_TYPE

Instance Method Summary collapse

Methods inherited from VersionedService

#async_result

Constructor Details

#initialize(connection:, version:, object_identifier:, workflow_name:, process:, object_workflow_client:) ⇒ Process



11
12
13
14
15
16
17
# File 'lib/dor/services/client/process.rb', line 11

def initialize(connection:, version:, object_identifier:, workflow_name:, process:, object_workflow_client:) # rubocop:disable Metrics/ParameterLists
  super(connection: connection, version: version)
  @object_identifier = object_identifier
  @workflow_name = workflow_name
  @process = process
  @object_workflow_client = object_workflow_client
end

Instance Method Details

#statusString?

Retrieves the process status of the given workflow for the given object identifier



21
22
23
24
25
26
27
# File 'lib/dor/services/client/process.rb', line 21

def status
  doc = object_workflow_client.find.xml

  processes = doc.root.xpath("//process[@name='#{process}']")
  process = processes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
  process&.attr('status')
end

#update(status:, elapsed: 0, lifecycle: nil, note: nil, current_status: nil) ⇒ Object

Updates the status of one step in a workflow.

Raises:



36
37
38
# File 'lib/dor/services/client/process.rb', line 36

def update(status:, elapsed: 0, lifecycle: nil, note: nil, current_status: nil)
  perform_update(status: status, elapsed: elapsed, lifecycle: lifecycle, note: note, current_status: current_status)
end

#update_error(error_msg:, error_text: nil) ⇒ Object

Updates the status of one step in a workflow to error.



43
44
45
# File 'lib/dor/services/client/process.rb', line 43

def update_error(error_msg:, error_text: nil)
  perform_update(status: 'error', error_msg: error_msg, error_text: error_text)
end