openwferu 0.9.3 → 0.9.4
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.
- data/examples/flowtracing.rb +22 -0
- data/lib/openwfe/contextual.rb +5 -2
- data/lib/openwfe/def.rb +47 -0
- data/lib/openwfe/engine/engine.rb +1 -1
- data/lib/openwfe/engine/file_persisted_engine.rb +3 -5
- data/lib/openwfe/expool/expressionpool.rb +45 -6
- data/lib/openwfe/expool/history.rb +117 -0
- data/lib/openwfe/expool/yamlexpstorage.rb +21 -4
- data/lib/openwfe/expressions/environment.rb +3 -0
- data/lib/openwfe/expressions/expressionmap.rb +1 -0
- data/lib/openwfe/expressions/fe_concurrence.rb +22 -12
- data/lib/openwfe/expressions/fe_iterator.rb +3 -1
- data/lib/openwfe/expressions/fe_participant.rb +1 -4
- data/lib/openwfe/expressions/fe_raw.rb +2 -2
- data/lib/openwfe/expressions/fe_time.rb +184 -10
- data/lib/openwfe/expressions/fe_utils.rb +10 -0
- data/lib/openwfe/expressions/flowexpression.rb +3 -1
- data/lib/openwfe/expressions/raw_prog.rb +1 -1
- data/lib/openwfe/expressions/timeout.rb +47 -13
- data/lib/openwfe/flowexpressionid.rb +9 -1
- data/lib/openwfe/participants/csvparticipant.rb +127 -0
- data/lib/openwfe/participants/participant.rb +1 -0
- data/lib/openwfe/participants/participants.rb +26 -3
- data/lib/openwfe/rest/controlclient.rb +3 -3
- data/lib/openwfe/rest/worklistclient.rb +6 -8
- data/lib/openwfe/rest/xmlcodec.rb +6 -6
- data/lib/openwfe/rudefinitions.rb +6 -13
- data/lib/openwfe/storage/yamlfilestorage.rb +1 -1
- data/lib/openwfe/tools/flowtracer.rb +80 -0
- data/lib/openwfe/util/csvtable.rb +378 -0
- data/lib/openwfe/util/dollar.rb +24 -7
- data/lib/openwfe/util/observable.rb +82 -0
- data/lib/openwfe/util/scheduler.rb +14 -0
- data/lib/openwfe/utils.rb +64 -0
- data/lib/openwfe/version.rb +38 -0
- data/lib/openwfe/workitem.rb +53 -0
- data/lib/openwfe/worklist/storeparticipant.rb +19 -4
- data/test/csv_test.rb +285 -0
- data/test/fei_test.rb +1 -1
- data/test/file_persistence_test.rb +2 -2
- data/test/flowtestbase.rb +10 -3
- data/test/ft_0.rb +0 -7
- data/test/ft_0d_participant.rb +29 -0
- data/test/ft_11_ppd.rb +26 -1
- data/test/ft_12_blockparticipant.rb +28 -1
- data/test/ft_19_csv.rb +64 -0
- data/test/ft_20_cron.rb +60 -0
- data/test/ft_21_cron.rb +48 -0
- data/test/ft_22_history.rb +68 -0
- data/test/ft_23_when.rb +50 -0
- data/test/ft_23b_when.rb +45 -0
- data/test/ft_24_def.rb +47 -0
- data/test/ft_9_cursor.rb +20 -0
- data/test/rake_qtest.rb +7 -0
- data/test/rake_test.rb +3 -0
- data/test/timeout_test.rb +46 -4
- data/test/wi_test.rb +66 -0
- metadata +21 -3
- data/test/rake_ptest.rb +0 -18
@@ -43,6 +43,8 @@ require 'openwfe/rudefinitions'
|
|
43
43
|
require 'openwfe/utils'
|
44
44
|
require 'openwfe/util/otime'
|
45
45
|
require 'openwfe/util/scheduler'
|
46
|
+
require 'openwfe/expressions/timeout'
|
47
|
+
require 'openwfe/expressions/fe_condition'
|
46
48
|
|
47
49
|
|
48
50
|
#
|
@@ -71,24 +73,31 @@ module OpenWFE
|
|
71
73
|
def cancel ()
|
72
74
|
synchronize do
|
73
75
|
|
74
|
-
ldebug { "cancel()
|
76
|
+
ldebug { "cancel()..." }
|
75
77
|
|
76
|
-
|
77
|
-
if @scheduler_job_id
|
78
|
+
unschedule()
|
78
79
|
|
79
80
|
return super()
|
80
81
|
end
|
81
82
|
end
|
83
|
+
|
84
|
+
def unschedule ()
|
85
|
+
|
86
|
+
ldebug { "unschedule() @scheduler_job_id is #{@scheduler_job_id}" }
|
87
|
+
|
88
|
+
get_scheduler.unschedule(@scheduler_job_id) \
|
89
|
+
if @scheduler_job_id
|
90
|
+
end
|
82
91
|
end
|
83
92
|
|
84
93
|
#
|
85
94
|
# The 'sleep' expression expects one attribute, either 'for', either
|
86
95
|
# 'until'.
|
87
96
|
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
97
|
+
# <sequence>
|
98
|
+
# <sleep for="10m12s" />
|
99
|
+
# <participant ref="alpha" />
|
100
|
+
# </sequence>
|
92
101
|
#
|
93
102
|
# will wait for 10 minutes and 12 seconds before sending a workitem
|
94
103
|
# to participant 'alpha'.
|
@@ -160,7 +169,7 @@ module OpenWFE
|
|
160
169
|
scheduler.schedule_at(@awakening_time, self, nil)
|
161
170
|
|
162
171
|
ldebug do
|
163
|
-
"[re]schedule() @scheduler_job_id is #{@scheduler_job_id} "+
|
172
|
+
"[re]schedule() @scheduler_job_id is '#{@scheduler_job_id}' "+
|
164
173
|
" (scheduler #{scheduler.object_id})"
|
165
174
|
end
|
166
175
|
|
@@ -168,11 +177,23 @@ module OpenWFE
|
|
168
177
|
end
|
169
178
|
end
|
170
179
|
|
180
|
+
#
|
181
|
+
# Scheduling subprocesses for repeating execution
|
171
182
|
#
|
172
183
|
# <cron tab="0 9-17 * * mon-fri" name="//reminder">
|
173
184
|
# <send-reminder/>
|
174
185
|
# </cron>
|
175
186
|
#
|
187
|
+
# In this short process definition snippet, the subprocess "send-reminder"
|
188
|
+
# will get triggered once per hour (minute 0) from 0900 to 1700 and
|
189
|
+
# this, from monday to friday.
|
190
|
+
#
|
191
|
+
# The 'name' of the cron indicates also at which level the cron should
|
192
|
+
# be bound. A double slash means the cron is bound at engine level (and
|
193
|
+
# will continue until it is unbound, as long as the engine is up, if the
|
194
|
+
# engine is a persisted one, the cron will continue when the engine
|
195
|
+
# restarts).
|
196
|
+
#
|
176
197
|
class CronExpression < TimeExpression
|
177
198
|
|
178
199
|
attr_accessor \
|
@@ -225,6 +246,11 @@ module OpenWFE
|
|
225
246
|
#
|
226
247
|
# implemented in parent TimeExpression class
|
227
248
|
|
249
|
+
#
|
250
|
+
# This is the method called each time, the scheduler triggers
|
251
|
+
# this cron. The contained segment of process will get
|
252
|
+
# executed.
|
253
|
+
#
|
228
254
|
def trigger (params)
|
229
255
|
#
|
230
256
|
# launch raw child
|
@@ -244,11 +270,21 @@ module OpenWFE
|
|
244
270
|
end
|
245
271
|
end
|
246
272
|
|
273
|
+
#
|
274
|
+
# This method is called at the first schedule of this expression
|
275
|
+
# or each time the engine is restarted and this expression has
|
276
|
+
# to be rescheduled.
|
277
|
+
#
|
247
278
|
def reschedule (scheduler)
|
248
279
|
|
249
|
-
@
|
280
|
+
@scheduler_job_id = @name.dup
|
281
|
+
|
282
|
+
@scheduler_job_id = "#{@fei.wfid}__#{@scheduler_job_id}" \
|
283
|
+
if not OpenWFE::starts_with(@name, "//")
|
250
284
|
|
251
|
-
|
285
|
+
get_scheduler.schedule(@tab, @scheduler_job_id, self, nil)
|
286
|
+
|
287
|
+
ldebug { "reschedule() job id is '#{@scheduler_job_id}'" }
|
252
288
|
|
253
289
|
#store_itself()
|
254
290
|
#
|
@@ -256,5 +292,143 @@ module OpenWFE
|
|
256
292
|
end
|
257
293
|
end
|
258
294
|
|
295
|
+
#
|
296
|
+
# The 'when' expression will trigger a consequence when a condition
|
297
|
+
# is met, like in
|
298
|
+
#
|
299
|
+
# <when test="${variable:over} == true">
|
300
|
+
# <participant ref="toto" />
|
301
|
+
# </when>
|
302
|
+
#
|
303
|
+
# where the participant "toto" will receive a workitem when the (local)
|
304
|
+
# variable "over" has the value true.
|
305
|
+
#
|
306
|
+
class WhenExpression < TimeExpression
|
307
|
+
include ConditionMixin, TimeoutMixin
|
308
|
+
|
309
|
+
attr_accessor \
|
310
|
+
:frequency,
|
311
|
+
:consequence_triggered
|
312
|
+
|
313
|
+
DEFAULT_FREQUENCY = "20s"
|
314
|
+
|
315
|
+
def apply (workitem)
|
316
|
+
|
317
|
+
if @children.size < 1
|
318
|
+
reply_to_parent(workitem)
|
319
|
+
return
|
320
|
+
end
|
321
|
+
|
322
|
+
@applied_workitem = workitem.dup
|
323
|
+
|
324
|
+
@frequency =
|
325
|
+
lookup_attribute(:frequency, workitem, DEFAULT_FREQUENCY)
|
326
|
+
@frequency =
|
327
|
+
OpenWFE::parse_time_string(@frequency)
|
328
|
+
|
329
|
+
determine_timeout()
|
330
|
+
|
331
|
+
@consequence_triggered = false
|
332
|
+
|
333
|
+
trigger(nil)
|
334
|
+
end
|
335
|
+
|
336
|
+
def reply (workitem)
|
337
|
+
|
338
|
+
ldebug do
|
339
|
+
"reply() @consequence_triggered is '#{@consequence_triggered}'"
|
340
|
+
end
|
341
|
+
|
342
|
+
if @consequence_triggered
|
343
|
+
reply_to_parent(workitem)
|
344
|
+
return
|
345
|
+
end
|
346
|
+
|
347
|
+
result = OpenWFE::get_result(workitem)
|
348
|
+
|
349
|
+
if result
|
350
|
+
apply_consequence(workitem)
|
351
|
+
else
|
352
|
+
reschedule(get_scheduler)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
def cancel ()
|
357
|
+
to_unschedule()
|
358
|
+
super()
|
359
|
+
end
|
360
|
+
|
361
|
+
def trigger (params)
|
362
|
+
|
363
|
+
ldebug { "trigger() params is #{params}" }
|
364
|
+
|
365
|
+
if params == :do_timeout!
|
366
|
+
#
|
367
|
+
# do timeout...
|
368
|
+
#
|
369
|
+
reply_to_parent(@applied_workitem)
|
370
|
+
return
|
371
|
+
end
|
372
|
+
|
373
|
+
@scheduler_job_id = nil
|
374
|
+
|
375
|
+
evaluate_condition()
|
376
|
+
end
|
377
|
+
|
378
|
+
def reschedule (scheduler)
|
379
|
+
|
380
|
+
@scheduler_job_id =
|
381
|
+
scheduler.schedule_in(@frequency, self, nil)
|
382
|
+
|
383
|
+
ldebug { "reschedule() @scheduler_job_id is #{@scheduler_job_id}" }
|
384
|
+
|
385
|
+
to_reschedule(scheduler)
|
386
|
+
end
|
387
|
+
|
388
|
+
def reply_to_parent (workitem)
|
389
|
+
|
390
|
+
unschedule()
|
391
|
+
unschedule_timeout()
|
392
|
+
|
393
|
+
super(workitem)
|
394
|
+
end
|
395
|
+
|
396
|
+
protected
|
397
|
+
|
398
|
+
def evaluate_condition
|
399
|
+
|
400
|
+
if @children.size > 1
|
401
|
+
#
|
402
|
+
# trigger the evaluation of the first (condition) child
|
403
|
+
|
404
|
+
store_itself()
|
405
|
+
|
406
|
+
get_expression_pool.launch_template(
|
407
|
+
self, @children[0], @applied_workitem)
|
408
|
+
else
|
409
|
+
#
|
410
|
+
# eval the attribute condition immediately
|
411
|
+
|
412
|
+
c = eval_condition(:test, @applied_workitem)
|
413
|
+
|
414
|
+
OpenWFE::set_result(@applied_workitem, c)
|
415
|
+
|
416
|
+
reply(@applied_workitem)
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
def apply_consequence (workitem)
|
421
|
+
|
422
|
+
@consequence_triggered = true
|
423
|
+
|
424
|
+
store_itself()
|
425
|
+
|
426
|
+
i = 1
|
427
|
+
i = 0 if @children.size == 1
|
428
|
+
|
429
|
+
get_expression_pool.apply(@children[i], workitem)
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
259
433
|
end
|
260
434
|
|
@@ -137,5 +137,15 @@ module OpenWFE
|
|
137
137
|
workitem.attributes[FIELD_RESULT] = result
|
138
138
|
end
|
139
139
|
|
140
|
+
#
|
141
|
+
# Just a shortcut (for consistency) of
|
142
|
+
#
|
143
|
+
# workitem.attributes["__result__"]
|
144
|
+
#
|
145
|
+
def OpenWFE.get_result (workitem)
|
146
|
+
|
147
|
+
workitem.attributes[FIELD_RESULT]
|
148
|
+
end
|
149
|
+
|
140
150
|
end
|
141
151
|
|
@@ -254,7 +254,6 @@ module OpenWFE
|
|
254
254
|
#
|
255
255
|
def lookup_attribute (attname, workitem, default=nil)
|
256
256
|
|
257
|
-
#attname = attname.to_s
|
258
257
|
attname = symbol_to_attname(attname) \
|
259
258
|
if attname.kind_of? Symbol
|
260
259
|
|
@@ -262,7 +261,10 @@ module OpenWFE
|
|
262
261
|
|
263
262
|
text = @attributes[attname]
|
264
263
|
|
264
|
+
default = default.to_s if default
|
265
|
+
|
265
266
|
return default if not text
|
267
|
+
|
266
268
|
return OpenWFE::dosub(text, self, workitem)
|
267
269
|
end
|
268
270
|
|
@@ -59,35 +59,69 @@ module OpenWFE
|
|
59
59
|
|
60
60
|
attr_accessor \
|
61
61
|
:timeout_at,
|
62
|
-
:
|
62
|
+
:timeout_job_id
|
63
63
|
|
64
64
|
def determine_timeout
|
65
65
|
|
66
|
+
#@timeout_at = nil
|
67
|
+
#@timeout_job_id = nil
|
68
|
+
|
66
69
|
timeout = lookup_attribute(:timeout, @applied_workitem)
|
67
70
|
return unless timeout
|
68
71
|
|
69
72
|
timeout = OpenWFE::parse_time_string(timeout)
|
70
73
|
@timeout_at = Time.new.to_f + timeout
|
71
|
-
|
72
|
-
reschedule(get_scheduler)
|
73
74
|
end
|
74
75
|
|
76
|
+
#
|
77
|
+
# Overrides the parent method to make sure a potential
|
78
|
+
#
|
75
79
|
def reschedule (scheduler)
|
80
|
+
to_reschedule(scheduler)
|
81
|
+
end
|
82
|
+
|
83
|
+
#
|
84
|
+
# Overrides the parent method to make sure a potential
|
85
|
+
# timeout schedules gets removed.
|
86
|
+
#
|
87
|
+
def reply_to_parent (workitem)
|
88
|
+
unschedule_timeout()
|
89
|
+
super(workitem)
|
90
|
+
end
|
91
|
+
|
92
|
+
protected
|
76
93
|
|
77
|
-
|
94
|
+
#
|
95
|
+
# prefixed with "to_" for easy mix in
|
96
|
+
#
|
97
|
+
def to_reschedule (scheduler)
|
78
98
|
|
79
|
-
|
80
|
-
|
99
|
+
return if @timeout_job_id
|
100
|
+
#
|
101
|
+
# already rescheduled
|
81
102
|
|
82
|
-
|
83
|
-
|
84
|
-
|
103
|
+
return unless @timeout_at
|
104
|
+
#
|
105
|
+
# no need for a timeout
|
106
|
+
|
107
|
+
@timeout_job_id =
|
108
|
+
scheduler.schedule_at(@timeout_at, self, :do_timeout!)
|
109
|
+
|
110
|
+
ldebug do
|
111
|
+
"to_reschedule() will timeout at "+
|
112
|
+
"#{OpenWFE::to_iso8601_date(@timeout_at)}"
|
113
|
+
end
|
114
|
+
|
115
|
+
#store_itself()
|
116
|
+
#
|
117
|
+
# done in the including expression
|
85
118
|
end
|
86
119
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
120
|
+
def unschedule_timeout ()
|
121
|
+
|
122
|
+
get_scheduler.unschedule(@timeout_job_id) \
|
123
|
+
if @timeout_job_id
|
124
|
+
end
|
91
125
|
end
|
92
126
|
|
93
127
|
end
|
@@ -123,7 +123,12 @@ module OpenWFE
|
|
123
123
|
fei = FlowExpressionId.new()
|
124
124
|
|
125
125
|
ss = string.split(" ")
|
126
|
-
|
126
|
+
|
127
|
+
#require 'pp'
|
128
|
+
#puts
|
129
|
+
#pp ss
|
130
|
+
|
131
|
+
ss = ss[1..-1] if ss[0] == "("
|
127
132
|
|
128
133
|
fei.owfe_version = ss[1]
|
129
134
|
|
@@ -138,6 +143,9 @@ module OpenWFE
|
|
138
143
|
fei.expression_name = ss[7]
|
139
144
|
fei.expression_id = ss[8][0..-2]
|
140
145
|
|
146
|
+
fei.expression_id = fei.expression_id[0..-2] \
|
147
|
+
if fei.expression_id[-1, 1] == ")"
|
148
|
+
|
141
149
|
return fei
|
142
150
|
end
|
143
151
|
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
#
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2007, John Mettraux, OpenWFE.org
|
4
|
+
# All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# . Redistributions of source code must retain the above copyright notice, this
|
10
|
+
# list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# . Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# . Neither the name of the "OpenWFE" nor the names of its contributors may be
|
17
|
+
# used to endorse or promote products derived from this software without
|
18
|
+
# specific prior written permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
25
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
#++
|
32
|
+
#
|
33
|
+
# $Id$
|
34
|
+
#
|
35
|
+
|
36
|
+
#
|
37
|
+
# "made in Japan"
|
38
|
+
#
|
39
|
+
# John Mettraux at openwfe.org
|
40
|
+
#
|
41
|
+
|
42
|
+
require 'openwfe/utils'
|
43
|
+
require 'openwfe/util/dollar'
|
44
|
+
require 'openwfe/util/csvtable'
|
45
|
+
require 'openwfe/participants/participant'
|
46
|
+
|
47
|
+
include OpenWFE
|
48
|
+
|
49
|
+
|
50
|
+
module OpenWFE
|
51
|
+
|
52
|
+
#
|
53
|
+
# Using CSV files to transform workitems
|
54
|
+
# This concept is called "decision participant" in OpenWFEja, here
|
55
|
+
# it's simply called "csv participant".
|
56
|
+
#
|
57
|
+
# See CsvTable for an explanation of the core concept behind a
|
58
|
+
# CsvParticipant
|
59
|
+
#
|
60
|
+
# An example :
|
61
|
+
#
|
62
|
+
# class TestDefinition0 < ProcessDefinition
|
63
|
+
# def make
|
64
|
+
# process_definition :name => "test0", :revision => "0" do
|
65
|
+
# sequence do
|
66
|
+
# set :field => "weather", :value => "cloudy"
|
67
|
+
# set :field => "month", :value => "may"
|
68
|
+
# decision
|
69
|
+
# _print "${f:take_umbrella?}"
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
#
|
76
|
+
# csvParticipant = CsvParticipant.new(
|
77
|
+
# """
|
78
|
+
# in:weather, in:month, out:take_umbrella?
|
79
|
+
# ,,
|
80
|
+
# raining, , yes
|
81
|
+
# sunny, , no
|
82
|
+
# cloudy, june, yes
|
83
|
+
# cloudy, may, yes
|
84
|
+
# cloudy, , no
|
85
|
+
# """)
|
86
|
+
#
|
87
|
+
# engine.register_participant("decision", csvParticipant)
|
88
|
+
#
|
89
|
+
# # ...
|
90
|
+
#
|
91
|
+
# engine.launch(new OpenWFE::LaunchItem(TestDefinition0)
|
92
|
+
#
|
93
|
+
# Note that the CsvParticipant constructor also accepts a block.
|
94
|
+
#
|
95
|
+
class CsvParticipant
|
96
|
+
include LocalParticipant
|
97
|
+
|
98
|
+
attr_accessor \
|
99
|
+
:csv_table
|
100
|
+
|
101
|
+
#
|
102
|
+
# Builds a new CsvParticipant instance, csv_data or the block
|
103
|
+
# may contain a File instance, a String or an Array of Array of
|
104
|
+
# String instances.
|
105
|
+
#
|
106
|
+
def initialize (csv_data=nil, &block)
|
107
|
+
|
108
|
+
super()
|
109
|
+
|
110
|
+
csv_data = block.call if block
|
111
|
+
|
112
|
+
@csv_table = CsvTable.new(csv_data)
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# This is the method called by the engine (actually the
|
117
|
+
# ParticipantExpression) when handling a workitem to this participant.
|
118
|
+
#
|
119
|
+
def consume (workitem)
|
120
|
+
fe = get_flow_expression(workitem)
|
121
|
+
workitem = @csv_table.transform_wi(fe, workitem)
|
122
|
+
reply_to_engine(workitem)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
@@ -80,21 +80,44 @@ module OpenWFE
|
|
80
80
|
# After the block executes, the BlockParticipant immediately replies
|
81
81
|
# to the engine.
|
82
82
|
#
|
83
|
+
# You can pass a block with two arguments : flow_expression and workitem
|
84
|
+
# to BlockParticipant, it will automatically adapt.
|
85
|
+
#
|
86
|
+
# engine.register_participant("the_boss") do |fexp, wi|
|
87
|
+
# puts "the boss received a workitem from exp #{fexp.fei.to_s}"
|
88
|
+
# end
|
89
|
+
#
|
90
|
+
# Having the FlowExpression instance at hand allows for advanced tricks,
|
91
|
+
# beware...
|
92
|
+
#
|
83
93
|
class BlockParticipant
|
84
94
|
include LocalParticipant
|
85
95
|
|
86
|
-
def initialize (
|
87
|
-
@block =
|
96
|
+
def initialize (block0=nil, &block1)
|
97
|
+
@block = if block1
|
98
|
+
block1
|
99
|
+
else
|
100
|
+
block0
|
101
|
+
end
|
102
|
+
raise "Missing a block parameter" \
|
103
|
+
unless @block
|
88
104
|
end
|
89
105
|
|
90
106
|
def consume (workitem)
|
91
107
|
|
92
|
-
@block.
|
108
|
+
if @block.arity == 1
|
109
|
+
@block.call workitem
|
110
|
+
elsif @block.arity > 1
|
111
|
+
@block.call get_flow_expression(workitem), workitem
|
112
|
+
else
|
113
|
+
@block.call
|
114
|
+
end
|
93
115
|
|
94
116
|
reply_to_engine(workitem) \
|
95
117
|
if workitem.kind_of? InFlowWorkItem
|
96
118
|
# else it's a cancel item
|
97
119
|
end
|
98
120
|
end
|
121
|
+
|
99
122
|
end
|
100
123
|
|
@@ -37,9 +37,9 @@
|
|
37
37
|
# "hecho en Costa Rica"
|
38
38
|
#
|
39
39
|
|
40
|
-
require '
|
41
|
-
require '
|
42
|
-
require '
|
40
|
+
require 'openwfe/rest/xmlcodec'
|
41
|
+
require 'openwfe/rest/definitions'
|
42
|
+
require 'openwfe/rest/restclient'
|
43
43
|
|
44
44
|
|
45
45
|
module OpenWFE
|
@@ -68,11 +68,9 @@ module OpenWFE
|
|
68
68
|
end
|
69
69
|
|
70
70
|
#
|
71
|
-
#
|
71
|
+
# An alias for list_stores()
|
72
72
|
#
|
73
|
-
|
74
|
-
return listStores()
|
75
|
-
end
|
73
|
+
alias :get_store_names :list_stores
|
76
74
|
|
77
75
|
#
|
78
76
|
# Returns the headers of a given store.
|
@@ -161,7 +159,7 @@ module OpenWFE
|
|
161
159
|
|
162
160
|
#puts " .id is #{h.flowExpressionId}"
|
163
161
|
|
164
|
-
return get_and_lock_workitem(storeName, h.
|
162
|
+
return get_and_lock_workitem(storeName, h.flow_expression_id) \
|
165
163
|
if ok
|
166
164
|
end
|
167
165
|
|
@@ -40,10 +40,10 @@
|
|
40
40
|
#require 'base64'
|
41
41
|
require 'rexml/document'
|
42
42
|
|
43
|
-
require '
|
44
|
-
require '
|
45
|
-
require '
|
46
|
-
require '
|
43
|
+
require 'openwfe/utils'
|
44
|
+
require 'openwfe/workitem'
|
45
|
+
require 'openwfe/flowexpressionid'
|
46
|
+
require 'openwfe/rest/definitions'
|
47
47
|
|
48
48
|
|
49
49
|
module OpenWFE
|
@@ -215,7 +215,7 @@ module OpenWFE
|
|
215
215
|
return Integer(xmlElt.text) if xmlElt.name == E_INTEGER
|
216
216
|
return Integer(xmlElt.text) if xmlElt.name == E_LONG
|
217
217
|
return Float(xmlElt.text) if xmlElt.name == E_DOUBLE
|
218
|
-
return
|
218
|
+
return parse_boolean(xmlElt.text) if xmlElt.name == E_BOOLEAN
|
219
219
|
|
220
220
|
return xmlElt if xmlElt.name == E_XML
|
221
221
|
|
@@ -224,7 +224,7 @@ module OpenWFE
|
|
224
224
|
#
|
225
225
|
# composite types
|
226
226
|
|
227
|
-
return
|
227
|
+
return decode_list(xmlElt) if xmlElt.name == E_LIST
|
228
228
|
|
229
229
|
if xmlElt.name == E_SMAP or xmlElt.name == E_MAP
|
230
230
|
|