dor-workflow-client 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dor/workflow/client/lifecycle_routes.rb +17 -13
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/workflow_template.rb +9 -0
- data/spec/workflow/client/lifecycle_routes_spec.rb +20 -0
- data/spec/workflow/client/workflow_template_spec.rb +12 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 103d448136015a1fcfe0742a1804ac0d883106071ca53472ccf8e0671b158e11
|
4
|
+
data.tar.gz: b94093ac940a33c03dca26685ef808322d07f1430b61769414aabfbb6203587f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b52575766b05e2645d800203e18e6f2ffe2929be1de46b00c31b36712246280ae35332102d4675e642e74dbc8076f675df9a2fdc7d9f547c599cad4ee50134
|
7
|
+
data.tar.gz: 55279fcdcb43e241a3f368290b2d86c896956a7962a2bb2506c8b01f02533c5b6690545a7de675865d1323d58a03d34e928dc758c61dd8733727c04e2d2b4ed0
|
@@ -14,10 +14,11 @@ module Dor
|
|
14
14
|
# @param [String] druid object id
|
15
15
|
# @param [String] milestone_name the name of the milestone being queried for
|
16
16
|
# @param [Number] version the version to query for
|
17
|
+
# @param [Boolean] active_only (false) if true, return only lifecycle steps for versions that have all processes complete
|
17
18
|
# @return [Time] when the milestone was achieved. Returns nil if the milestone does not exist
|
18
19
|
#
|
19
|
-
def lifecycle(repo, druid, milestone_name, version: nil)
|
20
|
-
filter_milestone(query_lifecycle(repo, druid, version: version), milestone_name)
|
20
|
+
def lifecycle(repo, druid, milestone_name, version: nil, active_only: false)
|
21
|
+
filter_milestone(query_lifecycle(repo, druid, version: version, active_only: active_only), milestone_name)
|
21
22
|
end
|
22
23
|
|
23
24
|
# Returns the Date for a requested milestone ONLY for the current version.
|
@@ -26,15 +27,16 @@ module Dor
|
|
26
27
|
# @param [String] repo repository name
|
27
28
|
# @param [String] druid object id
|
28
29
|
# @param [String] milestone_name the name of the milestone being queried for
|
30
|
+
# @param [Number] version the version to query for
|
29
31
|
# @return [Time] when the milestone was achieved. Returns nil if the milestone does not exis
|
30
32
|
#
|
31
|
-
def active_lifecycle(repo, druid, milestone_name)
|
32
|
-
|
33
|
+
def active_lifecycle(repo, druid, milestone_name, version: nil)
|
34
|
+
lifecycle(repo, druid, milestone_name, version: version, active_only: true)
|
33
35
|
end
|
34
36
|
|
35
37
|
# @return [Hash]
|
36
38
|
def milestones(repo, druid)
|
37
|
-
doc = query_lifecycle(repo, druid)
|
39
|
+
doc = query_lifecycle(repo, druid, active_only: false)
|
38
40
|
doc.xpath('//lifecycle/milestone').collect do |node|
|
39
41
|
{ milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
|
40
42
|
end
|
@@ -49,6 +51,10 @@ module Dor
|
|
49
51
|
Time.parse(milestone['date'])
|
50
52
|
end
|
51
53
|
|
54
|
+
# @param [String] repo repository name
|
55
|
+
# @param [String] druid object id
|
56
|
+
# @param [Boolean] active_only (false) if true, return only lifecycle steps for versions that have all processes complete
|
57
|
+
# @param [Number] version the version to query for
|
52
58
|
# @return [Nokogiri::XML::Document]
|
53
59
|
# @example An example lifecycle xml from the workflow service.
|
54
60
|
# <lifecycle objectId="druid:ct011cv6501">
|
@@ -57,15 +63,13 @@ module Dor
|
|
57
63
|
# <milestone date="2010-06-15T16:08:58-0700">released</milestone>
|
58
64
|
# </lifecycle>
|
59
65
|
#
|
60
|
-
def query_lifecycle(repo, druid, active_only
|
66
|
+
def query_lifecycle(repo, druid, active_only:, version: nil)
|
61
67
|
req = "#{repo}/objects/#{druid}/lifecycle"
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
''
|
68
|
-
end
|
68
|
+
params = []
|
69
|
+
params << "version=#{version}" if version
|
70
|
+
params << 'active-only=true' if active_only
|
71
|
+
req += "?#{params.join('&')}" unless params.empty?
|
72
|
+
|
69
73
|
Nokogiri::XML(requestor.request(req))
|
70
74
|
end
|
71
75
|
|
@@ -21,6 +21,15 @@ module Dor
|
|
21
21
|
JSON.parse(body)
|
22
22
|
end
|
23
23
|
|
24
|
+
# Retrieves a list of workflow template name
|
25
|
+
#
|
26
|
+
# @return [Array<String>] the list of templates
|
27
|
+
#
|
28
|
+
def all
|
29
|
+
body = requestor.request 'workflow_templates'
|
30
|
+
JSON.parse(body)
|
31
|
+
end
|
32
|
+
|
24
33
|
private
|
25
34
|
|
26
35
|
attr_reader :requestor
|
@@ -44,4 +44,24 @@ RSpec.describe Dor::Workflow::Client::LifecycleRoutes do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
describe '#active_lifecycle' do
|
49
|
+
context 'without version' do
|
50
|
+
subject(:active_lifecycle) { routes.active_lifecycle('dor', 'druid:gv054hp4128', 'submitted') }
|
51
|
+
|
52
|
+
it 'make the request' do
|
53
|
+
active_lifecycle
|
54
|
+
expect(requestor).to have_received(:request).with('dor/objects/druid:gv054hp4128/lifecycle?active-only=true')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with version' do
|
59
|
+
subject(:active_lifecycle) { routes.active_lifecycle('dor', 'druid:gv054hp4128', 'submitted', version: 3) }
|
60
|
+
|
61
|
+
it 'makes the request with the version' do
|
62
|
+
active_lifecycle
|
63
|
+
expect(requestor).to have_received(:request).with('dor/objects/druid:gv054hp4128/lifecycle?version=3&active-only=true')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
47
67
|
end
|
@@ -3,18 +3,28 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Dor::Workflow::Client::WorkflowTemplate do
|
6
|
-
let(:data) { '{"processes":[{"name":"start-assembly"},{"name":"content-metadata-create"}]}' }
|
7
6
|
let(:mock_requestor) { instance_double(Dor::Workflow::Client::Requestor, request: data) }
|
8
7
|
|
9
8
|
let(:routes) { described_class.new(requestor: mock_requestor) }
|
10
9
|
|
11
10
|
describe '#retrieve' do
|
12
11
|
subject(:workflow_template) { routes.retrieve('accessionWF') }
|
12
|
+
let(:data) { '{"processes":[{"name":"start-assembly"},{"name":"content-metadata-create"}]}' }
|
13
13
|
|
14
|
-
it 'returns a workflow' do
|
14
|
+
it 'returns a workflow template' do
|
15
15
|
expect(workflow_template['processes']).to eq [{ 'name' => 'start-assembly' },
|
16
16
|
{ 'name' => 'content-metadata-create' }]
|
17
17
|
expect(mock_requestor).to have_received(:request).with('workflow_templates/accessionWF')
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
describe '#all' do
|
22
|
+
subject(:workflow_templates) { routes.all }
|
23
|
+
let(:data) { '["assemblyWF","registrationWF"]' }
|
24
|
+
|
25
|
+
it 'returns a list of templates' do
|
26
|
+
expect(workflow_templates).to eq %w[assemblyWF registrationWF]
|
27
|
+
expect(mock_requestor).to have_received(:request).with('workflow_templates')
|
28
|
+
end
|
29
|
+
end
|
20
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willy Mene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-09-
|
12
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|