Class: LyberCore::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/lyber_core/workflow.rb

Overview

This encapsulates the workflow operations that lyber-core does

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_client:, workflow_name:, process:, version:) ⇒ Workflow

Returns a new instance of Workflow.



6
7
8
9
10
11
# File 'lib/lyber_core/workflow.rb', line 6

def initialize(object_client:, workflow_name:, process:, version:)
  @object_client = object_client
  @workflow_name = workflow_name
  @process = process
  @version = version
end

Instance Attribute Details

#object_clientObject (readonly)

Returns the value of attribute object_client.



60
61
62
# File 'lib/lyber_core/workflow.rb', line 60

def object_client
  @object_client
end

#processObject (readonly)

Returns the value of attribute process.



60
61
62
# File 'lib/lyber_core/workflow.rb', line 60

def process
  @process
end

#versionObject (readonly)

Returns the value of attribute version.



60
61
62
# File 'lib/lyber_core/workflow.rb', line 60

def version
  @version
end

#workflow_nameObject (readonly)

Returns the value of attribute workflow_name.



60
61
62
# File 'lib/lyber_core/workflow.rb', line 60

def workflow_name
  @workflow_name
end

Instance Method Details

#active_version?Boolean

Returns true if this workflow step is for the active version of the workflow.

Returns:

  • (Boolean)

    true if this workflow step is for the active version of the workflow



34
35
36
# File 'lib/lyber_core/workflow.rb', line 34

def active_version?
  workflow_response.process_for(name: process, version:).active_version?
end

#complete!(status, elapsed, note) ⇒ Object



42
43
44
# File 'lib/lyber_core/workflow.rb', line 42

def complete!(status, elapsed, note)
  workflow_process.update(status:, elapsed:, note:, version:)
end

#error!(error_msg, error_text) ⇒ Object



54
55
56
# File 'lib/lyber_core/workflow.rb', line 54

def error!(error_msg, error_text)
  workflow_process.update_error(error_msg:, error_text:, version:)
end

#object_workflowDor::Services::Client::ObjectWorkflow

Returns for druid/workflow/step on which this instance was initialized.

Returns:

  • (Dor::Services::Client::ObjectWorkflow)

    for druid/workflow/step on which this instance was initialized



14
15
16
# File 'lib/lyber_core/workflow.rb', line 14

def object_workflow
  @object_workflow ||= object_client.workflow(workflow_name)
end

#process_responseDor::Services::Response::Process

Returns for druid/workflow/step on which this instance was initialized.

Returns:

  • (Dor::Services::Response::Process)

    for druid/workflow/step on which this instance was initialized



29
30
31
# File 'lib/lyber_core/workflow.rb', line 29

def process_response
  @process_response ||= workflow_response.process_for_recent_version(name: process)
end

#retrying!Object



46
47
48
# File 'lib/lyber_core/workflow.rb', line 46

def retrying!
  workflow_process.update(status: 'retrying', elapsed: 1.0, note: nil, version:)
end

#skip!(note) ⇒ Object



50
51
52
# File 'lib/lyber_core/workflow.rb', line 50

def skip!(note)
  workflow_process.update(status: 'skipped', elapsed: 0, note:, version:)
end

#start!(note) ⇒ Object



38
39
40
# File 'lib/lyber_core/workflow.rb', line 38

def start!(note)
  workflow_process.update(status: 'started', elapsed: 1.0, note:, version:)
end

#workflow_processDor::Services::Client::Process

Returns for druid/workflow/step on which this instance was initialized.

Returns:

  • (Dor::Services::Client::Process)

    for druid/workflow/step on which this instance was initialized



19
20
21
# File 'lib/lyber_core/workflow.rb', line 19

def workflow_process
  @workflow_process ||= object_workflow.process(process)
end

#workflow_responseDor::Services::Response::Workflow

Returns for druid/workflow/step on which this instance was initialized.

Returns:

  • (Dor::Services::Response::Workflow)

    for druid/workflow/step on which this instance was initialized



24
25
26
# File 'lib/lyber_core/workflow.rb', line 24

def workflow_response
  @workflow_response ||= object_workflow.find
end