Class: Dor::Services::Client::Milestones

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

Overview

API calls around milestones

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:) ⇒ Milestones

Returns a new instance of Milestones.

Parameters:

  • object_identifier (String)

    the druid for the object



9
10
11
12
# File 'lib/dor/services/client/milestones.rb', line 9

def initialize(connection:, version:, object_identifier:)
  super(connection: connection, version: version)
  @object_identifier = object_identifier
end

Instance Method Details

#date(milestone_name:, version: nil, active_only: false) ⇒ Time

Returns the Date for a requested milestone from workflow lifecycle

Parameters:

  • druid (String)

    object id

  • milestone_name (String)

    the name of the milestone being queried for

  • version (Number) (defaults to: nil)

    (nil) the version to query for

  • active_only (Boolean) (defaults to: false)

    (false) if true, return only lifecycle steps for versions that have all processes complete

Returns:

  • (Time)

    when the milestone was achieved. Returns nil if the milestone does not exist



21
22
23
# File 'lib/dor/services/client/milestones.rb', line 21

def date(milestone_name:, version: nil, active_only: false)
  filter_milestone(query_lifecycle(version: version, active_only: active_only), milestone_name)
end

#listArray<Hash>

Returns:

  • (Array<Hash>)


26
27
28
29
30
31
# File 'lib/dor/services/client/milestones.rb', line 26

def list
  doc = query_lifecycle(active_only: false)
  doc.xpath('//lifecycle/milestone').collect do |node|
    { milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
  end
end