openwferu 0.9.12 → 0.9.12.863
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/engine_template.rb +30 -0
- data/lib/openwfe/contextual.rb +21 -0
- data/lib/openwfe/engine/engine.rb +24 -24
- data/lib/openwfe/expool/errorjournal.rb +1 -3
- data/lib/openwfe/expool/expressionpool.rb +29 -24
- data/lib/openwfe/expool/history.rb +1 -3
- data/lib/openwfe/expool/journal.rb +1 -3
- data/lib/openwfe/expool/wfidgen.rb +1 -3
- data/lib/openwfe/expool/yamlexpstorage.rb +7 -7
- data/lib/openwfe/expressions/environment.rb +17 -6
- data/lib/openwfe/expressions/expressionmap.rb +1 -2
- data/lib/openwfe/expressions/fe_command.rb +227 -0
- data/lib/openwfe/expressions/fe_concurrence.rb +8 -6
- data/lib/openwfe/expressions/fe_cursor.rb +3 -157
- data/lib/openwfe/expressions/fe_define.rb +6 -5
- data/lib/openwfe/expressions/fe_if.rb +8 -2
- data/lib/openwfe/expressions/fe_iterator.rb +141 -35
- data/lib/openwfe/expressions/fe_subprocess.rb +3 -29
- data/lib/openwfe/expressions/fe_value.rb +1 -4
- data/lib/openwfe/expressions/flowexpression.rb +0 -5
- data/lib/openwfe/expressions/raw.rb +0 -2
- data/lib/openwfe/expressions/raw_prog.rb +15 -15
- data/lib/openwfe/flowexpressionid.rb +3 -3
- data/lib/openwfe/listeners/listeners.rb +2 -6
- data/lib/openwfe/participants/enoparticipants.rb +1 -2
- data/lib/openwfe/participants/participantmap.rb +0 -2
- data/lib/openwfe/participants/participants.rb +95 -4
- data/lib/openwfe/participants/soapparticipants.rb +15 -8
- data/lib/openwfe/rest/osocket.rb +2 -3
- data/lib/openwfe/rest/xmlcodec.rb +0 -2
- data/lib/openwfe/rudefinitions.rb +0 -17
- data/lib/openwfe/storage/yamlfilestorage.rb +3 -8
- data/lib/openwfe/util/observable.rb +4 -2
- data/lib/openwfe/util/otime.rb +10 -9
- data/lib/openwfe/util/safe.rb +9 -6
- data/lib/openwfe/util/scheduler.rb +60 -9
- data/lib/openwfe/util/schedulers.rb +1 -1
- data/lib/openwfe/util/workqueue.rb +0 -3
- data/lib/openwfe/utils.rb +27 -11
- data/lib/openwfe/version.rb +1 -1
- data/lib/openwfe/workitem.rb +29 -3
- data/lib/openwfe/worklist/storeparticipant.rb +1 -5
- data/test/console_test.rb +1 -4
- data/test/file_persisted_engine_test.rb +64 -0
- data/test/file_persistence_test.rb +22 -1
- data/test/ft_15_iterator.rb +55 -1
- data/test/ft_20_cron.rb +0 -1
- data/test/ft_21_cron.rb +0 -1
- data/test/ft_26c_load.rb +4 -10
- data/test/ft_32_journal.rb +2 -2
- data/test/ft_61_elsub.rb +51 -0
- data/test/ft_62_procparticipant.rb +65 -0
- data/test/ft_tests.rb +3 -1
- data/test/hparticipant_test.rb +3 -3
- data/test/misc_test.rb +1 -1
- data/test/obs_test.rb +27 -0
- data/test/rake_qtest.rb +4 -3
- data/test/safely_test.rb +6 -1
- data/test/scheduler_test.rb +85 -2
- data/test/sec_test.rb +9 -7
- metadata +6 -14
- data/lib/openwfe/listeners/sqslisteners.rb +0 -145
- data/lib/openwfe/participants/atomparticipants.rb +0 -181
- data/lib/openwfe/participants/csvparticipants.rb +0 -127
- data/lib/openwfe/participants/sqsparticipants.rb +0 -121
- data/lib/openwfe/storage/yamlextras.rb +0 -115
- data/lib/openwfe/util/csvtable.rb +0 -448
- data/lib/openwfe/util/sqs.rb +0 -581
- data/test/atom_test.rb +0 -100
- data/test/csv_test.rb +0 -342
- data/test/ft_19_csv.rb +0 -65
- data/test/rest_test.rb +0 -189
- data/test/sqs_test.rb +0 -103
@@ -30,8 +30,6 @@
|
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
32
|
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
33
|
|
36
34
|
#
|
37
35
|
# "made in Japan"
|
@@ -41,6 +39,7 @@
|
|
41
39
|
|
42
40
|
require 'openwfe/expressions/wtemplate'
|
43
41
|
require 'openwfe/expressions/flowexpression'
|
42
|
+
require 'openwfe/expressions/fe_command'
|
44
43
|
|
45
44
|
|
46
45
|
module OpenWFE
|
@@ -62,22 +61,37 @@ module OpenWFE
|
|
62
61
|
# of elements in the iteration and the field "\_\_ip__" the index of the
|
63
62
|
# current iteration.
|
64
63
|
#
|
64
|
+
# The 'iterator' expression understands the same cursor commands as the
|
65
|
+
# CursorExpression. One can thus exit an iterator or skip steps in it.
|
66
|
+
#
|
67
|
+
# iterator :on_value => "alice, bob, charles, doug", to_variable => "v" do
|
68
|
+
# sequence do
|
69
|
+
# participant :variable_ref => "v"
|
70
|
+
# skip 1, :if => "${f:reply} == 'skip next'"
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
#
|
65
74
|
class IteratorExpression < WithTemplateExpression
|
75
|
+
include CommandMixin
|
66
76
|
|
67
77
|
names :iterator
|
68
78
|
|
79
|
+
#
|
80
|
+
# an Iterator instance that holds the list of values being iterated
|
81
|
+
# upon.
|
82
|
+
#
|
69
83
|
attr_accessor :iterator
|
70
84
|
|
71
85
|
def apply (workitem)
|
72
86
|
|
73
87
|
if @children.length < 1
|
74
|
-
reply_to_parent
|
88
|
+
reply_to_parent workitem
|
75
89
|
return
|
76
90
|
end
|
77
91
|
|
78
92
|
@iterator = Iterator.new(self, workitem)
|
79
93
|
|
80
|
-
if
|
94
|
+
if @iterator.size < 1
|
81
95
|
reply_to_parent workitem
|
82
96
|
return
|
83
97
|
end
|
@@ -87,14 +101,35 @@ module OpenWFE
|
|
87
101
|
|
88
102
|
def reply (workitem)
|
89
103
|
|
90
|
-
|
91
|
-
|
92
|
-
|
104
|
+
command, step = determine_command_and_step workitem
|
105
|
+
|
106
|
+
vars = if not command
|
107
|
+
|
108
|
+
@iterator.next workitem
|
109
|
+
|
110
|
+
elsif command == C_BREAK or command == C_CANCEL
|
111
|
+
|
112
|
+
nil
|
113
|
+
|
114
|
+
elsif command == C_REWIND or command == C_CONTINUE
|
115
|
+
|
116
|
+
@iterator.rewind workitem
|
117
|
+
|
118
|
+
elsif command.match "^#{C_JUMP}"
|
119
|
+
|
120
|
+
@iterator.jump workitem, step
|
121
|
+
|
122
|
+
else # C_SKIP or C_BACK
|
123
|
+
|
124
|
+
@iterator.skip workitem, step
|
93
125
|
end
|
94
126
|
|
95
|
-
vars
|
127
|
+
unless vars
|
128
|
+
reply_to_parent workitem
|
129
|
+
return
|
130
|
+
end
|
96
131
|
|
97
|
-
store_itself
|
132
|
+
store_itself
|
98
133
|
|
99
134
|
get_expression_pool.launch_template(
|
100
135
|
self, @iterator.index, @children[0], workitem, vars)
|
@@ -111,13 +146,17 @@ module OpenWFE
|
|
111
146
|
ITERATOR_COUNT = "__ic__"
|
112
147
|
ITERATOR_POSITION = "__ip__"
|
113
148
|
|
114
|
-
attr_accessor
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
:counter
|
149
|
+
attr_accessor :iteration_index
|
150
|
+
attr_accessor :iteration_list
|
151
|
+
attr_accessor :to_field
|
152
|
+
attr_accessor :to_variable
|
153
|
+
attr_accessor :value_separator
|
120
154
|
|
155
|
+
#
|
156
|
+
# Builds a new iterator, serving a given iterator_expression.
|
157
|
+
# The second parameter is the workitem (as applied to the iterator
|
158
|
+
# expression).
|
159
|
+
#
|
121
160
|
def initialize (iterator_expression, workitem)
|
122
161
|
|
123
162
|
@to_field = iterator_expression\
|
@@ -130,7 +169,7 @@ module OpenWFE
|
|
130
169
|
|
131
170
|
@value_separator = /,\s*/ unless @value_separator
|
132
171
|
|
133
|
-
@
|
172
|
+
@iteration_index = 0
|
134
173
|
|
135
174
|
raw_list = iterator_expression.lookup_vf_attribute(
|
136
175
|
workitem, :value, :on)
|
@@ -144,58 +183,125 @@ module OpenWFE
|
|
144
183
|
# Has the iteration a next element ?
|
145
184
|
#
|
146
185
|
def has_next?
|
147
|
-
|
186
|
+
|
187
|
+
@iteration_index < @iteration_list.size
|
188
|
+
end
|
189
|
+
|
190
|
+
#
|
191
|
+
# Returns the size of this iterator, or rather, the size of the
|
192
|
+
# underlying iteration list.
|
193
|
+
#
|
194
|
+
def size
|
195
|
+
|
196
|
+
@iteration_list.size
|
148
197
|
end
|
149
198
|
|
150
199
|
#
|
151
200
|
# Prepares the iterator expression and the workitem for the next
|
152
201
|
# iteration.
|
153
202
|
#
|
154
|
-
def next (
|
203
|
+
def next (workitem)
|
155
204
|
|
156
|
-
|
205
|
+
position_at workitem, @iteration_index
|
206
|
+
end
|
207
|
+
|
208
|
+
#
|
209
|
+
# Positions the iterator back at position 0.
|
210
|
+
#
|
211
|
+
def rewind (workitem)
|
157
212
|
|
158
|
-
|
213
|
+
position_at workitem, 0
|
214
|
+
end
|
215
|
+
|
216
|
+
#
|
217
|
+
# Jumps to a given position in the iterator
|
218
|
+
#
|
219
|
+
def jump (workitem, index)
|
159
220
|
|
160
|
-
if
|
161
|
-
|
221
|
+
index = if index < 0
|
222
|
+
0
|
223
|
+
elsif index >= @iteration_list.size
|
224
|
+
@iteration_list.size
|
162
225
|
else
|
163
|
-
|
164
|
-
result[@to_variable] = value
|
226
|
+
index
|
165
227
|
end
|
166
228
|
|
167
|
-
workitem
|
168
|
-
|
229
|
+
position_at workitem, index
|
230
|
+
end
|
169
231
|
|
170
|
-
|
232
|
+
#
|
233
|
+
# Jumps a certain number of positions in the iterator.
|
234
|
+
#
|
235
|
+
def skip (workitem, offset)
|
171
236
|
|
172
|
-
|
237
|
+
jump workitem, @iteration_index + offset
|
173
238
|
end
|
174
239
|
|
240
|
+
#
|
241
|
+
# The current index (whereas @iteration_index already points to
|
242
|
+
# the next element).
|
243
|
+
#
|
175
244
|
def index
|
176
|
-
|
245
|
+
|
246
|
+
@iteration_index - 1
|
177
247
|
end
|
178
248
|
|
179
249
|
protected
|
180
250
|
|
251
|
+
#
|
252
|
+
# Positions the iterator absolutely.
|
253
|
+
#
|
254
|
+
def position_at (workitem, position)
|
255
|
+
|
256
|
+
result = {}
|
257
|
+
|
258
|
+
value = @iteration_list[position]
|
259
|
+
|
260
|
+
return nil unless value
|
261
|
+
|
262
|
+
if @to_field
|
263
|
+
workitem.attributes[@to_field] = value
|
264
|
+
else
|
265
|
+
result[@to_variable] = value
|
266
|
+
end
|
267
|
+
|
268
|
+
workitem.attributes[ITERATOR_POSITION] = position
|
269
|
+
result[ITERATOR_POSITION] = position
|
270
|
+
|
271
|
+
@iteration_index = position + 1
|
272
|
+
|
273
|
+
result
|
274
|
+
end
|
275
|
+
|
276
|
+
#
|
277
|
+
# Extracts the iteration list from any value.
|
278
|
+
#
|
181
279
|
def extract_iteration_list (raw_list)
|
182
280
|
|
183
|
-
|
281
|
+
if is_suitable_list?(raw_list)
|
184
282
|
raw_list
|
185
283
|
else
|
186
284
|
extract_list_from_string(raw_list.to_s)
|
187
285
|
end
|
188
|
-
|
189
|
-
return l.reverse
|
190
286
|
end
|
191
287
|
|
192
|
-
|
193
|
-
|
194
|
-
|
288
|
+
#
|
289
|
+
# Returns true if the given instance can be directly
|
290
|
+
# used as a list.
|
291
|
+
#
|
292
|
+
def is_suitable_list? (instance)
|
293
|
+
|
294
|
+
(not instance.is_a?(String)) and \
|
295
|
+
instance.respond_to? :[] and \
|
195
296
|
instance.respond_to? :length
|
196
297
|
end
|
197
298
|
|
299
|
+
#
|
300
|
+
# Extracts the list from the string (comma separated list
|
301
|
+
# usually).
|
302
|
+
#
|
198
303
|
def extract_list_from_string (s)
|
304
|
+
|
199
305
|
s.split(@value_separator)
|
200
306
|
end
|
201
307
|
end
|
@@ -30,8 +30,6 @@
|
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
32
|
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
33
|
|
36
34
|
#
|
37
35
|
# "made in Japan"
|
@@ -39,8 +37,6 @@
|
|
39
37
|
# John Mettraux at openwfe.org
|
40
38
|
#
|
41
39
|
|
42
|
-
#require 'uri'
|
43
|
-
|
44
40
|
require 'openwfe/utils'
|
45
41
|
|
46
42
|
|
@@ -87,15 +83,9 @@ module OpenWFE
|
|
87
83
|
|
88
84
|
raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" unless ref
|
89
85
|
|
90
|
-
template_uri =
|
91
|
-
|
92
|
-
template = if template_uri
|
93
|
-
template_uri
|
94
|
-
else
|
95
|
-
lookup_variable(ref)
|
96
|
-
end
|
86
|
+
template_uri = OpenWFE::parse_known_uri(ref)
|
97
87
|
|
98
|
-
|
88
|
+
template = template_uri || lookup_variable(ref)
|
99
89
|
|
100
90
|
raise "did not find any subprocess named '#{ref}'" \
|
101
91
|
if not template
|
@@ -103,7 +93,7 @@ module OpenWFE
|
|
103
93
|
forget = lookup_boolean_attribute(:forget, workitem)
|
104
94
|
|
105
95
|
requester = @fei
|
106
|
-
requester = @fei.
|
96
|
+
requester = @fei.workflow_instance_id if forget
|
107
97
|
|
108
98
|
params = lookup_attributes(workitem)
|
109
99
|
|
@@ -120,22 +110,6 @@ module OpenWFE
|
|
120
110
|
|
121
111
|
#def reply (workitem)
|
122
112
|
#end
|
123
|
-
|
124
|
-
protected
|
125
|
-
|
126
|
-
def parse_uri (ref)
|
127
|
-
|
128
|
-
uri = OpenWFE::parse_uri(ref)
|
129
|
-
|
130
|
-
return nil unless uri
|
131
|
-
|
132
|
-
return uri if uri.scheme == "http"
|
133
|
-
return uri if uri.scheme == "https"
|
134
|
-
return uri if uri.scheme == "ftp"
|
135
|
-
# what else ...
|
136
|
-
|
137
|
-
return nil
|
138
|
-
end
|
139
113
|
end
|
140
114
|
|
141
115
|
end
|
@@ -29,9 +29,6 @@
|
|
29
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
|
-
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
32
|
|
36
33
|
#
|
37
34
|
# "made in Japan"
|
@@ -99,7 +96,7 @@ module OpenWFE
|
|
99
96
|
#puts "value is '#{value}'"
|
100
97
|
|
101
98
|
if vkey
|
102
|
-
set_variable
|
99
|
+
set_variable vkey, value
|
103
100
|
elsif fkey
|
104
101
|
workitem.attributes[fkey] = value
|
105
102
|
else
|
@@ -29,9 +29,6 @@
|
|
29
29
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
|
-
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
32
|
|
36
33
|
#
|
37
34
|
# "made in Japan"
|
@@ -51,8 +48,6 @@ module OpenWFE
|
|
51
48
|
|
52
49
|
#
|
53
50
|
# FlowExpression
|
54
|
-
#
|
55
|
-
|
56
51
|
#
|
57
52
|
# The base class for all OpenWFE flow expression classes.
|
58
53
|
# It gathers all the methods for attributes and variable lookup.
|
@@ -49,24 +49,24 @@ require 'openwfe/expressions/simplerep'
|
|
49
49
|
module OpenWFE
|
50
50
|
|
51
51
|
#
|
52
|
-
#
|
52
|
+
# Extend this class to create a programmatic process definition.
|
53
53
|
#
|
54
54
|
# A short example :
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
55
|
+
#
|
56
|
+
# class MyProcessDefinition < OpenWFE::ProcessDefinition
|
57
|
+
# def make
|
58
|
+
# process_definition :name => "test1", :revision => "0" do
|
59
|
+
# sequence do
|
60
|
+
# set :variable => "toto", :value => "nada"
|
61
|
+
# print "toto:${toto}"
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# end
|
66
66
|
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
67
|
+
# li = OpenWFE::LaunchItem.new(MyProcessDefinition)
|
68
|
+
# engine.launch(li)
|
69
|
+
#
|
70
70
|
#
|
71
71
|
class ProcessDefinition
|
72
72
|
|
@@ -47,9 +47,9 @@ module OpenWFE
|
|
47
47
|
# A FlowExpressionId is a unique identifier for a FlowExpression (an atomic
|
48
48
|
# piece of a process instance).
|
49
49
|
#
|
50
|
-
# As workitems
|
51
|
-
# of the business process engine via 'participant expressions',
|
52
|
-
#
|
50
|
+
# As workitems move through a workflow among the expressions and are emitted
|
51
|
+
# outside of the business process engine via 'participant expressions', these
|
52
|
+
# workitems are identified by the FlowExpressionId of the participant
|
53
53
|
# expression that pushed them out (and is waiting for them to come back).
|
54
54
|
#
|
55
55
|
class FlowExpressionId
|
@@ -30,8 +30,6 @@
|
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
32
|
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
33
|
|
36
34
|
#
|
37
35
|
# "made in Japan"
|
@@ -75,12 +73,10 @@ module OpenWFE
|
|
75
73
|
attr_reader :workdir
|
76
74
|
|
77
75
|
def initialize (service_name, application_context)
|
76
|
+
|
78
77
|
super
|
79
78
|
|
80
|
-
|
81
|
-
#@workdir = OpenWFE::DEFAULT_WORK_DIRECTORY unless @workdir
|
82
|
-
#@workdir += "/in/"
|
83
|
-
@workdir = OpenWFE::get_work_directory + "/in/"
|
79
|
+
@workdir = get_work_directory + "/in/"
|
84
80
|
|
85
81
|
linfo { "new() workdir is '#{@workdir}'" }
|
86
82
|
end
|
@@ -30,7 +30,6 @@
|
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
32
|
#
|
33
|
-
#
|
34
33
|
|
35
34
|
#
|
36
35
|
# "made in Japan"
|
@@ -142,7 +141,7 @@ module OpenWFE
|
|
142
141
|
# This participant is used to send an email notification.
|
143
142
|
#
|
144
143
|
# It's perhaps better to use MailParticipant which is simpler to
|
145
|
-
#
|
144
|
+
# initialize. This class is anyway an extension of MailParticipant.
|
146
145
|
#
|
147
146
|
# @engine.register_participant(
|
148
147
|
# 'eno',
|
@@ -30,8 +30,6 @@
|
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
32
|
#
|
33
|
-
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
|
34
|
-
#
|
35
33
|
|
36
34
|
#
|
37
35
|
# "made in Japan"
|
@@ -68,7 +66,7 @@ module OpenWFE
|
|
68
66
|
#
|
69
67
|
def initialize (context_or_dir=nil)
|
70
68
|
|
71
|
-
@workdir =
|
69
|
+
@workdir = get_work_directory(context_or_dir) + "/out/"
|
72
70
|
|
73
71
|
@reply_anyway = false
|
74
72
|
end
|
@@ -190,6 +188,7 @@ module OpenWFE
|
|
190
188
|
# Simply discards the incoming workitem
|
191
189
|
#
|
192
190
|
def consume (workitem)
|
191
|
+
# does nothing and does not reply to the engine.
|
193
192
|
end
|
194
193
|
end
|
195
194
|
|
@@ -210,7 +209,7 @@ module OpenWFE
|
|
210
209
|
|
211
210
|
#
|
212
211
|
# The PrintParticipant will just emit its name to the
|
213
|
-
# test tracer if any or to stdout else.
|
212
|
+
# test tracer if any or to the stdout else.
|
214
213
|
# Used by some unit tests.
|
215
214
|
#
|
216
215
|
class PrintParticipant
|
@@ -231,5 +230,97 @@ module OpenWFE
|
|
231
230
|
end
|
232
231
|
end
|
233
232
|
|
233
|
+
#
|
234
|
+
# Links a process under a participant [name].
|
235
|
+
#
|
236
|
+
# Turns top level processes into participants
|
237
|
+
#
|
238
|
+
# Some examples :
|
239
|
+
#
|
240
|
+
# require 'engine/participants/participants'
|
241
|
+
#
|
242
|
+
# engine.register_participant(
|
243
|
+
# "transmit_to_accounting",
|
244
|
+
# "http://company.process.server.ie/processes/acc0.xml")
|
245
|
+
#
|
246
|
+
# engine.register_participant(
|
247
|
+
# "hr_resume_review_process",
|
248
|
+
# "file:/var/processes/hr_resume_review_process.rb")
|
249
|
+
#
|
250
|
+
# Some more examples :
|
251
|
+
#
|
252
|
+
# class RegistrationProcess < OpenWFE::ProcessDefinition
|
253
|
+
# sequence do
|
254
|
+
# participant :ref => "Alice"
|
255
|
+
# participant :ref => "Bob"
|
256
|
+
# end
|
257
|
+
# end
|
258
|
+
#
|
259
|
+
# # later in the code ...
|
260
|
+
#
|
261
|
+
# engine.register_participant("registration", RegistrationProcess)
|
262
|
+
#
|
263
|
+
# Or directly with some XML string :
|
264
|
+
#
|
265
|
+
# engine.register_participant("registration", '''
|
266
|
+
# <process-definition name="registration" revision="0.1">
|
267
|
+
# <sequence>
|
268
|
+
# <participant ref="Alice" />
|
269
|
+
# <participant ref="Bob" />
|
270
|
+
# </sequence>
|
271
|
+
# </process-definition>
|
272
|
+
# '''.strip)
|
273
|
+
#
|
274
|
+
# It's then easy to call the subprocess as if it were a participant :
|
275
|
+
#
|
276
|
+
# sequence do
|
277
|
+
# participant :ref => "registration"
|
278
|
+
# # or
|
279
|
+
# participant "registration"
|
280
|
+
# # or simply
|
281
|
+
# registration
|
282
|
+
# end
|
283
|
+
#
|
284
|
+
# Note that the 'subprocess' expression may be used as well :
|
285
|
+
#
|
286
|
+
# sequence do
|
287
|
+
# subprocess ref => "http://dms.company.org/processes/proc1.rb"
|
288
|
+
# end
|
289
|
+
#
|
290
|
+
# But you can't use the URL as an expression name for writing nice,
|
291
|
+
# concise, process definitions.
|
292
|
+
#
|
293
|
+
class ProcessParticipant
|
294
|
+
include LocalParticipant
|
295
|
+
|
296
|
+
#
|
297
|
+
# The 'object' may be the URL of a process definition or the process
|
298
|
+
# definition itself as an XML string or a Ruby process definition
|
299
|
+
# (as a class or in a String).
|
300
|
+
#
|
301
|
+
def initialize (object)
|
302
|
+
|
303
|
+
super()
|
304
|
+
|
305
|
+
template_uri = OpenWFE::parse_known_uri object
|
306
|
+
|
307
|
+
@template = template_uri || object
|
308
|
+
end
|
309
|
+
|
310
|
+
#
|
311
|
+
# This is the method called by the engine when it has a workitem
|
312
|
+
# for this participant.
|
313
|
+
#
|
314
|
+
def consume (workitem)
|
315
|
+
|
316
|
+
get_expression_pool.launch_template(
|
317
|
+
get_flow_expression(workitem),
|
318
|
+
0, #sub_id
|
319
|
+
@template,
|
320
|
+
workitem)
|
321
|
+
#params)
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
234
325
|
end
|
235
326
|
|
@@ -30,8 +30,6 @@
|
|
30
30
|
# POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
#++
|
32
32
|
#
|
33
|
-
# $Id$
|
34
|
-
#
|
35
33
|
|
36
34
|
#
|
37
35
|
# "made in Japan"
|
@@ -57,8 +55,14 @@ module OpenWFE
|
|
57
55
|
#
|
58
56
|
# engine.register_participant("quote_service", quote_service)
|
59
57
|
#
|
60
|
-
#
|
61
|
-
#
|
58
|
+
# By default, call params for the SOAP operations are determined by
|
59
|
+
# iterating the parameters and fetching the values under the
|
60
|
+
# corresponding workitem fields.
|
61
|
+
# This behaviour can be changed by overriding the prepare_call_params()
|
62
|
+
# method.
|
63
|
+
#
|
64
|
+
# On the return side, you can override the method handle_call_result
|
65
|
+
# for better mappings between web service calls and the workitems.
|
62
66
|
#
|
63
67
|
class SoapParticipant
|
64
68
|
include LocalParticipant
|
@@ -77,6 +81,10 @@ module OpenWFE
|
|
77
81
|
@driver.add_method(method_name, *params)
|
78
82
|
end
|
79
83
|
|
84
|
+
#
|
85
|
+
# The method called by the engine when the flow reaches an instance
|
86
|
+
# of this Participant class.
|
87
|
+
#
|
80
88
|
def consume (workitem)
|
81
89
|
|
82
90
|
call_params = prepare_call_params(workitem)
|
@@ -97,7 +105,7 @@ module OpenWFE
|
|
97
105
|
def prepare_call_params (workitem)
|
98
106
|
|
99
107
|
@params.collect do |param|
|
100
|
-
get_param
|
108
|
+
get_param workitem, param
|
101
109
|
end
|
102
110
|
end
|
103
111
|
|
@@ -117,9 +125,8 @@ module OpenWFE
|
|
117
125
|
def get_param (workitem, param_name)
|
118
126
|
|
119
127
|
param_name = @param_prefix + param_name if @param_prefix
|
120
|
-
|
121
|
-
|
122
|
-
return ""
|
128
|
+
|
129
|
+
workitem.attributes[param_name] || ""
|
123
130
|
end
|
124
131
|
|
125
132
|
end
|