dor-workflow-client 7.3.0 → 7.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +7 -7
- data/README.md +50 -0
- data/bin/console +8 -0
- data/lib/dor/workflow/client/lifecycle_routes.rb +0 -1
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/version_routes.rb +0 -1
- data/lib/dor/workflow/client/workflow_routes.rb +5 -5
- data/lib/dor/workflow/client.rb +1 -1
- data/lib/dor/workflow/response/process.rb +7 -0
- data/spec/dor/workflow/client/workflow_routes_spec.rb +42 -2
- data/spec/dor/workflow/client_spec.rb +23 -0
- data/spec/dor/workflow/response/process_spec.rb +28 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e57b379b07c024d6add2d3746c30f042ee10cecef9e5373b85cf697d5538a35
|
4
|
+
data.tar.gz: ae9ba93b8d724464772962044363428ba045716682b35011087b88af6dc5aa05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d6da0f6d3075f8fa335bcc550419a9534974ab76cab28bd2adf39a75ba1eabf75231c207bca89fee8251ee3f7be5549c7378ee68579a7647b0fd261927aff8
|
7
|
+
data.tar.gz: 4331412a8b8b4d6a87f072b79835c377909d7636f7519e8937e91ae844e59ef4ec592aa68bb7205b870b9b98a4e3c33cd4c85cc5c8428b14368cce3a560d54b5
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dor-workflow-client (7.
|
4
|
+
dor-workflow-client (7.4.0)
|
5
5
|
activesupport (>= 3.2.1, < 8)
|
6
6
|
deprecation (>= 0.99.0)
|
7
7
|
faraday (~> 2.0)
|
@@ -42,23 +42,23 @@ GEM
|
|
42
42
|
faraday-net_http (>= 2.0, < 3.2)
|
43
43
|
faraday-net_http (3.1.0)
|
44
44
|
net-http
|
45
|
-
faraday-retry (2.2.
|
45
|
+
faraday-retry (2.2.1)
|
46
46
|
faraday (~> 2.0)
|
47
47
|
hashdiff (1.1.0)
|
48
48
|
i18n (1.14.4)
|
49
49
|
concurrent-ruby (~> 1.0)
|
50
50
|
json (2.7.2)
|
51
51
|
language_server-protocol (3.17.0.3)
|
52
|
-
mini_portile2 (2.8.
|
52
|
+
mini_portile2 (2.8.6)
|
53
53
|
minitest (5.22.3)
|
54
54
|
mutex_m (0.2.0)
|
55
55
|
net-http (0.4.1)
|
56
56
|
uri
|
57
|
-
nokogiri (1.16.
|
57
|
+
nokogiri (1.16.4)
|
58
58
|
mini_portile2 (~> 2.8.2)
|
59
59
|
racc (~> 1.4)
|
60
60
|
parallel (1.24.0)
|
61
|
-
parser (3.3.0
|
61
|
+
parser (3.3.1.0)
|
62
62
|
ast (~> 2.4.1)
|
63
63
|
racc
|
64
64
|
public_suffix (5.0.5)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
rspec-support (3.13.1)
|
83
83
|
rspec_junit_formatter (0.6.0)
|
84
84
|
rspec-core (>= 2, < 4, != 2.12.0)
|
85
|
-
rubocop (1.63.
|
85
|
+
rubocop (1.63.4)
|
86
86
|
json (~> 2.3)
|
87
87
|
language_server-protocol (>= 3.17.0)
|
88
88
|
parallel (~> 1.10)
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
rubocop-capybara (~> 2.17)
|
107
107
|
rubocop-factory_bot (~> 2.22)
|
108
108
|
rubocop-rspec_rails (~> 2.28)
|
109
|
-
rubocop-rspec_rails (2.28.
|
109
|
+
rubocop-rspec_rails (2.28.3)
|
110
110
|
rubocop (~> 1.40)
|
111
111
|
ruby-progressbar (1.13.0)
|
112
112
|
simplecov (0.22.0)
|
data/README.md
CHANGED
@@ -19,15 +19,47 @@ client = Dor::Workflow::Client.new(url: 'https://test-server.edu/workflow/')
|
|
19
19
|
|
20
20
|
Consumers of recent versions of the [dor-services](https://github.com/sul-dlss/dor-services) gem can access the configured `Dor::Workflow::Client` object via `Dor::Config`.
|
21
21
|
|
22
|
+
## Console
|
23
|
+
|
24
|
+
During development, you can test the gem locally on your laptop, hitting a local instance of workflow-server-rails via the console:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
bin/console
|
28
|
+
|
29
|
+
client = Dor::Workflow::Client.new(url: 'http://localhost:3000')
|
30
|
+
client.create_workflow_by_name('druid:bc123df4567', 'accessionWF', version: '1', context: { 'requireOCR' => true})
|
31
|
+
|
32
|
+
client.workflows('druid:bc123df4567')
|
33
|
+
=> ["accessionWF"]
|
34
|
+
|
35
|
+
client.workflow(pid: 'druid:bc123df4567', workflow_name: 'accessionWF')
|
36
|
+
=> #<Dor::Workflow::Response::Workflow:0x0000000105c8b440
|
37
|
+
|
38
|
+
client.process(pid: 'druid:bc123df4567', workflow_name: 'accessionWF', process: 'start-accession').context
|
39
|
+
=> {"requireOCR"=>true}
|
40
|
+
|
41
|
+
client.all_workflows(pid: 'druid:bc123df4567')
|
42
|
+
=> #<Dor::Workflow::Response::Workflows:0x00000001055d29a0>.....
|
43
|
+
```
|
44
|
+
|
22
45
|
## API
|
23
46
|
[Rubydoc](https://www.rubydoc.info/github/sul-dlss/dor-workflow-client/main)
|
24
47
|
|
48
|
+
### Workflow Variables
|
49
|
+
|
50
|
+
If a workflow or workflows for a particular object require data to be persisted and available between steps, workflow variables can be set. These are per object/version pair and thus available to any step in any workflow for a given version of an object once set. Pass in a context variable as a Hash as shown in the example below. The context will be returned as a hash when fetching workflows data for an object.
|
51
|
+
|
25
52
|
### Example usage
|
26
53
|
Create a workflow
|
27
54
|
```
|
28
55
|
client.create_workflow_by_name('druid:bc123df4567', 'etdSubmitWF', version: '1')
|
29
56
|
```
|
30
57
|
|
58
|
+
Create a workflow and send in context
|
59
|
+
```
|
60
|
+
client.create_workflow_by_name('druid:bc123df4567', 'etdSubmitWF', version: '1', context: { foo: 'bar'} )
|
61
|
+
```
|
62
|
+
|
31
63
|
Update a workflow step's status
|
32
64
|
```ruby
|
33
65
|
client.update_status(druid: 'druid:bc123df4567',
|
@@ -36,6 +68,24 @@ client.update_status(druid: 'druid:bc123df4567',
|
|
36
68
|
status: 'completed')
|
37
69
|
```
|
38
70
|
|
71
|
+
Fetch information about a workflow:
|
72
|
+
```ruby
|
73
|
+
client.workflow(pid: 'druid:bc123df4567', workflow_name: 'etdSubmitWF')
|
74
|
+
=> #<Dor::Workflow::Response::Workflow:0x000000010cb28588
|
75
|
+
```
|
76
|
+
|
77
|
+
Fetch information about a workflow step:
|
78
|
+
```ruby
|
79
|
+
client.process(pid: 'druid:bc123df4567', workflow_name: 'etdSubmitWF', process: 'registrar-approval')
|
80
|
+
=> #<Dor::Workflow::Response::Process:0x000000010c505098
|
81
|
+
```
|
82
|
+
|
83
|
+
Fetch version context about a workflow step:
|
84
|
+
```ruby
|
85
|
+
client.process(pid: 'druid:bc123df4567', workflow_name: 'etdSubmitWF', process: 'registrar-approval').context
|
86
|
+
=> {"foo"=>"bar"}
|
87
|
+
```
|
88
|
+
|
39
89
|
Show "milestones" for an object
|
40
90
|
```ruby
|
41
91
|
client.milestones(druid: 'druid:gv054hp4128')
|
data/bin/console
ADDED
@@ -11,7 +11,6 @@ module Dor
|
|
11
11
|
|
12
12
|
# Returns the Date for a requested milestone from workflow lifecycle
|
13
13
|
#
|
14
|
-
# @param [String] repo The repository the object resides in. This parameter is deprecated
|
15
14
|
# @param [String] druid object id
|
16
15
|
# @param [String] milestone_name the name of the milestone being queried for
|
17
16
|
# @param [Number] version (nil) the version to query for
|
@@ -14,7 +14,6 @@ module Dor
|
|
14
14
|
# - completes the versioningWF:submit-version and versioningWF:start-accession steps
|
15
15
|
# - initiates accesssionWF
|
16
16
|
#
|
17
|
-
# @param [String] repo The repository the object resides in. This parameter is deprecated
|
18
17
|
# @param [String] druid The id of the object to delete the workflow from
|
19
18
|
# @param [Boolean] create_accession_wf Option to create accessionWF when closing a version. Defaults to true
|
20
19
|
def close_version(druid:, version:, create_accession_wf: true)
|
@@ -17,13 +17,15 @@ module Dor
|
|
17
17
|
# @param [String] workflow_name The name of the workflow you want to create. This must correspond with a workflow
|
18
18
|
# name that is known by the workflow service.
|
19
19
|
# @param [String] lane_id adds laneId attribute to all process elements in the wf_xml workflow xml. Defaults to a value of 'default'
|
20
|
+
# @param [Hash] context optional context to be included in the workflow (same for all processes for a given druid/version pair)
|
20
21
|
# @param [Integer] version specifies the version so that workflow service doesn't need to query dor-services.
|
21
22
|
# @return [Boolean] always true
|
22
23
|
#
|
23
|
-
def create_workflow_by_name(druid, workflow_name, version:, lane_id: 'default')
|
24
|
+
def create_workflow_by_name(druid, workflow_name, version:, lane_id: 'default', context: nil)
|
24
25
|
params = { 'lane-id' => lane_id, 'version' => version }
|
25
|
-
|
26
|
-
|
26
|
+
body = context ? { 'context' => context }.to_json : ''
|
27
|
+
requestor.request "objects/#{druid}/workflows/#{workflow_name}", 'post', body,
|
28
|
+
content_type: 'application/json',
|
27
29
|
params: params
|
28
30
|
true
|
29
31
|
end
|
@@ -31,7 +33,6 @@ module Dor
|
|
31
33
|
# Updates the status of one step in a workflow.
|
32
34
|
# Returns true on success. Caller must handle any exceptions
|
33
35
|
#
|
34
|
-
# @param [String] repo The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
|
35
36
|
# @param [String] druid The id of the object
|
36
37
|
# @param [String] workflow The name of the workflow
|
37
38
|
# @param [String] process The name of the process step
|
@@ -61,7 +62,6 @@ module Dor
|
|
61
62
|
|
62
63
|
#
|
63
64
|
# Retrieves the process status of the given workflow for the given object identifier
|
64
|
-
# @param [String] repo The repository the object resides in. Currently recoginzes "dor" and "sdr".
|
65
65
|
# @param [String] druid The id of the object
|
66
66
|
# @param [String] workflow The name of the workflow
|
67
67
|
# @param [String] process The name of the process step
|
data/lib/dor/workflow/client.rb
CHANGED
@@ -40,7 +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 :create_workflow_by_name, :workflow_status, :workflows,
|
43
|
+
delegate :create_workflow_by_name, :workflow_status, :workflows, :all_workflows,
|
44
44
|
:workflow, :process, :delete_workflow, :delete_all_workflows, :update_status, :update_error_status,
|
45
45
|
to: :workflow_routes
|
46
46
|
|
@@ -51,6 +51,13 @@ module Dor
|
|
51
51
|
@attributes[:laneId].presence
|
52
52
|
end
|
53
53
|
|
54
|
+
# @return [Hash] the context for the process (or empty hash if none present)
|
55
|
+
def context
|
56
|
+
return {} unless @attributes[:context].present?
|
57
|
+
|
58
|
+
JSON.parse(@attributes[:context])
|
59
|
+
end
|
60
|
+
|
54
61
|
delegate :pid, :workflow_name, to: :parent
|
55
62
|
|
56
63
|
private
|
@@ -169,8 +169,48 @@ RSpec.describe Dor::Workflow::Client::WorkflowRoutes do
|
|
169
169
|
end
|
170
170
|
|
171
171
|
describe '#create_workflow_by_name' do
|
172
|
-
|
173
|
-
|
172
|
+
let(:mock_requestor) { instance_double(Dor::Workflow::Client::Requestor, request: nil) }
|
173
|
+
|
174
|
+
context 'with default lane_id and no context' do
|
175
|
+
subject(:create_workflow_by_name) do
|
176
|
+
routes.create_workflow_by_name('druid:mw971zk1113', 'accessionWF', version: '1')
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'sends a create request with default lane_id and without any context param' do
|
180
|
+
create_workflow_by_name
|
181
|
+
expect(mock_requestor).to have_received(:request)
|
182
|
+
.with('objects/druid:mw971zk1113/workflows/accessionWF', 'post', '',
|
183
|
+
{ content_type: 'application/json',
|
184
|
+
params: { 'lane-id' => 'default', 'version' => '1' } })
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'with a custom lane_id' do
|
189
|
+
subject(:create_workflow_by_name) do
|
190
|
+
routes.create_workflow_by_name('druid:mw971zk1113', 'accessionWF', version: '1', lane_id: 'hamburgers')
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'sends a create request without any context param' do
|
194
|
+
create_workflow_by_name
|
195
|
+
expect(mock_requestor).to have_received(:request)
|
196
|
+
.with('objects/druid:mw971zk1113/workflows/accessionWF', 'post', '',
|
197
|
+
{ content_type: 'application/json',
|
198
|
+
params: { 'lane-id' => 'hamburgers', 'version' => '1' } })
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context 'when context is sent' do
|
203
|
+
subject(:create_workflow_by_name) do
|
204
|
+
routes.create_workflow_by_name('druid:mw971zk1113', 'accessionWF', version: '1', lane_id: 'default', context: { foo: 'bar' })
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'sends a create request with the context in the body' do
|
208
|
+
create_workflow_by_name
|
209
|
+
expect(mock_requestor).to have_received(:request)
|
210
|
+
.with('objects/druid:mw971zk1113/workflows/accessionWF', 'post', '{"context":{"foo":"bar"}}',
|
211
|
+
{ content_type: 'application/json',
|
212
|
+
params: { 'lane-id' => 'default', 'version' => '1' } })
|
213
|
+
end
|
174
214
|
end
|
175
215
|
end
|
176
216
|
end
|
@@ -225,6 +225,29 @@ RSpec.describe Dor::Workflow::Client do
|
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
228
|
+
describe '#all_workflows' do
|
229
|
+
let(:xml) do
|
230
|
+
<<~XML
|
231
|
+
<workflows objectId="druid:123">
|
232
|
+
<workflow repository="dor" objectId="druid:123" id="accessionWF">
|
233
|
+
<process laneId="default" lifecycle="submitted" elapsed="0.0" attempts="1" datetime="2013-02-18T15:08:10-0800" status="completed" name="start-accession"/>
|
234
|
+
</workflow>
|
235
|
+
</workflows>
|
236
|
+
XML
|
237
|
+
end
|
238
|
+
let(:stubs) do
|
239
|
+
Faraday::Adapter::Test::Stubs.new do |stub|
|
240
|
+
stub.get("/objects/#{@druid}/workflows") do |_env|
|
241
|
+
[200, {}, xml]
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
it 'returns the workflow details associated with druid' do
|
247
|
+
expect(client.all_workflows(pid: @druid).xml).to eq(xml)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
228
251
|
describe '#lifecycle' do
|
229
252
|
let(:stubs) do
|
230
253
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
@@ -62,4 +62,32 @@ RSpec.describe Dor::Workflow::Response::Process do
|
|
62
62
|
|
63
63
|
it { is_expected.to eq 'default' }
|
64
64
|
end
|
65
|
+
|
66
|
+
describe '#context' do
|
67
|
+
subject { instance.context }
|
68
|
+
|
69
|
+
context 'when context exists' do
|
70
|
+
let(:xml) do
|
71
|
+
<<~XML
|
72
|
+
<workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
|
73
|
+
<process name="start-assembly" laneId="default" context="{"requireOCR":true}">
|
74
|
+
</workflow>
|
75
|
+
XML
|
76
|
+
end
|
77
|
+
|
78
|
+
it { is_expected.to eq({ 'requireOCR' => true }) }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when no context exists' do
|
82
|
+
let(:xml) do
|
83
|
+
<<~XML
|
84
|
+
<workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
|
85
|
+
<process name="start-assembly" laneId="default" context="">
|
86
|
+
</workflow>
|
87
|
+
XML
|
88
|
+
end
|
89
|
+
|
90
|
+
it { is_expected.to eq({}) }
|
91
|
+
end
|
92
|
+
end
|
65
93
|
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: 7.
|
4
|
+
version: 7.4.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: 2024-
|
12
|
+
date: 2024-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- LICENSE.txt
|
121
121
|
- README.md
|
122
122
|
- Rakefile
|
123
|
+
- bin/console
|
123
124
|
- dor-workflow-client.gemspec
|
124
125
|
- lib/dor/missing_workflow_exception.rb
|
125
126
|
- lib/dor/workflow/client.rb
|
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
|
-
rubygems_version: 3.5.
|
172
|
+
rubygems_version: 3.5.9
|
172
173
|
signing_key:
|
173
174
|
specification_version: 4
|
174
175
|
summary: Provides convenience methods to work with the DOR Workflow Service
|