dor-workflow-service 1.6.3 → 1.7.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 +8 -8
- data/lib/dor/services/workflow_service.rb +51 -38
- data/lib/dor/workflow_version.rb +1 -1
- data/spec/workflow_service_spec.rb +69 -40
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTY2Zjg1ZWZlYmI4ZTI2ZmYxZTBlYjI1NTgzYWFhZWIxOWFmZTY4Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmM5ZDU5YTQ5ZTBjY2IwMDVmYzM3YTUxODU3MTc0YmFmMDQ4MGFhNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzM2ZjgwYzRjNmE3MjFjZDM0NmIwZjczMDg0OWJkYWUwOTZkMzNiOWQzYzM1
|
10
|
+
MDk1OTNmZDQ5Y2U5YjRmNjNjYmFlYTQ4NzYwMjc4ZWRhMWZiYzkwMTk0M2My
|
11
|
+
YjdhYmQzMmQ5NjBjOGFhZjA4YzdlMjYwNWY0YmU5MWYwZTczNWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Njg3N2ZkNTVjYzdiZmIyYjQ1OTE3ZGY1OGY5Y2MwM2RlYTYzYzllZTk0Nzlj
|
14
|
+
ZWI0MTZlYWE2NGVhMmQyOWEwNWIwOWIwOTBkMTY2NmU2OWI3MTkzZWE2MDYw
|
15
|
+
ZDY2ZGFhMzhiYzIwNTBjMmQ5NjNlZjJkMTIyODIzNzMwODM2Nzg=
|
@@ -25,29 +25,17 @@ module Dor
|
|
25
25
|
# @param [Hash] opts optional params
|
26
26
|
# @option opts [Boolean] :create_ds if true, a workflow datastream will be created in Fedora. Set to false if you do not want a datastream to be created
|
27
27
|
# If you do not pass in an <b>opts</b> Hash, then :create_ds is set to true by default
|
28
|
-
# @option opts [
|
28
|
+
# @option opts [String] :lane_id adds laneId attribute to all process elements in the wf_xml workflow xml. Defaults to a value of 'default'
|
29
29
|
# @return [Boolean] always true
|
30
30
|
#
|
31
31
|
def create_workflow(repo, druid, workflow_name, wf_xml, opts = {:create_ds => true})
|
32
|
-
|
33
|
-
xml =
|
32
|
+
lane_id = opts.fetch(:lane_id, 'default')
|
33
|
+
xml = add_lane_id_to_workflow_xml(lane_id, wf_xml)
|
34
34
|
workflow_resource["#{repo}/objects/#{druid}/workflows/#{workflow_name}"].put(xml, :content_type => 'application/xml',
|
35
35
|
:params => {'create-ds' => opts[:create_ds] })
|
36
36
|
return true
|
37
37
|
end
|
38
38
|
|
39
|
-
# Adds priority attributes to each process of workflow xml
|
40
|
-
#
|
41
|
-
# @param [Integer] priority value to add to each process element
|
42
|
-
# @param [String] wf_xml the workflow xml
|
43
|
-
# @return [String] wf_xml with priority attributes
|
44
|
-
def add_priority_to_workflow_xml(priority, wf_xml)
|
45
|
-
return wf_xml if(priority.to_i == 0)
|
46
|
-
doc = Nokogiri::XML(wf_xml)
|
47
|
-
doc.xpath('/workflow/process').each { |proc| proc['priority'] = priority }
|
48
|
-
doc.to_xml
|
49
|
-
end
|
50
|
-
|
51
39
|
# Updates the status of one step in a workflow.
|
52
40
|
# Returns true on success. Caller must handle any exceptions
|
53
41
|
#
|
@@ -60,7 +48,7 @@ module Dor
|
|
60
48
|
# @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.
|
61
49
|
# @option opts [String] :lifecycle Bookeeping label for this particular workflow step. Examples are: 'registered', 'shelved'
|
62
50
|
# @option opts [String] :note Any kind of string annotation that you want to attach to the workflow
|
63
|
-
# @option opts [
|
51
|
+
# @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')
|
64
52
|
# @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
|
65
53
|
# @return [Boolean] always true
|
66
54
|
# Http Call
|
@@ -244,10 +232,12 @@ module Dor
|
|
244
232
|
# @param [String] waiting name of the waiting step
|
245
233
|
# @param [String] repository default repository to use if it isn't passed in the qualified-step-name
|
246
234
|
# @param [String] workflow default workflow to use if it isn't passed in the qualified-step-name
|
235
|
+
# @param [String] lane_id issue a query for a specific lane_id for the waiting step
|
247
236
|
# @param [Hash] options
|
248
|
-
# @
|
237
|
+
# @param options [String] :default_repository repository to query for if not using the qualified format
|
238
|
+
# @param options [String] :default_workflow workflow to query for if not using the qualified format
|
249
239
|
# @option options [Integer] :limit maximum number of druids to return (nil for no limit)
|
250
|
-
# @return [Array<String
|
240
|
+
# @return [Array<String>] Array of druids
|
251
241
|
#
|
252
242
|
# @example
|
253
243
|
# get_objects_for_workstep(...)
|
@@ -258,25 +248,26 @@ module Dor
|
|
258
248
|
# ]
|
259
249
|
#
|
260
250
|
# @example
|
261
|
-
# get_objects_for_workstep(...,
|
251
|
+
# get_objects_for_workstep(..., "lane1")
|
262
252
|
# => {
|
263
|
-
# "druid:py156ps0477"
|
264
|
-
# "druid:tt628cb6479"
|
265
|
-
# "druid:ct021wp7863" => -100
|
253
|
+
# "druid:py156ps0477",
|
254
|
+
# "druid:tt628cb6479",
|
266
255
|
# }
|
267
256
|
#
|
268
257
|
# @example
|
269
|
-
# get_objects_for_workstep(...,
|
258
|
+
# get_objects_for_workstep(..., "lane1", limit: 1)
|
270
259
|
# => {
|
271
|
-
# "druid:py156ps0477"
|
260
|
+
# "druid:py156ps0477",
|
272
261
|
# }
|
273
262
|
#
|
274
|
-
def get_objects_for_workstep completed, waiting,
|
263
|
+
def get_objects_for_workstep completed, waiting, lane_id='default', options = {}
|
275
264
|
result = nil
|
276
|
-
|
265
|
+
waiting_param = qualify_step(options[:default_repository],options[:default_workflow],waiting)
|
266
|
+
uri_string = "workflow_queue?waiting=#{waiting_param}"
|
277
267
|
if(completed)
|
278
268
|
Array(completed).each do |step|
|
279
|
-
|
269
|
+
completed_param = qualify_step(options[:default_repository],options[:default_workflow],step)
|
270
|
+
uri_string << "&completed=#{completed_param}"
|
280
271
|
end
|
281
272
|
end
|
282
273
|
|
@@ -284,24 +275,22 @@ module Dor
|
|
284
275
|
uri_string << "&limit=#{options[:limit].to_i}"
|
285
276
|
end
|
286
277
|
|
278
|
+
uri_string << "&lane-id=#{lane_id}"
|
279
|
+
|
287
280
|
workflow_resource.options[:timeout] = 5 * 60 unless(workflow_resource.options.include?(:timeout))
|
288
281
|
resp = workflow_resource[uri_string].get
|
289
282
|
#
|
290
283
|
# response looks like:
|
291
284
|
# <objects count="2">
|
292
|
-
# <object id="druid:ab123de4567"
|
293
|
-
# <object id="druid:ab123de9012"
|
285
|
+
# <object id="druid:ab123de4567"/>
|
286
|
+
# <object id="druid:ab123de9012"/>
|
294
287
|
# </objects>
|
295
288
|
#
|
296
289
|
# convert into:
|
297
|
-
#
|
290
|
+
# ['druid:ab123de4567', 'druid:ab123de9012']
|
298
291
|
#
|
299
|
-
result = Nokogiri::XML(resp).xpath('//object[@id]')
|
300
|
-
|
301
|
-
h
|
302
|
-
end
|
303
|
-
|
304
|
-
options[:with_priority] ? result : result.keys
|
292
|
+
result = Nokogiri::XML(resp).xpath('//object[@id]')
|
293
|
+
result.map { |n| n[:id] }
|
305
294
|
end
|
306
295
|
|
307
296
|
# Get a list of druids that have errored out in a particular workflow and step
|
@@ -333,7 +322,7 @@ module Dor
|
|
333
322
|
# meaning you will get all queued workflows
|
334
323
|
# @option opts [Integer] :limit sets the maximum number of workflow steps that can be returned. Defaults to no limit
|
335
324
|
# @return [Array[Hash]] each Hash represents a workflow step. It will have the following keys:
|
336
|
-
# :workflow, :step, :druid, :
|
325
|
+
# :workflow, :step, :druid, :lane_id
|
337
326
|
def get_stale_queued_workflows(repository, opts = {})
|
338
327
|
uri_string = build_queued_uri(repository, opts)
|
339
328
|
xml = workflow_resource[uri_string].get
|
@@ -403,6 +392,19 @@ module Dor
|
|
403
392
|
return true
|
404
393
|
end
|
405
394
|
|
395
|
+
# Returns all the distinct laneIds for a given workflow step
|
396
|
+
#
|
397
|
+
# @param [String] repo The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
|
398
|
+
# @param [String] workflow name
|
399
|
+
# @param [String] process name
|
400
|
+
# @return [Array<String>] all of the distinct laneIds. Array will be empty if no lane ids were found
|
401
|
+
def get_lane_ids(repo, workflow, process)
|
402
|
+
uri = "workflow_queue/lane_ids?step=#{repo}:#{workflow}:#{process}"
|
403
|
+
doc = Nokogiri::XML(workflow_resource[uri].get)
|
404
|
+
nodes = doc.xpath('/lanes/lane')
|
405
|
+
nodes.map {|n| n['id']}
|
406
|
+
end
|
407
|
+
|
406
408
|
# @return [RestClient::Resource] the REST client resource
|
407
409
|
def workflow_resource
|
408
410
|
raise "Please call Dor::WorkflowService.configure(url) once before calling any WorkflowService methods" if(@@resource.nil?)
|
@@ -445,12 +447,23 @@ module Dor
|
|
445
447
|
wf[:workflow] = wf_node['name']
|
446
448
|
wf[:step] = wf_node['process']
|
447
449
|
wf[:druid] = wf_node['druid']
|
448
|
-
wf[:
|
450
|
+
wf[:lane_id] = wf_node['laneId']
|
449
451
|
res << wf
|
450
452
|
end
|
451
453
|
res
|
452
454
|
end
|
453
455
|
|
456
|
+
# Adds laneId attributes to each process of workflow xml
|
457
|
+
#
|
458
|
+
# @param [String] lane_id to add to each process element
|
459
|
+
# @param [String] wf_xml the workflow xml
|
460
|
+
# @return [String] wf_xml with lane_id attributes
|
461
|
+
def add_lane_id_to_workflow_xml(lane_id, wf_xml)
|
462
|
+
doc = Nokogiri::XML(wf_xml)
|
463
|
+
doc.xpath('/workflow/process').each { |proc| proc['laneId'] = lane_id }
|
464
|
+
doc.to_xml
|
465
|
+
end
|
466
|
+
|
454
467
|
end
|
455
468
|
end
|
456
469
|
end
|
data/lib/dor/workflow_version.rb
CHANGED
@@ -15,6 +15,18 @@ describe Dor::WorkflowService do
|
|
15
15
|
EOXML
|
16
16
|
}
|
17
17
|
|
18
|
+
let(:wf_xml_label) { <<-EOXML
|
19
|
+
<?xml version="1.0"?>
|
20
|
+
<workflow id="etdSubmitWF">
|
21
|
+
<process name="register-object" status="completed" attempts="1" laneId="default"/>
|
22
|
+
<process name="submit" status="waiting" laneId="default"/>
|
23
|
+
<process name="reader-approval" status="waiting" laneId="default"/>
|
24
|
+
<process name="registrar-approval" status="waiting" laneId="default"/>
|
25
|
+
<process name="start-accession" status="waiting" laneId="default"/>
|
26
|
+
</workflow>
|
27
|
+
EOXML
|
28
|
+
}
|
29
|
+
|
18
30
|
before(:each) do
|
19
31
|
@repo = 'dor'
|
20
32
|
@druid = 'druid:123'
|
@@ -31,7 +43,7 @@ describe Dor::WorkflowService do
|
|
31
43
|
|
32
44
|
describe "#create_workflow" do
|
33
45
|
it "should pass workflow xml to the DOR workflow service and return the URL to the workflow" do
|
34
|
-
@mock_resource.should_receive(:put).with(
|
46
|
+
@mock_resource.should_receive(:put).with(wf_xml_label, anything()).and_return('')
|
35
47
|
Dor::WorkflowService.create_workflow(@repo, @druid, 'etdSubmitWF', wf_xml)
|
36
48
|
end
|
37
49
|
|
@@ -42,31 +54,31 @@ describe Dor::WorkflowService do
|
|
42
54
|
end
|
43
55
|
|
44
56
|
it "sets the create-ds param to the value of the passed in options hash" do
|
45
|
-
@mock_resource.should_receive(:put).with(
|
57
|
+
@mock_resource.should_receive(:put).with(wf_xml_label, :content_type => 'application/xml',
|
46
58
|
:params => {'create-ds' => false}).and_return('')
|
47
59
|
Dor::WorkflowService.create_workflow(@repo, @druid, 'etdSubmitWF', wf_xml, :create_ds => false)
|
48
60
|
end
|
49
61
|
|
50
|
-
it "adds
|
62
|
+
it "adds lane_id attributes to all steps if passed in as an option" do
|
51
63
|
|
52
64
|
end
|
53
65
|
|
54
66
|
end
|
55
67
|
|
56
|
-
describe "#
|
68
|
+
describe "#add_lane_id_to_workflow_xml" do
|
57
69
|
|
58
|
-
it "adds
|
70
|
+
it "adds laneId attributes to all process elements" do
|
59
71
|
expected = <<-XML
|
60
72
|
<workflow id="etdSubmitWF">
|
61
|
-
<process name="register-object" status="completed" attempts="1"
|
62
|
-
<process name="submit" status="waiting"
|
63
|
-
<process name="reader-approval" status="waiting"
|
64
|
-
<process name="registrar-approval" status="waiting"
|
65
|
-
<process name="start-accession" status="waiting"
|
73
|
+
<process name="register-object" status="completed" attempts="1" laneId="lane1"/>
|
74
|
+
<process name="submit" status="waiting" laneId="lane1"/>
|
75
|
+
<process name="reader-approval" status="waiting" laneId="lane1"/>
|
76
|
+
<process name="registrar-approval" status="waiting" laneId="lane1"/>
|
77
|
+
<process name="start-accession" status="waiting" laneId="lane1"/>
|
66
78
|
</workflow>
|
67
79
|
XML
|
68
80
|
|
69
|
-
Dor::WorkflowService.
|
81
|
+
Dor::WorkflowService.send(:add_lane_id_to_workflow_xml, 'lane1', wf_xml).should be_equivalent_to(expected)
|
70
82
|
end
|
71
83
|
end
|
72
84
|
|
@@ -76,8 +88,9 @@ describe Dor::WorkflowService do
|
|
76
88
|
end
|
77
89
|
|
78
90
|
it "should update workflow status and return true if successful" do
|
79
|
-
|
80
|
-
|
91
|
+
built_xml = "<?xml version=\"1.0\"?>\n<process name=\"reader-approval\" status=\"completed\" elapsed=\"0\" note=\"annotation\" version=\"2\" laneId=\"lane2\"/>\n"
|
92
|
+
@mock_resource.should_receive(:put).with(built_xml, { :content_type => 'application/xml' }).and_return('')
|
93
|
+
Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :lane_id => 'lane2').should be_true
|
81
94
|
end
|
82
95
|
|
83
96
|
it "should return false if the PUT to the DOR workflow service throws an exception" do
|
@@ -87,9 +100,9 @@ describe Dor::WorkflowService do
|
|
87
100
|
end
|
88
101
|
|
89
102
|
it "performs a conditional update when current-status is passed as a parameter" do
|
90
|
-
|
103
|
+
@mock_resource.should_receive(:[]).with("dor/objects/druid:123/workflows/etdSubmitWF/reader-approval?current-status=queued")
|
91
104
|
@mock_resource.should_receive(:put).with(@xml_re, { :content_type => 'application/xml' }).and_return('')
|
92
|
-
Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :
|
105
|
+
Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :lane_id => 'lane1', :current_status => 'queued').should be_true
|
93
106
|
end
|
94
107
|
end
|
95
108
|
|
@@ -168,18 +181,18 @@ describe Dor::WorkflowService do
|
|
168
181
|
|
169
182
|
context "a query with one step completed and one waiting" do
|
170
183
|
it "creates the URI string with only the one completed step" do
|
171
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{@repository}:#{@workflow}:#{@waiting}&completed=#{@repository}:#{@workflow}:#{@completed}")
|
184
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{@repository}:#{@workflow}:#{@waiting}&completed=#{@repository}:#{@workflow}:#{@completed}&lane-id=default")
|
172
185
|
@mock_resource.should_receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
173
|
-
Dor::WorkflowService.get_objects_for_workstep(@completed, @waiting, @repository, @workflow).should == ['druid:ab123de4567','druid:ab123de9012']
|
186
|
+
Dor::WorkflowService.get_objects_for_workstep(@completed, @waiting, 'default', :default_repository => @repository, :default_workflow => @workflow).should == ['druid:ab123de4567','druid:ab123de9012']
|
174
187
|
end
|
175
188
|
end
|
176
189
|
|
177
190
|
context "a query with TWO steps completed and one waiting" do
|
178
191
|
it "creates the URI string with the two completed steps correctly" do
|
179
192
|
second_completed="google-convert"
|
180
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{@repository}:#{@workflow}:#{@waiting}&completed=#{@repository}:#{@workflow}:#{@completed}&completed=#{@repository}:#{@workflow}:#{second_completed}")
|
193
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{@repository}:#{@workflow}:#{@waiting}&completed=#{@repository}:#{@workflow}:#{@completed}&completed=#{@repository}:#{@workflow}:#{second_completed}&lane-id=default")
|
181
194
|
@mock_resource.should_receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
182
|
-
Dor::WorkflowService.get_objects_for_workstep([@completed,second_completed], @waiting, @repository, @workflow).should == ['druid:ab123de4567','druid:ab123de9012']
|
195
|
+
Dor::WorkflowService.get_objects_for_workstep([@completed,second_completed], @waiting, 'default', :default_repository => @repository, :default_workflow => @workflow).should == ['druid:ab123de4567','druid:ab123de9012']
|
183
196
|
end
|
184
197
|
end
|
185
198
|
|
@@ -193,12 +206,12 @@ describe Dor::WorkflowService do
|
|
193
206
|
completed3="ingest-transfer"
|
194
207
|
qualified_completed2 = "#{repo2}:#{workflow2}:#{completed2}"
|
195
208
|
qualified_completed3 = "#{repo2}:#{workflow2}:#{completed3}"
|
196
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}")
|
197
|
-
@mock_resource.should_receive(:get).and_return(%{<objects count="2"><object id="druid:ab123de4567"
|
209
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}&lane-id=default")
|
210
|
+
@mock_resource.should_receive(:get).and_return(%{<objects count="2"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
198
211
|
Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting).should == ['druid:ab123de4567', 'druid:ab123de9012']
|
199
212
|
end
|
200
213
|
|
201
|
-
it "same but with
|
214
|
+
it "same but with lane_id" do
|
202
215
|
qualified_waiting = "#{@repository}:#{@workflow}:#{@waiting}"
|
203
216
|
qualified_completed = "#{@repository}:#{@workflow}:#{@completed}"
|
204
217
|
repo2 = "sdr"
|
@@ -207,9 +220,9 @@ describe Dor::WorkflowService do
|
|
207
220
|
completed3="ingest-transfer"
|
208
221
|
qualified_completed2 = "#{repo2}:#{workflow2}:#{completed2}"
|
209
222
|
qualified_completed3 = "#{repo2}:#{workflow2}:#{completed3}"
|
210
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}")
|
211
|
-
@mock_resource.should_receive(:get).and_return(%{<objects count="2"><object id="druid:ab123de4567"
|
212
|
-
Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting,
|
223
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}&lane-id=lane1")
|
224
|
+
@mock_resource.should_receive(:get).and_return(%{<objects count="2"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
225
|
+
Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting, "lane1").should == [ 'druid:ab123de4567', 'druid:ab123de9012']
|
213
226
|
end
|
214
227
|
|
215
228
|
it "creates the URI string with only one completed step passed in as a String" do
|
@@ -217,7 +230,7 @@ describe Dor::WorkflowService do
|
|
217
230
|
qualified_completed = "#{@repository}:#{@workflow}:#{@completed}"
|
218
231
|
repo2 = "sdr"
|
219
232
|
|
220
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}")
|
233
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&lane-id=default")
|
221
234
|
@mock_resource.should_receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/></objects>})
|
222
235
|
Dor::WorkflowService.get_objects_for_workstep(qualified_completed, qualified_waiting).should == ['druid:ab123de4567']
|
223
236
|
end
|
@@ -225,17 +238,17 @@ describe Dor::WorkflowService do
|
|
225
238
|
it "creates the URI string without any completed steps, only waiting" do
|
226
239
|
qualified_waiting = "#{@repository}:#{@workflow}:#{@waiting}"
|
227
240
|
|
228
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}")
|
241
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&lane-id=default")
|
229
242
|
@mock_resource.should_receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/></objects>})
|
230
243
|
Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting).should == ['druid:ab123de4567']
|
231
244
|
end
|
232
245
|
|
233
|
-
it "same but with
|
246
|
+
it "same but with lane_id" do
|
234
247
|
qualified_waiting = "#{@repository}:#{@workflow}:#{@waiting}"
|
235
248
|
|
236
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}")
|
237
|
-
@mock_resource.should_receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"
|
238
|
-
Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting,
|
249
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&lane-id=lane1")
|
250
|
+
@mock_resource.should_receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/></objects>})
|
251
|
+
Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting, "lane1").should == [ 'druid:ab123de4567' ]
|
239
252
|
end
|
240
253
|
end
|
241
254
|
end
|
@@ -246,9 +259,9 @@ describe Dor::WorkflowService do
|
|
246
259
|
workflow = "googleScannedBookWF"
|
247
260
|
completed = "google-download"
|
248
261
|
waiting = "process-content"
|
249
|
-
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{repository}:#{workflow}:#{waiting}&completed=#{repository}:#{workflow}:#{completed}")
|
262
|
+
@mock_resource.should_receive(:[]).with("workflow_queue?waiting=#{repository}:#{workflow}:#{waiting}&completed=#{repository}:#{workflow}:#{completed}&lane-id=default")
|
250
263
|
@mock_resource.should_receive(:get).and_return(%{<objects count="0"/>})
|
251
|
-
Dor::WorkflowService.get_objects_for_workstep(completed, waiting, repository, workflow).should == []
|
264
|
+
Dor::WorkflowService.get_objects_for_workstep(completed, waiting, 'default', :default_repository => repository, :default_workflow => workflow).should == []
|
252
265
|
end
|
253
266
|
end
|
254
267
|
|
@@ -275,11 +288,11 @@ describe Dor::WorkflowService do
|
|
275
288
|
xml = <<-XML
|
276
289
|
<workflows objectId="druid:mw971zk1113">
|
277
290
|
<workflow repository="dor" objectId="druid:mw971zk1113" id="accessionWF">
|
278
|
-
<process
|
291
|
+
<process laneId="default" lifecycle="submitted" elapsed="0.0" attempts="1" datetime="2013-02-18T15:08:10-0800" status="completed" name="start-accession"/>
|
279
292
|
</workflow>
|
280
293
|
<workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
|
281
|
-
<process version="1"
|
282
|
-
<process version="1"
|
294
|
+
<process version="1" laneId="default" elapsed="0.0" archived="true" attempts="1" datetime="2013-02-18T14:40:25-0800" status="completed" name="start-assembly"/>
|
295
|
+
<process version="1" laneId="default" elapsed="0.509" archived="true" attempts="1" datetime="2013-02-18T14:42:24-0800" status="completed" name="jp2-create"/>
|
283
296
|
</workflow>
|
284
297
|
</workflows>
|
285
298
|
XML
|
@@ -307,16 +320,16 @@ describe Dor::WorkflowService do
|
|
307
320
|
it "returns an Array of Hashes containing each workflow step" do
|
308
321
|
xml = <<-XML
|
309
322
|
<workflows>
|
310
|
-
<workflow
|
311
|
-
<workflow
|
323
|
+
<workflow laneId="lane1" note="annotation" lifecycle="in-process" errorText="stacktrace" errorMessage="NullPointerException" elapsed="1.173" repository="dor" attempts="0" datetime="2008-11-15T13:30:00-0800" status="waiting" process="content-metadata" name="accessionWF" druid="dr:123"/>
|
324
|
+
<workflow laneId="lane2" note="annotation" lifecycle="in-process" errorText="stacktrace" errorMessage="NullPointerException" elapsed="1.173" repository="dor" attempts="0" datetime="2008-11-15T13:30:00-0800" status="waiting" process="jp2-create" name="assemblyWF" druid="dr:456"/>
|
312
325
|
</workflows>
|
313
326
|
XML
|
314
327
|
@mock_resource.should_receive(:[]).with("workflow_queue/all_queued?repository=dor&hours-ago=24&limit=100")
|
315
328
|
@mock_resource.should_receive(:get).and_return(xml)
|
316
329
|
|
317
330
|
ah = Dor::WorkflowService.get_stale_queued_workflows 'dor', :hours_ago => 24, :limit => 100
|
318
|
-
expected = [ { :workflow => 'accessionWF', :step => 'content-metadata', :druid => 'dr:123', :
|
319
|
-
{ :workflow => 'assemblyWF', :step => 'jp2-create', :druid => 'dr:456', :
|
331
|
+
expected = [ { :workflow => 'accessionWF', :step => 'content-metadata', :druid => 'dr:123', :lane_id => 'lane1'},
|
332
|
+
{ :workflow => 'assemblyWF', :step => 'jp2-create', :druid => 'dr:456', :lane_id => 'lane2'} ]
|
320
333
|
ah.should eql(expected)
|
321
334
|
end
|
322
335
|
end
|
@@ -330,4 +343,20 @@ describe Dor::WorkflowService do
|
|
330
343
|
end
|
331
344
|
end
|
332
345
|
|
346
|
+
describe ".get_lane_ids" do
|
347
|
+
it "returns the lane ids for a given workflow step" do
|
348
|
+
xml = <<-XML
|
349
|
+
<lanes>
|
350
|
+
<lane id="lane1"/>
|
351
|
+
<lane id="lane2"/>
|
352
|
+
</lanes>
|
353
|
+
XML
|
354
|
+
|
355
|
+
@mock_resource.should_receive(:[]).with("workflow_queue/lane_ids?step=dor:accessionWF:shelve")
|
356
|
+
@mock_resource.should_receive(:get).and_return(xml)
|
357
|
+
|
358
|
+
Dor::WorkflowService.get_lane_ids('dor', 'accessionWF', 'shelve').should == ["lane1", "lane2"]
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
333
362
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.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: 2014-05-
|
12
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|