dor-workflow-client 4.0.0 → 5.1.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/.github/pull_request_template.md +3 -5
- data/.gitignore +0 -2
- data/.rubocop.yml +33 -1
- data/.rubocop_todo.yml +6 -12
- data/Gemfile.lock +123 -0
- data/dor-workflow-client.gemspec +1 -2
- data/lib/dor/workflow/client/connection_factory.rb +2 -4
- data/lib/dor/workflow/client/lifecycle_routes.rb +4 -71
- data/lib/dor/workflow/client/queues.rb +11 -44
- data/lib/dor/workflow/client/status.rb +0 -2
- 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 +9 -147
- 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/connection_factory_spec.rb +2 -2
- data/spec/workflow/client/lifecycle_routes_spec.rb +18 -152
- data/spec/workflow/client/version_routes_spec.rb +1 -44
- data/spec/workflow/client/workflow_routes_spec.rb +13 -0
- data/spec/workflow/client_spec.rb +9 -258
- metadata +9 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c58569c11d2c599671ecf4fef09158bdf37191c93c4193d96d2e6be614d9eeaa
|
4
|
+
data.tar.gz: ce8f53542aede57b9386ec769673fac4af7a92d9bb32b2c9a00ba9fe59ae6754
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e09e2e40204d869c31ce832509ccf4582d98823cd767348966789a5961bfb2ae3b67b148a35a41f734fb782100bef10619e36a1f44e244a70685d3a1d6613f90
|
7
|
+
data.tar.gz: 2ddd5435a3f7738a48800182c46e1d243bf9bdaf457d367f7f26d0a7868c61005f853850a18aba61c97475c74bf297b08060fc7a51fdadd76161d90b4287cebc
|
data/.circleci/config.yml
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
## Why was this change made?
|
1
|
+
## Why was this change made? 🤔
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
## How was this change tested?
|
5
|
+
## How was this change tested? 🤨
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
## Which documentation and/or configurations were updated?
|
7
|
+
⚡ ⚠ If this change affects the API or other fundamentals of this service, ***run [integration tests](https://github.com/sul-dlss/infrastructure-integration-test)*** that exercise this service and/or test in [stage|qa] environment, in addition to specs. ⚡
|
10
8
|
|
11
9
|
|
12
10
|
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -10,7 +10,10 @@ Metrics/BlockLength:
|
|
10
10
|
Exclude:
|
11
11
|
- spec/**/*_spec.rb
|
12
12
|
|
13
|
-
|
13
|
+
Lint/UnusedBlockArgument:
|
14
|
+
AllowUnusedKeywordArguments: true
|
15
|
+
|
16
|
+
Gemspec/DeprecatedAttributeAssignment: # new in 1.10
|
14
17
|
Enabled: true
|
15
18
|
Gemspec/RequireMFA: # new in 1.23
|
16
19
|
Enabled: true
|
@@ -112,3 +115,32 @@ Style/StringChars: # new in 1.12
|
|
112
115
|
Enabled: true
|
113
116
|
Style/SwapValues: # new in 1.1
|
114
117
|
Enabled: true
|
118
|
+
|
119
|
+
Layout/LineContinuationLeadingSpace: # new in 1.31
|
120
|
+
Enabled: true
|
121
|
+
Layout/LineContinuationSpacing: # new in 1.31
|
122
|
+
Enabled: true
|
123
|
+
Lint/ConstantOverwrittenInRescue: # new in 1.31
|
124
|
+
Enabled: true
|
125
|
+
Lint/NonAtomicFileOperation: # new in 1.31
|
126
|
+
Enabled: true
|
127
|
+
Lint/RefinementImportMethods: # new in 1.27
|
128
|
+
Enabled: true
|
129
|
+
Lint/RequireRangeParentheses: # new in 1.32
|
130
|
+
Enabled: true
|
131
|
+
Security/CompoundHash: # new in 1.28
|
132
|
+
Enabled: true
|
133
|
+
Style/EmptyHeredoc: # new in 1.32
|
134
|
+
Enabled: true
|
135
|
+
Style/EnvHome: # new in 1.29
|
136
|
+
Enabled: true
|
137
|
+
Style/FetchEnvVar: # new in 1.28
|
138
|
+
Enabled: true
|
139
|
+
Style/MapCompactWithConditionalBlock: # new in 1.30
|
140
|
+
Enabled: true
|
141
|
+
Style/NestedFileDirname: # new in 1.26
|
142
|
+
Enabled: true
|
143
|
+
Style/ObjectThen: # new in 1.28
|
144
|
+
Enabled: true
|
145
|
+
Style/RedundantInitialize: # new in 1.27
|
146
|
+
Enabled: true
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2022-
|
3
|
+
# on 2022-06-28 04:56:14 UTC using RuboCop version 1.31.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -27,23 +27,17 @@ Lint/NoReturnInBeginEndBlocks:
|
|
27
27
|
# Offense count: 5
|
28
28
|
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
29
29
|
Metrics/AbcSize:
|
30
|
-
Max:
|
31
|
-
|
32
|
-
# Offense count: 1
|
33
|
-
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
34
|
-
# IgnoredMethods: refine
|
35
|
-
Metrics/BlockLength:
|
36
|
-
Max: 26
|
30
|
+
Max: 23
|
37
31
|
|
38
32
|
# Offense count: 2
|
39
33
|
# Configuration parameters: IgnoredMethods.
|
40
34
|
Metrics/CyclomaticComplexity:
|
41
35
|
Max: 8
|
42
36
|
|
43
|
-
# Offense count:
|
37
|
+
# Offense count: 2
|
44
38
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
45
39
|
Metrics/MethodLength:
|
46
|
-
Max:
|
40
|
+
Max: 19
|
47
41
|
|
48
42
|
# Offense count: 3
|
49
43
|
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
@@ -51,13 +45,13 @@ Metrics/ParameterLists:
|
|
51
45
|
Max: 8
|
52
46
|
|
53
47
|
# Offense count: 1
|
54
|
-
#
|
48
|
+
# This cop supports safe autocorrection (--autocorrect).
|
55
49
|
Style/KeywordParametersOrder:
|
56
50
|
Exclude:
|
57
51
|
- 'lib/dor/workflow/client/workflow_routes.rb'
|
58
52
|
|
59
53
|
# Offense count: 1
|
60
|
-
#
|
54
|
+
# This cop supports safe autocorrection (--autocorrect).
|
61
55
|
# Configuration parameters: AllowModifier.
|
62
56
|
Style/SoleNestedConditional:
|
63
57
|
Exclude:
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dor-workflow-client (5.1.0)
|
5
|
+
activesupport (>= 3.2.1, < 8)
|
6
|
+
deprecation (>= 0.99.0)
|
7
|
+
faraday (~> 2.0)
|
8
|
+
faraday-retry (~> 2.0)
|
9
|
+
nokogiri (~> 1.6)
|
10
|
+
zeitwerk (~> 2.1)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activesupport (7.0.3.1)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
addressable (2.8.0)
|
21
|
+
public_suffix (>= 2.0.2, < 5.0)
|
22
|
+
ast (2.4.2)
|
23
|
+
byebug (11.1.3)
|
24
|
+
concurrent-ruby (1.1.10)
|
25
|
+
crack (0.4.5)
|
26
|
+
rexml
|
27
|
+
deprecation (1.1.0)
|
28
|
+
activesupport
|
29
|
+
diff-lcs (1.5.0)
|
30
|
+
docile (1.4.0)
|
31
|
+
faraday (2.4.0)
|
32
|
+
faraday-net_http (~> 2.0)
|
33
|
+
ruby2_keywords (>= 0.0.4)
|
34
|
+
faraday-net_http (2.1.0)
|
35
|
+
faraday-retry (2.0.0)
|
36
|
+
faraday (~> 2.0)
|
37
|
+
hashdiff (1.0.1)
|
38
|
+
i18n (1.12.0)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
json (2.6.2)
|
41
|
+
mini_portile2 (2.8.0)
|
42
|
+
minitest (5.16.2)
|
43
|
+
nokogiri (1.13.8)
|
44
|
+
mini_portile2 (~> 2.8.0)
|
45
|
+
racc (~> 1.4)
|
46
|
+
parallel (1.22.1)
|
47
|
+
parser (3.1.2.0)
|
48
|
+
ast (~> 2.4.1)
|
49
|
+
public_suffix (4.0.7)
|
50
|
+
racc (1.6.0)
|
51
|
+
rainbow (3.1.1)
|
52
|
+
rake (13.0.6)
|
53
|
+
regexp_parser (2.5.0)
|
54
|
+
rexml (3.2.5)
|
55
|
+
rspec (3.11.0)
|
56
|
+
rspec-core (~> 3.11.0)
|
57
|
+
rspec-expectations (~> 3.11.0)
|
58
|
+
rspec-mocks (~> 3.11.0)
|
59
|
+
rspec-core (3.11.0)
|
60
|
+
rspec-support (~> 3.11.0)
|
61
|
+
rspec-expectations (3.11.0)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.11.0)
|
64
|
+
rspec-mocks (3.11.1)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.11.0)
|
67
|
+
rspec-support (3.11.0)
|
68
|
+
rspec_junit_formatter (0.5.1)
|
69
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
70
|
+
rubocop (1.33.0)
|
71
|
+
json (~> 2.3)
|
72
|
+
parallel (~> 1.10)
|
73
|
+
parser (>= 3.1.0.0)
|
74
|
+
rainbow (>= 2.2.2, < 4.0)
|
75
|
+
regexp_parser (>= 1.8, < 3.0)
|
76
|
+
rexml (>= 3.2.5, < 4.0)
|
77
|
+
rubocop-ast (>= 1.19.1, < 2.0)
|
78
|
+
ruby-progressbar (~> 1.7)
|
79
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
80
|
+
rubocop-ast (1.19.1)
|
81
|
+
parser (>= 3.1.1.0)
|
82
|
+
rubocop-rake (0.6.0)
|
83
|
+
rubocop (~> 1.0)
|
84
|
+
rubocop-rspec (2.12.1)
|
85
|
+
rubocop (~> 1.31)
|
86
|
+
ruby-progressbar (1.11.0)
|
87
|
+
ruby2_keywords (0.0.5)
|
88
|
+
simplecov (0.21.2)
|
89
|
+
docile (~> 1.1)
|
90
|
+
simplecov-html (~> 0.11)
|
91
|
+
simplecov_json_formatter (~> 0.1)
|
92
|
+
simplecov-html (0.12.3)
|
93
|
+
simplecov_json_formatter (0.1.4)
|
94
|
+
tzinfo (2.0.5)
|
95
|
+
concurrent-ruby (~> 1.0)
|
96
|
+
unicode-display_width (2.2.0)
|
97
|
+
webmock (3.16.0)
|
98
|
+
addressable (>= 2.8.0)
|
99
|
+
crack (>= 0.3.2)
|
100
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
101
|
+
webrick (1.7.0)
|
102
|
+
yard (0.9.28)
|
103
|
+
webrick (~> 1.7.0)
|
104
|
+
zeitwerk (2.6.0)
|
105
|
+
|
106
|
+
PLATFORMS
|
107
|
+
ruby
|
108
|
+
|
109
|
+
DEPENDENCIES
|
110
|
+
byebug
|
111
|
+
dor-workflow-client!
|
112
|
+
rake
|
113
|
+
rspec (~> 3.3)
|
114
|
+
rspec_junit_formatter
|
115
|
+
rubocop (~> 1.24)
|
116
|
+
rubocop-rake
|
117
|
+
rubocop-rspec (~> 2.1)
|
118
|
+
simplecov
|
119
|
+
webmock
|
120
|
+
yard
|
121
|
+
|
122
|
+
BUNDLED WITH
|
123
|
+
2.3.17
|
data/dor-workflow-client.gemspec
CHANGED
@@ -14,14 +14,13 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.homepage = 'https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow'
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
17
|
-
gem.test_files = gem.files.grep(%r{^(spec)/})
|
18
17
|
gem.require_paths = ['lib']
|
19
18
|
gem.required_ruby_version = '>= 2.7'
|
20
19
|
|
21
20
|
gem.add_dependency 'activesupport', '>= 3.2.1', '< 8'
|
22
21
|
gem.add_dependency 'deprecation', '>= 0.99.0'
|
23
22
|
gem.add_dependency 'faraday', '~> 2.0'
|
24
|
-
gem.add_dependency 'faraday-retry'
|
23
|
+
gem.add_dependency 'faraday-retry', '~> 2.0'
|
25
24
|
|
26
25
|
gem.add_dependency 'nokogiri', '~> 1.6'
|
27
26
|
gem.add_dependency 'zeitwerk', '~> 2.1'
|
@@ -15,7 +15,6 @@ module Dor
|
|
15
15
|
@logger = logger
|
16
16
|
end
|
17
17
|
|
18
|
-
# rubocop:disable Metrics/MethodLength
|
19
18
|
def build_connection
|
20
19
|
Faraday.new(url: url) do |faraday|
|
21
20
|
faraday.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
|
@@ -37,7 +36,6 @@ module Dor
|
|
37
36
|
faraday.adapter Faraday.default_adapter # Last middleware must be the adapter
|
38
37
|
end
|
39
38
|
end
|
40
|
-
# rubocop:enable Metrics/MethodLength
|
41
39
|
|
42
40
|
def user_agent
|
43
41
|
"dor-workflow-client #{VERSION}"
|
@@ -56,8 +54,8 @@ module Dor
|
|
56
54
|
end
|
57
55
|
|
58
56
|
def retry_block
|
59
|
-
lambda do |env
|
60
|
-
logger.warn "retrying connection (#{
|
57
|
+
lambda do |env:, options:, retry_count:, exception:, will_retry_in:|
|
58
|
+
logger.warn "retrying connection (#{retry_count + 1}) to #{env.url}: (#{exception.class}) " \
|
61
59
|
"#{exception.message} #{env.status}"
|
62
60
|
end
|
63
61
|
end
|
@@ -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,57 +28,17 @@ 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
|
-
|
88
|
-
def milestones(*args)
|
89
|
-
case args.size
|
90
|
-
when 2
|
91
|
-
Deprecation.warn(self, 'you provided 2 args, but active_lifecycle now takes kwargs')
|
92
|
-
(repo, druid) = args
|
93
|
-
when 1
|
94
|
-
opts = args.first
|
95
|
-
repo = opts[:repo]
|
96
|
-
druid = opts.fetch(:druid)
|
97
|
-
else
|
98
|
-
raise ArgumentError, 'wrong number of arguments, must be 1-2'
|
99
|
-
end
|
100
|
-
|
101
|
-
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
|
102
|
-
|
36
|
+
def milestones(druid:)
|
103
37
|
doc = query_lifecycle(druid, active_only: false)
|
104
38
|
doc.xpath('//lifecycle/milestone').collect do |node|
|
105
39
|
{ milestone: node.text, at: Time.parse(node['date']), version: node['version'] }
|
106
40
|
end
|
107
41
|
end
|
108
|
-
# rubocop:enable Metrics/MethodLength
|
109
42
|
|
110
43
|
private
|
111
44
|
|
@@ -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
|
-
#
|
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?
|
116
|
+
# blah blah. See logger for details>"}
|
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
|
|
@@ -42,7 +42,6 @@ module Dor
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# @return [Hash{Symbol => Object}] including :status_code and :status_time
|
45
|
-
# rubocop:disable Metrics/MethodLength
|
46
45
|
def info
|
47
46
|
@info ||= begin
|
48
47
|
# if we have an accessioned milestone, this is the last possible step and should be the status regardless of time stamp
|
@@ -64,7 +63,6 @@ module Dor
|
|
64
63
|
{ status_code: status_code, status_time: status_time }
|
65
64
|
end
|
66
65
|
end
|
67
|
-
# rubocop:enable Metrics/MethodLength
|
68
66
|
|
69
67
|
def status_code
|
70
68
|
info.fetch(:status_code)
|
@@ -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
|
|