Class: Dor::Workflow::Client::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/workflow/client/status.rb

Overview

reveals the status of an object based on the lifecycles

Constant Summary collapse

STATUS_CODE_DISP_TXT =

verbiage we want to use to describe an item when it has completed a particular step

{
  0 => 'Unknown Status', # if there are no milestones for the current version, someone likely messed up the versioning process.
  1 => 'Registered',
  2 => 'In accessioning',
  3 => 'In accessioning (published)',
  4 => 'In accessioning (published, deposited)',
  5 => 'Accessioned',
  6 => 'Accessioned (indexed)',
  7 => 'Accessioned (indexed, ingested)',
  8 => 'Opened'
}.freeze
STEPS =

milestones from accessioning and the order they happen in

{
  'registered' => 1,
  'submitted' => 2,
  'published' => 3,
  'deposited' => 4,
  'accessioned' => 5,
  'indexed' => 6,
  'shelved' => 7,
  'opened' => 8
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(druid:, version:, lifecycle_routes:) ⇒ Status

Returns a new instance of Status.

Parameters:

  • druid (String)

    the object identifier

  • version (String|Integer)

    the version identifier

  • lifecycle_routes (LifecycleRoutes)

    the lifecycle client



38
39
40
41
42
43
# File 'lib/dor/workflow/client/status.rb', line 38

def initialize(druid:, version:, lifecycle_routes:)
  @druid = druid
  @version = version.to_s
  @lifecycle_routes = lifecycle_routes
  @status_code, @status_time = status_from_latest_current_milestone
end

Instance Attribute Details

#status_codeObject (readonly)

Returns the value of attribute status_code.



33
34
35
# File 'lib/dor/workflow/client/status.rb', line 33

def status_code
  @status_code
end

Instance Method Details

#display(include_time: false) ⇒ String

Returns single composed status from status_info.

Parameters:

  • include_time (Boolean) (defaults to: false)

Returns:

  • (String)

    single composed status from status_info



47
48
49
50
51
52
# File 'lib/dor/workflow/client/status.rb', line 47

def display(include_time: false)
  # use the translation table to get the appropriate verbage for the latest step
  result = "v#{version} #{STATUS_CODE_DISP_TXT[status_code]}"
  result += " #{format_date(status_time)}" if include_time
  result
end

#display_simplifiedObject



54
55
56
# File 'lib/dor/workflow/client/status.rb', line 54

def display_simplified
  simplified_status_code(STATUS_CODE_DISP_TXT[status_code])
end

#milestonesObject



58
59
60
# File 'lib/dor/workflow/client/status.rb', line 58

def milestones
  @milestones ||= lifecycle_routes.milestones(druid: druid)
end