dor-workflow-service 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/lib/dor/services/workflow_service.rb +24 -6
- data/lib/dor/workflow_version.rb +1 -1
- data/spec/workflow_service_spec.rb +19 -0
- metadata +45 -25
- checksums.yaml +0 -7
data/Gemfile
CHANGED
@@ -91,17 +91,28 @@ module Dor
|
|
91
91
|
# Get workflow names into an array for given PID
|
92
92
|
# This method only works when this gem is used in a project that is configured to connect to DOR
|
93
93
|
#
|
94
|
-
# @param [
|
95
|
-
#
|
96
|
-
# @
|
97
|
-
#
|
98
|
-
# Dor::WorkflowService.get_workflows('druid:sr100hp0609')
|
99
|
-
# => ["accessionWF", "assemblyWF", "disseminationWF"]
|
94
|
+
# @param [String] pid of druid
|
95
|
+
# @return [Array<String>] list of worklows
|
96
|
+
# @example Dor::WorkflowService.get_workflows('druid:sr100hp0609')
|
97
|
+
# => ["accessionWF", "assemblyWF", "disseminationWF"]
|
100
98
|
def get_workflows(pid)
|
101
99
|
xml_doc=Nokogiri::XML(get_workflow_xml('dor',pid,''))
|
102
100
|
return xml_doc.xpath('//workflow').collect {|workflow| workflow['id']}
|
103
101
|
end
|
104
102
|
|
103
|
+
# Get active workflow names into an array for given PID
|
104
|
+
# This method only works when this gem is used in a project that is configured to connect to DOR
|
105
|
+
#
|
106
|
+
# @param [String] repo repository of the object
|
107
|
+
# @param [String] pid id of object
|
108
|
+
# @return [Array<String>] list of active worklows. Returns an empty Array if none are found
|
109
|
+
# @example Dor::WorkflowService.get_workflows('dor', 'druid:sr100hp0609')
|
110
|
+
# => ["accessionWF", "assemblyWF", "disseminationWF"]
|
111
|
+
def get_active_workflows(repo, pid)
|
112
|
+
doc = Nokogiri::XML(get_workflow_xml(repo,pid,''))
|
113
|
+
doc.xpath( %(//workflow[not(process/@archived)]/@id ) ).map {|n| n.value}
|
114
|
+
end
|
115
|
+
|
105
116
|
# Updates the status of one step in a workflow to error.
|
106
117
|
# Returns true on success. Caller must handle any exceptions
|
107
118
|
#
|
@@ -248,6 +259,13 @@ module Dor
|
|
248
259
|
return Nokogiri::XML(lifecycle_xml)
|
249
260
|
end
|
250
261
|
|
262
|
+
def archive_active_workflow(repo, druid)
|
263
|
+
workflows = get_active_workflows(repo, druid)
|
264
|
+
workflows.each do |wf|
|
265
|
+
archive_workflow(repo, druid, wf,)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
251
269
|
def archive_workflow(repo, druid, wf_name, version_num=nil)
|
252
270
|
raise "Please call Dor::WorkflowService.configure(workflow_service_url, :dor_services_url => DOR_SERVIES_URL) once before archiving workflow" if(@@dor_services_url.nil?)
|
253
271
|
|
data/lib/dor/workflow_version.rb
CHANGED
@@ -242,4 +242,23 @@ describe Dor::WorkflowService do
|
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
+
describe ".get_active_workflows" do
|
246
|
+
it "it returns an array of active workflows only" do
|
247
|
+
xml = <<-XML
|
248
|
+
<workflows objectId="druid:mw971zk1113">
|
249
|
+
<workflow repository="dor" objectId="druid:mw971zk1113" id="accessionWF">
|
250
|
+
<process priority="0" lifecycle="submitted" elapsed="0.0" attempts="1" datetime="2013-02-18T15:08:10-0800" status="completed" name="start-accession"/>
|
251
|
+
</workflow>
|
252
|
+
<workflow repository="dor" objectId="druid:mw971zk1113" id="assemblyWF">
|
253
|
+
<process version="1" priority="0" elapsed="0.0" archived="true" attempts="1" datetime="2013-02-18T14:40:25-0800" status="completed" name="start-assembly"/>
|
254
|
+
<process version="1" priority="0" elapsed="0.509" archived="true" attempts="1" datetime="2013-02-18T14:42:24-0800" status="completed" name="jp2-create"/>
|
255
|
+
</workflow>
|
256
|
+
</workflows>
|
257
|
+
XML
|
258
|
+
|
259
|
+
Dor::WorkflowService.stub(:get_workflow_xml) { xml }
|
260
|
+
expect(Dor::WorkflowService.get_active_workflows('dor', 'druid:mw971zk1113')).to eq(['accessionWF'])
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
245
264
|
end
|
metadata
CHANGED
@@ -1,139 +1,158 @@
|
|
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.4.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Willy Mene
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activesupport
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: nokogiri
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rest-client
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: confstruct
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rake
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- - '>='
|
83
|
+
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: '0'
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- - '>='
|
91
|
+
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: '0'
|
83
94
|
- !ruby/object:Gem::Dependency
|
84
95
|
name: rspec
|
85
96
|
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
86
98
|
requirements:
|
87
|
-
- - '>='
|
99
|
+
- - ! '>='
|
88
100
|
- !ruby/object:Gem::Version
|
89
101
|
version: '0'
|
90
102
|
type: :development
|
91
103
|
prerelease: false
|
92
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
93
106
|
requirements:
|
94
|
-
- - '>='
|
107
|
+
- - ! '>='
|
95
108
|
- !ruby/object:Gem::Version
|
96
109
|
version: '0'
|
97
110
|
- !ruby/object:Gem::Dependency
|
98
111
|
name: yard
|
99
112
|
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
100
114
|
requirements:
|
101
|
-
- - '>='
|
115
|
+
- - ! '>='
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
107
122
|
requirements:
|
108
|
-
- - '>='
|
123
|
+
- - ! '>='
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: '0'
|
111
126
|
- !ruby/object:Gem::Dependency
|
112
127
|
name: redcarpet
|
113
128
|
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
114
130
|
requirements:
|
115
|
-
- - '>='
|
131
|
+
- - ! '>='
|
116
132
|
- !ruby/object:Gem::Version
|
117
133
|
version: '0'
|
118
134
|
type: :development
|
119
135
|
prerelease: false
|
120
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
121
138
|
requirements:
|
122
|
-
- - '>='
|
139
|
+
- - ! '>='
|
123
140
|
- !ruby/object:Gem::Version
|
124
141
|
version: '0'
|
125
142
|
- !ruby/object:Gem::Dependency
|
126
143
|
name: equivalent-xml
|
127
144
|
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
128
146
|
requirements:
|
129
|
-
- - '>='
|
147
|
+
- - ! '>='
|
130
148
|
- !ruby/object:Gem::Version
|
131
149
|
version: '0'
|
132
150
|
type: :development
|
133
151
|
prerelease: false
|
134
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
|
-
- - '>='
|
155
|
+
- - ! '>='
|
137
156
|
- !ruby/object:Gem::Version
|
138
157
|
version: '0'
|
139
158
|
description: Enables Ruby manipulation of the DOR Workflow Service via its REST API
|
@@ -159,26 +178,27 @@ files:
|
|
159
178
|
- spec/workflow_service_spec.rb
|
160
179
|
homepage: https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow
|
161
180
|
licenses: []
|
162
|
-
metadata: {}
|
163
181
|
post_install_message:
|
164
182
|
rdoc_options: []
|
165
183
|
require_paths:
|
166
184
|
- lib
|
167
185
|
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
168
187
|
requirements:
|
169
|
-
- - '>='
|
188
|
+
- - ! '>='
|
170
189
|
- !ruby/object:Gem::Version
|
171
190
|
version: '0'
|
172
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
none: false
|
173
193
|
requirements:
|
174
|
-
- - '>='
|
194
|
+
- - ! '>='
|
175
195
|
- !ruby/object:Gem::Version
|
176
196
|
version: '0'
|
177
197
|
requirements: []
|
178
198
|
rubyforge_project:
|
179
|
-
rubygems_version:
|
199
|
+
rubygems_version: 1.8.25
|
180
200
|
signing_key:
|
181
|
-
specification_version:
|
201
|
+
specification_version: 3
|
182
202
|
summary: Provides convenience methods to work with the DOR Workflow Service
|
183
203
|
test_files:
|
184
204
|
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 1d6fc3e584fe89a00011d92d20c3808bdbb7a9fe
|
4
|
-
data.tar.gz: 1f9c905de65222b5b1bcf85faa9a0caeb4b03054
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: a93219741feb1dfed55872d75a97c6822debb2781b3b7aedf90daeb03bd28155baca5ec823d223fde63f5ce76aa0684505df5c35f90d750b815a0380b682897e
|
7
|
-
data.tar.gz: 2165204dc1a3b3c14dc9fa8c555e7959a6bcbc134d752bdae29023828fdd97c8fce9ce384b1facdc4c0b4716cd6824271151d2a4e2d774f286c415371a13143f
|