dor-workflow-client 4.1.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/Gemfile.lock +18 -14
- data/lib/dor/workflow/client/lifecycle_routes.rb +4 -69
- data/lib/dor/workflow/client/queues.rb +10 -43
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/version_routes.rb +1 -23
- data/lib/dor/workflow/client/workflow_routes.rb +7 -150
- data/lib/dor/workflow/client.rb +1 -2
- data/lib/dor/workflow/response/process.rb +1 -2
- data/lib/dor/workflow/response/workflow.rb +0 -8
- data/spec/models/response/process_spec.rb +0 -17
- data/spec/models/response/workflow_spec.rb +0 -16
- data/spec/workflow/client/lifecycle_routes_spec.rb +18 -152
- data/spec/workflow/client/version_routes_spec.rb +1 -44
- data/spec/workflow/client_spec.rb +9 -270
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660ca959342689ef767c9b7d6ce72f90ec5d568227e1acab968c7cf5b2e9bb95
|
4
|
+
data.tar.gz: e5c19e4cf9c2f79edc1cefaa0b9dbe4954866c2f29357fd58425d173662422ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f985246d0238a872a26f9fcab9a65f7d2795be9b7946dffa4fba5cb2557203184de1ec1e1b4a758405a397c34dc991ef74290e8d5d5d28691b69984c18ddfd
|
7
|
+
data.tar.gz: c458009469d0684198722475fbe01a1dce917272298b18494979ed63957e399ea76830f1c22036ae0e21b46fb7ac31481b1e37e5f715916ee217648cb62526cc
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dor-workflow-client (
|
4
|
+
dor-workflow-client (5.0.0)
|
5
5
|
activesupport (>= 3.2.1, < 8)
|
6
6
|
deprecation (>= 0.99.0)
|
7
7
|
faraday (~> 2.0)
|
@@ -12,7 +12,7 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (7.0.3)
|
15
|
+
activesupport (7.0.3.1)
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
17
|
i18n (>= 1.6, < 2)
|
18
18
|
minitest (>= 5.1)
|
@@ -28,16 +28,19 @@ GEM
|
|
28
28
|
activesupport
|
29
29
|
diff-lcs (1.5.0)
|
30
30
|
docile (1.4.0)
|
31
|
-
faraday (2.
|
31
|
+
faraday (2.4.0)
|
32
32
|
faraday-net_http (~> 2.0)
|
33
33
|
ruby2_keywords (>= 0.0.4)
|
34
|
-
faraday-net_http (2.0
|
34
|
+
faraday-net_http (2.1.0)
|
35
35
|
faraday-retry (1.0.3)
|
36
36
|
hashdiff (1.0.1)
|
37
|
-
i18n (1.
|
37
|
+
i18n (1.12.0)
|
38
38
|
concurrent-ruby (~> 1.0)
|
39
|
-
|
40
|
-
|
39
|
+
json (2.6.2)
|
40
|
+
mini_portile2 (2.8.0)
|
41
|
+
minitest (5.16.2)
|
42
|
+
nokogiri (1.13.8)
|
43
|
+
mini_portile2 (~> 2.8.0)
|
41
44
|
racc (~> 1.4)
|
42
45
|
parallel (1.22.1)
|
43
46
|
parser (3.1.2.0)
|
@@ -63,21 +66,22 @@ GEM
|
|
63
66
|
rspec-support (3.11.0)
|
64
67
|
rspec_junit_formatter (0.5.1)
|
65
68
|
rspec-core (>= 2, < 4, != 2.12.0)
|
66
|
-
rubocop (1.
|
69
|
+
rubocop (1.32.0)
|
70
|
+
json (~> 2.3)
|
67
71
|
parallel (~> 1.10)
|
68
72
|
parser (>= 3.1.0.0)
|
69
73
|
rainbow (>= 2.2.2, < 4.0)
|
70
74
|
regexp_parser (>= 1.8, < 3.0)
|
71
75
|
rexml (>= 3.2.5, < 4.0)
|
72
|
-
rubocop-ast (>= 1.
|
76
|
+
rubocop-ast (>= 1.19.1, < 2.0)
|
73
77
|
ruby-progressbar (~> 1.7)
|
74
78
|
unicode-display_width (>= 1.4.0, < 3.0)
|
75
|
-
rubocop-ast (1.
|
79
|
+
rubocop-ast (1.19.1)
|
76
80
|
parser (>= 3.1.1.0)
|
77
81
|
rubocop-rake (0.6.0)
|
78
82
|
rubocop (~> 1.0)
|
79
|
-
rubocop-rspec (2.
|
80
|
-
rubocop (~> 1.
|
83
|
+
rubocop-rspec (2.12.1)
|
84
|
+
rubocop (~> 1.31)
|
81
85
|
ruby-progressbar (1.11.0)
|
82
86
|
ruby2_keywords (0.0.5)
|
83
87
|
simplecov (0.21.2)
|
@@ -86,7 +90,7 @@ GEM
|
|
86
90
|
simplecov_json_formatter (~> 0.1)
|
87
91
|
simplecov-html (0.12.3)
|
88
92
|
simplecov_json_formatter (0.1.4)
|
89
|
-
tzinfo (2.0.
|
93
|
+
tzinfo (2.0.5)
|
90
94
|
concurrent-ruby (~> 1.0)
|
91
95
|
unicode-display_width (2.2.0)
|
92
96
|
webmock (3.14.0)
|
@@ -115,4 +119,4 @@ DEPENDENCIES
|
|
115
119
|
yard
|
116
120
|
|
117
121
|
BUNDLED WITH
|
118
|
-
2.
|
122
|
+
2.3.17
|
@@ -14,39 +14,12 @@ module Dor
|
|
14
14
|
# @param [String] repo The repository the object resides in. This parameter is deprecated
|
15
15
|
# @param [String] druid object id
|
16
16
|
# @param [String] milestone_name the name of the milestone being queried for
|
17
|
-
# @param [Number] version the version to query for
|
17
|
+
# @param [Number] version (nil) the version to query for
|
18
18
|
# @param [Boolean] active_only (false) if true, return only lifecycle steps for versions that have all processes complete
|
19
19
|
# @return [Time] when the milestone was achieved. Returns nil if the milestone does not exist
|
20
|
-
|
21
|
-
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
22
|
-
def lifecycle(*args)
|
23
|
-
case args.size
|
24
|
-
when 4
|
25
|
-
Deprecation.warn(self, 'you provided 4 args, but lifecycle now takes kwargs')
|
26
|
-
(repo, druid, milestone_name) = args[0..2]
|
27
|
-
version = args[3][:version]
|
28
|
-
active_only = args[3][:active_only] || false
|
29
|
-
when 3
|
30
|
-
Deprecation.warn(self, 'you provided 3 args, but lifecycle now takes kwargs')
|
31
|
-
(repo, druid, milestone_name) = args
|
32
|
-
version = nil
|
33
|
-
active_only = false
|
34
|
-
when 1
|
35
|
-
opts = args.first
|
36
|
-
repo = opts[:repo]
|
37
|
-
druid = opts[:druid]
|
38
|
-
milestone_name = opts[:milestone_name]
|
39
|
-
version = opts[:version]
|
40
|
-
active_only = opts[:active_only] || false
|
41
|
-
else
|
42
|
-
raise ArgumentError, 'wrong number of arguments, must be 1, or 3-5'
|
43
|
-
end
|
44
|
-
|
45
|
-
Deprecation.warn(self, 'passing the repo parameter to lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
46
|
-
|
20
|
+
def lifecycle(druid:, milestone_name:, version: nil, active_only: false)
|
47
21
|
filter_milestone(query_lifecycle(druid, version: version, active_only: active_only), milestone_name)
|
48
22
|
end
|
49
|
-
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
50
23
|
|
51
24
|
# Returns the Date for a requested milestone ONLY for the current version.
|
52
25
|
# This is slow as the workflow server will query dor-services-app for the version.
|
@@ -55,50 +28,12 @@ module Dor
|
|
55
28
|
# @param [String] milestone_name the name of the milestone being queried for
|
56
29
|
# @param [Number] version the version to query for
|
57
30
|
# @return [Time] when the milestone was achieved. Returns nil if the milestone does not exis
|
58
|
-
|
59
|
-
# rubocop:disable Metrics/MethodLength
|
60
|
-
def active_lifecycle(*args)
|
61
|
-
case args.size
|
62
|
-
when 4
|
63
|
-
Deprecation.warn(self, 'you provided 4 args, but active_lifecycle now takes kwargs')
|
64
|
-
(repo, druid, milestone_name) = args[0..2]
|
65
|
-
version = args[3][:version]
|
66
|
-
when 3
|
67
|
-
Deprecation.warn(self, 'you provided 3 args, but active_lifecycle now takes kwargs')
|
68
|
-
(repo, druid, milestone_name) = args
|
69
|
-
version = nil
|
70
|
-
when 1
|
71
|
-
opts = args.first
|
72
|
-
repo = opts[:repo]
|
73
|
-
druid = opts[:druid]
|
74
|
-
milestone_name = opts[:milestone_name]
|
75
|
-
version = opts[:version]
|
76
|
-
else
|
77
|
-
raise ArgumentError, 'wrong number of arguments, must be 1, 3, or 4'
|
78
|
-
end
|
79
|
-
|
80
|
-
Deprecation.warn(self, 'passing the repo parameter to active_lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
81
|
-
|
31
|
+
def active_lifecycle(druid:, milestone_name:, version:)
|
82
32
|
lifecycle(druid: druid, milestone_name: milestone_name, version: version, active_only: true)
|
83
33
|
end
|
84
|
-
# rubocop:enable Metrics/MethodLength
|
85
34
|
|
86
35
|
# @return [Array<Hash>]
|
87
|
-
def milestones(
|
88
|
-
case args.size
|
89
|
-
when 2
|
90
|
-
Deprecation.warn(self, 'you provided 2 args, but active_lifecycle now takes kwargs')
|
91
|
-
(repo, druid) = args
|
92
|
-
when 1
|
93
|
-
opts = args.first
|
94
|
-
repo = opts[:repo]
|
95
|
-
druid = opts.fetch(:druid)
|
96
|
-
else
|
97
|
-
raise ArgumentError, 'wrong number of arguments, must be 1-2'
|
98
|
-
end
|
99
|
-
|
100
|
-
Deprecation.warn(self, 'passing the repo parameter to active_lifecycle is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
101
|
-
|
36
|
+
def milestones(druid:)
|
102
37
|
doc = query_lifecycle(druid, active_only: false)
|
103
38
|
doc.xpath('//lifecycle/milestone').collect do |node|
|
104
39
|
{ milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
|
@@ -11,59 +11,35 @@ module Dor
|
|
11
11
|
|
12
12
|
# Returns all the distinct laneIds for a given workflow step
|
13
13
|
#
|
14
|
-
# @param [String] repo -- deprecated, ignored by workflow service
|
15
14
|
# @param [String] workflow name
|
16
15
|
# @param [String] process name
|
17
16
|
# @return [Array<String>] all of the distinct laneIds. Array will be empty if no lane ids were found
|
18
|
-
def lane_ids(
|
19
|
-
|
20
|
-
Deprecation.warn(
|
21
|
-
self,
|
22
|
-
'`#lane_ids` only takes two args: workflow name, & process/step name. This will raise an exception in Dor::Workflow::Client 4.0.0'
|
23
|
-
)
|
24
|
-
args.shift # ditch the `repo` argument
|
25
|
-
end
|
26
|
-
uri = "workflow_queue/lane_ids?step=#{args.first}:#{args.second}"
|
17
|
+
def lane_ids(workflow, process)
|
18
|
+
uri = "workflow_queue/lane_ids?step=#{workflow}:#{process}"
|
27
19
|
doc = Nokogiri::XML(requestor.request(uri))
|
28
20
|
doc.xpath('/lanes/lane').map { |n| n['id'] }
|
29
21
|
end
|
30
22
|
|
31
23
|
# Gets all of the workflow steps that have a status of 'queued' that have a last-updated timestamp older than the number of hours passed in
|
32
24
|
# This will enable re-queueing of jobs that have been lost by the job manager
|
33
|
-
# @param [String] repository -- deprecated, ignored by workflow service
|
34
25
|
# @param [Hash] opts optional values for query
|
35
26
|
# @option opts [Integer] :hours_ago steps older than this value will be returned by the query. If not passed in, the service defaults to 0 hours,
|
36
27
|
# meaning you will get all queued workflows
|
37
28
|
# @option opts [Integer] :limit sets the maximum number of workflow steps that can be returned. Defaults to no limit
|
38
29
|
# @return [Array[Hash]] each Hash represents a workflow step. It will have the following keys:
|
39
30
|
# :workflow, :step, :druid, :lane_id
|
40
|
-
def stale_queued_workflows(
|
41
|
-
|
42
|
-
Deprecation.warn(
|
43
|
-
self,
|
44
|
-
'`#stale_queued_workflows` only takes one arg: a hash. This will raise an exception in Dor::Workflow::Client 4.0.0'
|
45
|
-
)
|
46
|
-
args.shift # ditch the `repo` argument
|
47
|
-
end
|
48
|
-
uri_string = build_queued_uri(args.first)
|
31
|
+
def stale_queued_workflows(opts)
|
32
|
+
uri_string = build_queued_uri(opts)
|
49
33
|
parse_queued_workflows_response requestor.request(uri_string)
|
50
34
|
end
|
51
35
|
|
52
36
|
# Returns a count of workflow steps that have a status of 'queued' that have a last-updated timestamp older than the number of hours passed in
|
53
|
-
# @param [String] repository -- deprecated, ignored by workflow service
|
54
37
|
# @param [Hash] opts optional values for query
|
55
38
|
# @option opts [Integer] :hours_ago steps older than this value will be returned by the query. If not passed in, the service defaults to 0 hours,
|
56
39
|
# meaning you will get all queued workflows
|
57
40
|
# @return [Integer] number of stale, queued steps if the :count_only option was set to true
|
58
|
-
def count_stale_queued_workflows(
|
59
|
-
|
60
|
-
Deprecation.warn(
|
61
|
-
self,
|
62
|
-
'`#count_stale_queued_workflows` only takes one arg: a hash. This will raise an exception in Dor::Workflow::Client 4.0.0'
|
63
|
-
)
|
64
|
-
args.shift # ditch the `repo` argument
|
65
|
-
end
|
66
|
-
uri_string = "#{build_queued_uri(args.first)}&count-only=true"
|
41
|
+
def count_stale_queued_workflows(opts)
|
42
|
+
uri_string = "#{build_queued_uri(opts)}&count-only=true"
|
67
43
|
doc = Nokogiri::XML(requestor.request(uri_string))
|
68
44
|
doc.at_xpath('/objects/@count').value.to_i
|
69
45
|
end
|
@@ -102,7 +78,6 @@ module Dor
|
|
102
78
|
# }
|
103
79
|
#
|
104
80
|
def objects_for_workstep(completed, waiting, lane_id = 'default', options = {})
|
105
|
-
Deprecation.warn(self, 'the `:default_repository` option in `#objects_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') if options[:default_repository]
|
106
81
|
waiting_param = qualify_step(options[:default_workflow], waiting)
|
107
82
|
uri_string = "workflow_queue?waiting=#{waiting_param}"
|
108
83
|
if completed
|
@@ -133,15 +108,13 @@ module Dor
|
|
133
108
|
#
|
134
109
|
# @param [String] workflow name
|
135
110
|
# @param [String] step name
|
136
|
-
# @param [String] repository -- deprecated, ignored by workflow service
|
137
111
|
#
|
138
112
|
# @return [Hash] hash of results, with key has a druid, and value as the error message
|
139
113
|
# @example
|
140
114
|
# client.errored_objects_for_workstep('accessionWF','content-metadata')
|
141
115
|
# => {"druid:qd556jq0580"=>"druid:qd556jq0580 - Item error; caused by
|
142
116
|
# blah blah. See logger for details>"}
|
143
|
-
def errored_objects_for_workstep(workflow, step
|
144
|
-
Deprecation.warn(self, 'the third argument to `#errored_objects_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
|
117
|
+
def errored_objects_for_workstep(workflow, step)
|
145
118
|
resp = requestor.request "workflow_queue?workflow=#{workflow}&error=#{step}"
|
146
119
|
Nokogiri::XML(resp).xpath('//object').to_h do |node|
|
147
120
|
[node['id'], node['errorMessage']]
|
@@ -153,11 +126,9 @@ module Dor
|
|
153
126
|
# @param [String] workflow name
|
154
127
|
# @param [String] step name
|
155
128
|
# @param [String] type
|
156
|
-
# @param [String] repo -- deprecated, ignored by workflow service
|
157
129
|
#
|
158
130
|
# @return [Hash] hash of results, with key has a druid, and value as the error message
|
159
|
-
def count_objects_in_step(workflow, step, type
|
160
|
-
Deprecation.warn(self, 'the fourth argument to `#count_objects_in_step` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repo.nil?
|
131
|
+
def count_objects_in_step(workflow, step, type)
|
161
132
|
resp = requestor.request "workflow_queue?workflow=#{workflow}&#{type}=#{step}"
|
162
133
|
extract_object_count(resp)
|
163
134
|
end
|
@@ -166,11 +137,9 @@ module Dor
|
|
166
137
|
#
|
167
138
|
# @param [String] workflow name
|
168
139
|
# @param [String] step name
|
169
|
-
# @param [String] repository -- deprecated, ignored by workflow service
|
170
140
|
#
|
171
141
|
# @return [Integer] Number of objects with this repository:workflow:step that have a status of 'error'
|
172
|
-
def count_errored_for_workstep(workflow, step
|
173
|
-
Deprecation.warn(self, 'the third argument to `#count_errored_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
|
142
|
+
def count_errored_for_workstep(workflow, step)
|
174
143
|
count_objects_in_step(workflow, step, 'error')
|
175
144
|
end
|
176
145
|
|
@@ -178,11 +147,9 @@ module Dor
|
|
178
147
|
#
|
179
148
|
# @param [String] workflow name
|
180
149
|
# @param [String] step name
|
181
|
-
# @param [String] repository -- deprecated, ignored by workflow service
|
182
150
|
#
|
183
151
|
# @return [Integer] Number of objects with this repository:workflow:step that have a status of 'queued'
|
184
|
-
def count_queued_for_workstep(workflow, step
|
185
|
-
Deprecation.warn(self, 'the third argument to `#count_queued_for_workstep` is unused and will go away in Dor::Workflow::Client 4.0.0. omit argument to silence.') unless repository.nil?
|
152
|
+
def count_queued_for_workstep(workflow, step)
|
186
153
|
count_objects_in_step(workflow, step, 'queued')
|
187
154
|
end
|
188
155
|
|
@@ -17,32 +17,10 @@ module Dor
|
|
17
17
|
# @param [String] repo The repository the object resides in. This parameter is deprecated
|
18
18
|
# @param [String] druid The id of the object to delete the workflow from
|
19
19
|
# @param [Boolean] create_accession_wf Option to create accessionWF when closing a version. Defaults to true
|
20
|
-
|
21
|
-
def close_version(*args)
|
22
|
-
case args.size
|
23
|
-
when 3
|
24
|
-
Deprecation.warn(self, 'you provided 3 args, but close_version now takes kwargs')
|
25
|
-
(repo, druid, create_accession_wf) = args
|
26
|
-
when 2
|
27
|
-
Deprecation.warn(self, 'you provided 2 args, but close_version now takes kwargs')
|
28
|
-
(repo, druid) = args
|
29
|
-
create_accession_wf = true
|
30
|
-
when 1
|
31
|
-
opts = args.first
|
32
|
-
repo = opts[:repo]
|
33
|
-
druid = opts[:druid]
|
34
|
-
version = opts[:version]
|
35
|
-
create_accession_wf = opts.key?(:create_accession_wf) ? opts[:create_accession_wf] : true
|
36
|
-
else
|
37
|
-
raise ArgumentError, 'wrong number of arguments, must be 1-3'
|
38
|
-
end
|
39
|
-
|
40
|
-
Deprecation.warn(self, 'passing the repo parameter to close_version is no longer necessary. This will raise an error in dor-workflow-client version 4') if repo
|
41
|
-
|
20
|
+
def close_version(druid:, version:, create_accession_wf: true)
|
42
21
|
requestor.request(construct_url(druid, version, create_accession_wf), 'post', '')
|
43
22
|
true
|
44
23
|
end
|
45
|
-
# rubocop:enable Metrics/MethodLength
|
46
24
|
|
47
25
|
private
|
48
26
|
|
@@ -4,29 +4,11 @@ module Dor
|
|
4
4
|
module Workflow
|
5
5
|
class Client
|
6
6
|
# Makes requests relating to a workflow
|
7
|
-
# rubocop:disable Metrics/ClassLength
|
8
7
|
class WorkflowRoutes
|
9
|
-
extend Deprecation
|
10
|
-
|
11
8
|
def initialize(requestor:)
|
12
9
|
@requestor = requestor
|
13
10
|
end
|
14
11
|
|
15
|
-
# This method is deprecated and calls create_workflow_by_name.
|
16
|
-
#
|
17
|
-
# @param [String] repo Ignored
|
18
|
-
# @param [String] druid The id of the object
|
19
|
-
# @param [String] workflow_name The name of the workflow you want to create
|
20
|
-
# @param [String] wf_xml Ignored
|
21
|
-
# @param [Hash] opts optional params
|
22
|
-
# @option opts [String] :lane_id adds laneId attribute to all process elements in the wf_xml workflow xml. Defaults to a value of 'default'
|
23
|
-
# @return [Boolean] always true
|
24
|
-
#
|
25
|
-
def create_workflow(_repo, druid, workflow_name, _wf_xml, opts = {})
|
26
|
-
create_workflow_by_name(druid, workflow_name, **opts)
|
27
|
-
end
|
28
|
-
deprecation_deprecate create_workflow: 'use create_workflow_by_name instead'
|
29
|
-
|
30
12
|
# Creates a workflow for a given object in the repository. If this particular workflow for this objects exists,
|
31
13
|
# it will replace the old workflow.
|
32
14
|
# Returns true on success. Caller must handle any exceptions.
|
@@ -38,13 +20,8 @@ module Dor
|
|
38
20
|
# @param [Integer] version specifies the version so that workflow service doesn't need to query dor-services.
|
39
21
|
# @return [Boolean] always true
|
40
22
|
#
|
41
|
-
def create_workflow_by_name(druid, workflow_name, version
|
42
|
-
params = { 'lane-id' => lane_id }
|
43
|
-
if version
|
44
|
-
params['version'] = version
|
45
|
-
else
|
46
|
-
Deprecation.warn(self, 'Calling create_workflow_by_name without passing version is deprecated and will result in an error in dor-workflow-client 4.0')
|
47
|
-
end
|
23
|
+
def create_workflow_by_name(druid, workflow_name, version:, lane_id: 'default')
|
24
|
+
params = { 'lane-id' => lane_id, 'version' => version }
|
48
25
|
requestor.request "objects/#{druid}/workflows/#{workflow_name}", 'post', '',
|
49
26
|
content_type: 'application/xml',
|
50
27
|
params: params
|
@@ -82,41 +59,6 @@ module Dor
|
|
82
59
|
Workflow::Response::Update.new(json: response)
|
83
60
|
end
|
84
61
|
|
85
|
-
# Updates the status of one step in a workflow.
|
86
|
-
# Returns true on success. Caller must handle any exceptions
|
87
|
-
#
|
88
|
-
# @param [String] repo The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
|
89
|
-
# @param [String] druid The id of the object
|
90
|
-
# @param [String] workflow The name of the workflow
|
91
|
-
# @param [String] process The name of the process step
|
92
|
-
# @param [String] status The status that you want to set -- using one of the values in VALID_STATUS
|
93
|
-
# @param [Hash] opts optional values for the workflow step
|
94
|
-
# @option opts [Float] :elapsed The number of seconds it took to complete this step. Can have a decimal. Is set to 0 if not passed in.
|
95
|
-
# @option opts [String] :lifecycle Bookeeping label for this particular workflow step. Examples are: 'registered', 'shelved'
|
96
|
-
# @option opts [String] :note Any kind of string annotation that you want to attach to the workflow
|
97
|
-
# @option opts [String] :lane_id Id of processing lane used by the job manager. Can convey priority or name of an applicaiton specific processing lane (e.g. 'high', 'critical', 'hydrus')
|
98
|
-
# @option opts [String] :current_status Setting this string tells the workflow service to compare the current status to this value. If the current value does not match this value, the update is not performed
|
99
|
-
# @return [Boolean] always true
|
100
|
-
# Http Call
|
101
|
-
# ==
|
102
|
-
# The method does an HTTP PUT to the base URL. As an example:
|
103
|
-
#
|
104
|
-
# PUT "/dor/objects/pid:123/workflows/GoogleScannedWF/convert"
|
105
|
-
# <process name=\"convert\" status=\"completed\" />"
|
106
|
-
def update_workflow_status(repo, druid, workflow, process, status, opts = {})
|
107
|
-
raise ArgumentError, "Unknown status value #{status}" unless VALID_STATUS.include?(status.downcase)
|
108
|
-
|
109
|
-
opts = { elapsed: 0, lifecycle: nil, note: nil }.merge!(opts)
|
110
|
-
opts[:elapsed] = opts[:elapsed].to_s
|
111
|
-
current_status = opts.delete(:current_status)
|
112
|
-
xml = create_process_xml({ name: process, status: status.downcase }.merge!(opts))
|
113
|
-
uri = "#{repo}/objects/#{druid}/workflows/#{workflow}/#{process}"
|
114
|
-
uri += "?current-status=#{current_status.downcase}" if current_status
|
115
|
-
response = requestor.request(uri, 'put', xml, content_type: 'application/xml')
|
116
|
-
Workflow::Response::Update.new(json: response)
|
117
|
-
end
|
118
|
-
deprecation_deprecate update_workflow_status: 'use update_status instead.'
|
119
|
-
|
120
62
|
#
|
121
63
|
# Retrieves the process status of the given workflow for the given object identifier
|
122
64
|
# @param [String] repo The repository the object resides in. Currently recoginzes "dor" and "sdr".
|
@@ -124,20 +66,7 @@ module Dor
|
|
124
66
|
# @param [String] workflow The name of the workflow
|
125
67
|
# @param [String] process The name of the process step
|
126
68
|
# @return [String] status for repo-workflow-process-druid
|
127
|
-
|
128
|
-
def workflow_status(*args)
|
129
|
-
case args.length
|
130
|
-
when 4
|
131
|
-
Deprecation.warn(self, 'Calling workflow_status with positional args is deprecated, use kwargs instead')
|
132
|
-
(_repo, druid, workflow, process) = *args
|
133
|
-
when 1
|
134
|
-
opts = args.first
|
135
|
-
repo = opts[:repo]
|
136
|
-
Deprecation.warn(self, 'Passing `:repo` to workflow_status is deprecated and can be omitted') if repo
|
137
|
-
druid = opts[:druid]
|
138
|
-
workflow = opts[:workflow]
|
139
|
-
process = opts[:process]
|
140
|
-
end
|
69
|
+
def workflow_status(druid:, workflow:, process:)
|
141
70
|
workflow_md = fetch_workflow(druid: druid, workflow: workflow)
|
142
71
|
doc = Nokogiri::XML(workflow_md)
|
143
72
|
raise Dor::WorkflowException, "Unable to parse response:\n#{workflow_md}" if doc.root.nil?
|
@@ -147,57 +76,6 @@ module Dor
|
|
147
76
|
process&.attr('status')
|
148
77
|
end
|
149
78
|
|
150
|
-
# rubocop:enable Metrics/AbcSize
|
151
|
-
#
|
152
|
-
# Retrieves the raw XML for the given workflow
|
153
|
-
# @param [String] repo The repository the object resides in. Currently recoginzes "dor" and "sdr".
|
154
|
-
# @param [String] druid The id of the object
|
155
|
-
# @param [String] workflow The name of the workflow
|
156
|
-
# @return [String] XML of the workflow
|
157
|
-
def workflow_xml(*args)
|
158
|
-
case args.length
|
159
|
-
when 3
|
160
|
-
Deprecation.warn(self, 'Calling workflow_xml with positional args is deprecated, use kwargs instead')
|
161
|
-
(repo, druid, workflow) = *args
|
162
|
-
when 1
|
163
|
-
opts = args.first
|
164
|
-
repo = opts[:repo]
|
165
|
-
Deprecation.warn(self, 'Passing `:repo` to workflow_xml is deprecated and can be omitted') if repo
|
166
|
-
druid = opts[:druid]
|
167
|
-
workflow = opts[:workflow]
|
168
|
-
end
|
169
|
-
|
170
|
-
raise ArgumentError, 'missing workflow' unless workflow
|
171
|
-
return requestor.request "#{repo}/objects/#{druid}/workflows/#{workflow}" if repo
|
172
|
-
|
173
|
-
fetch_workflow(druid: druid, workflow: workflow)
|
174
|
-
end
|
175
|
-
deprecation_deprecate workflow_xml: 'workflow_xml will not be replaced'
|
176
|
-
|
177
|
-
# Updates the status of one step in a workflow to error.
|
178
|
-
# Returns true on success. Caller must handle any exceptions
|
179
|
-
#
|
180
|
-
# @param [String] _repo The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
|
181
|
-
# @param [String] druid The id of the object
|
182
|
-
# @param [String] workflow The name of the workflow
|
183
|
-
# @param [String] process The name of the workflow step
|
184
|
-
# @param [String] error_msg The error message. Ideally, this is a brief message describing the error
|
185
|
-
# @param [Hash] opts optional values for the workflow step
|
186
|
-
# @option opts [String] :error_text A slot to hold more information about the error, like a full stacktrace
|
187
|
-
# @return [Boolean] always true
|
188
|
-
#
|
189
|
-
# Http Call
|
190
|
-
# ==
|
191
|
-
# The method does an HTTP PUT to the base URL.
|
192
|
-
#
|
193
|
-
# PUT "/objects/pid:123/workflows/GoogleScannedWF/convert"
|
194
|
-
# <process name=\"convert\" status=\"error\" />"
|
195
|
-
def update_workflow_error_status(_repo, druid, workflow, process, error_msg, opts = {})
|
196
|
-
update_error_status(druid: druid, workflow: workflow, process: process, error_msg: error_msg, error_text: opts[:error_text])
|
197
|
-
true
|
198
|
-
end
|
199
|
-
deprecation_deprecate update_workflow_error_status: 'use update_error_status instead.'
|
200
|
-
|
201
79
|
# Updates the status of one step in a workflow to error.
|
202
80
|
# Returns true on success. Caller must handle any exceptions
|
203
81
|
#
|
@@ -240,23 +118,19 @@ module Dor
|
|
240
118
|
# This method only works when this gem is used in a project that is configured to connect to DOR
|
241
119
|
#
|
242
120
|
# @param [String] pid of druid
|
243
|
-
# @param [String] repo repository for the object
|
244
121
|
# @return [Array<String>] list of worklows
|
245
122
|
# @example
|
246
123
|
# client.workflows('druid:sr100hp0609')
|
247
124
|
# => ["accessionWF", "assemblyWF", "disseminationWF"]
|
248
|
-
def workflows(pid
|
249
|
-
Deprecation.warn(self, 'Passing the second argument (repo) to workflows is deprecated and can be omitted') if repo
|
125
|
+
def workflows(pid)
|
250
126
|
xml_doc = Nokogiri::XML(fetch_workflow(druid: pid, workflow: ''))
|
251
127
|
xml_doc.xpath('//workflow').collect { |workflow| workflow['id'] }
|
252
128
|
end
|
253
129
|
|
254
|
-
# @param [String] repo repository of the object
|
255
130
|
# @param [String] pid id of object
|
256
131
|
# @param [String] workflow_name The name of the workflow
|
257
132
|
# @return [Workflow::Response::Workflow]
|
258
|
-
def workflow(
|
259
|
-
Deprecation.warn(self, 'passing the repo parameter is deprecated and will be removed in the next major versions') if repo
|
133
|
+
def workflow(pid:, workflow_name:)
|
260
134
|
xml = fetch_workflow(druid: pid, workflow: workflow_name)
|
261
135
|
Workflow::Response::Workflow.new(xml: xml)
|
262
136
|
end
|
@@ -274,24 +148,8 @@ module Dor
|
|
274
148
|
# @param [String] workflow The name of the workflow to be deleted
|
275
149
|
# @param [Integer] version The version of the workflow to delete
|
276
150
|
# @return [Boolean] always true
|
277
|
-
def delete_workflow(
|
278
|
-
|
279
|
-
when 3..4
|
280
|
-
Deprecation.warn(self, 'Calling delete_workflow with positional args is deprecated, use kwargs instead')
|
281
|
-
(_repo, druid, workflow, version_hash) = *args
|
282
|
-
version = version_hash && version_hash[:version]
|
283
|
-
when 1
|
284
|
-
opts = args.first
|
285
|
-
druid = opts[:druid]
|
286
|
-
workflow = opts[:workflow]
|
287
|
-
version = opts[:version]
|
288
|
-
end
|
289
|
-
qs_args = if version
|
290
|
-
"?version=#{version}"
|
291
|
-
else
|
292
|
-
Deprecation.warn(self, 'Calling delete_workflow without passing version is deprecated and will result in an error in dor-workflow-client 4.0')
|
293
|
-
''
|
294
|
-
end
|
151
|
+
def delete_workflow(druid:, workflow:, version:)
|
152
|
+
qs_args = "?version=#{version}"
|
295
153
|
requestor.request "/objects/#{druid}/workflows/#{workflow}#{qs_args}", 'delete'
|
296
154
|
true
|
297
155
|
end
|
@@ -325,7 +183,6 @@ module Dor
|
|
325
183
|
builder.to_xml
|
326
184
|
end
|
327
185
|
end
|
328
|
-
# rubocop:enable Metrics/ClassLength
|
329
186
|
end
|
330
187
|
end
|
331
188
|
end
|
data/lib/dor/workflow/client.rb
CHANGED
@@ -40,8 +40,7 @@ module Dor
|
|
40
40
|
@requestor = Requestor.new(connection: connection || ConnectionFactory.build_connection(url, timeout: timeout, logger: logger))
|
41
41
|
end
|
42
42
|
|
43
|
-
delegate :
|
44
|
-
:workflow_xml, :update_workflow_error_status, :all_workflows_xml, :workflows,
|
43
|
+
delegate :create_workflow_by_name, :workflow_status, :all_workflows_xml, :workflows,
|
45
44
|
:workflow, :process, :delete_workflow, :delete_all_workflows, :update_status, :update_error_status,
|
46
45
|
to: :workflow_routes
|
47
46
|
|
@@ -5,9 +5,6 @@ module Dor
|
|
5
5
|
module Response
|
6
6
|
# The response from asking the server about a workflow for an item
|
7
7
|
class Workflow
|
8
|
-
extend Deprecation
|
9
|
-
self.deprecation_horizon = '4.x'
|
10
|
-
|
11
8
|
def initialize(xml:)
|
12
9
|
@xml = xml
|
13
10
|
end
|
@@ -20,11 +17,6 @@ module Dor
|
|
20
17
|
workflow['id']
|
21
18
|
end
|
22
19
|
|
23
|
-
def repository
|
24
|
-
workflow['repository']
|
25
|
-
end
|
26
|
-
deprecation_deprecate :repository
|
27
|
-
|
28
20
|
# @param [Integer] version the version we are checking for.
|
29
21
|
def active_for?(version:)
|
30
22
|
result = ng_xml.at_xpath("/workflow/process[@version=#{version}]")
|