openwferu 0.9.9 → 0.9.10
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/kotoba.rb +22 -0
- data/lib/openwfe/engine/engine.rb +46 -10
- data/lib/openwfe/expool/expressionpool.rb +84 -71
- data/lib/openwfe/expool/history.rb +6 -2
- data/lib/openwfe/expool/journal.rb +9 -3
- data/lib/openwfe/expool/journal_replay.rb +8 -5
- data/lib/openwfe/expressions/fe_participant.rb +32 -1
- data/lib/openwfe/filterdef.rb +1 -1
- data/lib/openwfe/omixins.rb +70 -0
- data/lib/openwfe/participants/participantmap.rb +14 -1
- data/lib/openwfe/rest/definitions.rb +2 -1
- data/lib/openwfe/rest/xmlcodec.rb +56 -27
- data/lib/openwfe/util/kotoba.rb +2 -2
- data/lib/openwfe/util/workqueue.rb +177 -0
- data/lib/openwfe/utils.rb +52 -13
- data/lib/openwfe/version.rb +1 -1
- data/lib/openwfe/worklist/storeparticipant.rb +7 -4
- data/test/fei_test.rb +12 -1
- data/test/flowtestbase.rb +21 -8
- data/test/ft_0b_sequence.rb +6 -4
- data/test/ft_10_loop.rb +10 -5
- data/test/ft_10b_loop2.rb +5 -2
- data/test/ft_11_ppd.rb +12 -5
- data/test/ft_1_unset.rb +22 -13
- data/test/ft_23c_wait.rb +10 -6
- data/test/ft_25_cancel.rb +11 -5
- data/test/ft_27_getflowpos.rb +21 -4
- data/test/ft_28_fileparticipant.rb +1 -1
- data/test/ft_2c_concurrence.rb +8 -4
- data/test/ft_30_socketlistener.rb +8 -0
- data/test/ft_32_journal.rb +11 -2
- data/test/ft_34_cancelwfid.rb +4 -0
- data/test/ft_36_subprocids.rb +2 -1
- data/test/ft_37_pnames.rb +1 -1
- data/test/ft_38_tag.rb +5 -5
- data/test/ft_39_reserve.rb +1 -41
- data/test/ft_39b_reserve.rb +70 -0
- data/test/ft_40_defined.rb +2 -1
- data/test/ft_42_environments.rb +1 -2
- data/test/ft_45_citerator.rb +16 -4
- data/test/ft_46_pparams.rb +3 -0
- data/test/ft_49_condition.rb +2 -1
- data/test/ft_50_xml_attribute.rb +72 -3
- data/test/ft_51_stack.rb +58 -0
- data/test/ft_52_obs_participant.rb +127 -0
- data/test/ft_7b_lose.rb +5 -4
- data/test/ft_tests.rb +3 -0
- data/test/hparticipant_test.rb +21 -18
- data/test/misc_test.rb +9 -0
- data/test/param_test.rb +6 -0
- data/test/rake_test.rb +1 -0
- data/test/scheduler_test.rb +21 -0
- data/test/sec_test.rb +14 -27
- data/test/timeout_test.rb +6 -2
- metadata +8 -2
@@ -41,6 +41,7 @@
|
|
41
41
|
|
42
42
|
require 'openwfe/workitem'
|
43
43
|
require 'openwfe/service'
|
44
|
+
require 'openwfe/util/observable'
|
44
45
|
require 'openwfe/participants/participants'
|
45
46
|
|
46
47
|
include OpenWFE
|
@@ -52,6 +53,7 @@ module OpenWFE
|
|
52
53
|
# A very simple directory of participants
|
53
54
|
#
|
54
55
|
class ParticipantMap < Service
|
56
|
+
include Observable
|
55
57
|
|
56
58
|
attr_accessor \
|
57
59
|
:participants
|
@@ -60,6 +62,8 @@ module OpenWFE
|
|
60
62
|
super(service_name, application_context)
|
61
63
|
|
62
64
|
@participants = []
|
65
|
+
|
66
|
+
@observers = {}
|
63
67
|
end
|
64
68
|
|
65
69
|
#
|
@@ -167,12 +171,21 @@ module OpenWFE
|
|
167
171
|
|
168
172
|
workitem.participant_name = participant_name
|
169
173
|
|
170
|
-
if workitem.kind_of?
|
174
|
+
if (workitem.kind_of?(CancelItem) and
|
175
|
+
participant.respond_to?(:cancel))
|
176
|
+
|
171
177
|
participant.cancel(workitem)
|
178
|
+
|
179
|
+
onotify :dispatch, :cancel, workitem
|
180
|
+
|
172
181
|
return
|
173
182
|
end
|
174
183
|
|
184
|
+
onotify :dispatch, :before_consume, workitem
|
185
|
+
|
175
186
|
participant.consume(workitem)
|
187
|
+
|
188
|
+
onotify :dispatch, :after_consume, workitem
|
176
189
|
end
|
177
190
|
end
|
178
191
|
|
@@ -37,6 +37,7 @@
|
|
37
37
|
# "hecho en Costa Rica"
|
38
38
|
#
|
39
39
|
|
40
|
+
require 'base64'
|
40
41
|
require 'rexml/document'
|
41
42
|
|
42
43
|
require 'openwfe/utils'
|
@@ -62,7 +63,11 @@ module OpenWFE
|
|
62
63
|
|
63
64
|
if xmlElt.kind_of? String
|
64
65
|
|
65
|
-
xmlElt = REXML::Document.new(
|
66
|
+
xmlElt = REXML::Document.new(
|
67
|
+
xmlElt,
|
68
|
+
:compress_whitespace => :all,
|
69
|
+
:ignore_whitespace_nodes => :all)
|
70
|
+
|
66
71
|
xmlElt = xmlElt.root
|
67
72
|
end
|
68
73
|
|
@@ -145,7 +150,7 @@ module OpenWFE
|
|
145
150
|
launchable.url = xmlElt.attributes[URL]
|
146
151
|
launchable.engine_id = xmlElt.attributes[ENGINE_ID]
|
147
152
|
|
148
|
-
|
153
|
+
launchable
|
149
154
|
end
|
150
155
|
|
151
156
|
|
@@ -210,7 +215,7 @@ module OpenWFE
|
|
210
215
|
#puts " ... fei.expressionName is >#{fei.expressionName}<"
|
211
216
|
#puts " ... fei.wfid is >#{fei.workflowInstanceId}<"
|
212
217
|
|
213
|
-
|
218
|
+
fei
|
214
219
|
end
|
215
220
|
|
216
221
|
|
@@ -221,20 +226,30 @@ module OpenWFE
|
|
221
226
|
#
|
222
227
|
# atomic types
|
223
228
|
|
224
|
-
return xmlElt.text
|
225
|
-
|
226
|
-
return Integer(xmlElt.text)
|
227
|
-
|
228
|
-
return
|
229
|
-
|
230
|
-
return xmlElt
|
231
|
-
|
232
|
-
return
|
229
|
+
return xmlElt.text \
|
230
|
+
if xmlElt.name == E_STRING
|
231
|
+
return Integer(xmlElt.text) \
|
232
|
+
if xmlElt.name == E_INTEGER
|
233
|
+
return Integer(xmlElt.text) \
|
234
|
+
if xmlElt.name == E_LONG
|
235
|
+
return Float(xmlElt.text) \
|
236
|
+
if xmlElt.name == E_DOUBLE
|
237
|
+
return parse_boolean(xmlElt.text) \
|
238
|
+
if xmlElt.name == E_BOOLEAN
|
239
|
+
|
240
|
+
return decode_xmldocument(xmlElt) \
|
241
|
+
if xmlElt.name == E_XML_DOCUMENT
|
242
|
+
return xmlElt.children[0] \
|
243
|
+
if xmlElt.name == E_RAW_XML
|
244
|
+
|
245
|
+
return Base64Attribute.new(xmlElt.text) \
|
246
|
+
if xmlElt.name == E_BASE64
|
233
247
|
|
234
248
|
#
|
235
249
|
# composite types
|
236
250
|
|
237
|
-
return decode_list(xmlElt)
|
251
|
+
return decode_list(xmlElt) \
|
252
|
+
if xmlElt.name == E_LIST
|
238
253
|
|
239
254
|
if xmlElt.name == E_SMAP or xmlElt.name == E_MAP
|
240
255
|
|
@@ -258,6 +273,12 @@ module OpenWFE
|
|
258
273
|
OpenWFE.xmldoc_to_string(xmlElt.document())
|
259
274
|
end
|
260
275
|
|
276
|
+
def decode_xmldocument (xmlElt)
|
277
|
+
|
278
|
+
s = Base64::decode64 xmlElt.text.strip
|
279
|
+
REXML::Document.new s
|
280
|
+
end
|
281
|
+
|
261
282
|
def decode_entry (xmlElt, map)
|
262
283
|
|
263
284
|
key = xmlElt.elements[1]
|
@@ -452,25 +473,27 @@ module OpenWFE
|
|
452
473
|
#puts "encodeAttribute() att.class is #{att.class}"
|
453
474
|
|
454
475
|
return encode_atomicattribute(E_STRING, att) \
|
455
|
-
if att.kind_of?
|
476
|
+
if att.kind_of?(String)
|
456
477
|
return encode_atomicattribute(E_INTEGER, att) \
|
457
|
-
if att.kind_of?
|
478
|
+
if att.kind_of?(Fixnum)
|
458
479
|
return encode_atomicattribute(E_DOUBLE, att) \
|
459
|
-
if att.kind_of?
|
480
|
+
if att.kind_of?(Float)
|
460
481
|
|
482
|
+
return encode_xmldocument(att) \
|
483
|
+
if att.kind_of?(REXML::Document)
|
461
484
|
return encode_xmlattribute(att) \
|
462
|
-
if att.kind_of?
|
485
|
+
if att.kind_of?(REXML::Element)
|
463
486
|
|
464
487
|
return encode_atomicattribute(E_BOOLEAN, true) \
|
465
|
-
if att.kind_of?
|
488
|
+
if att.kind_of?(TrueClass)
|
466
489
|
return encode_atomicattribute(E_BOOLEAN, false) \
|
467
|
-
if att.kind_of?
|
490
|
+
if att.kind_of?(FalseClass)
|
468
491
|
|
469
492
|
return encode_base64attribute(att) \
|
470
|
-
if att.kind_of?
|
493
|
+
if att.kind_of?(Base64Attribute)
|
471
494
|
|
472
|
-
return encode_mapattribute(att) if att.kind_of?
|
473
|
-
return encode_listattribute(att) if att.kind_of?
|
495
|
+
return encode_mapattribute(att) if att.kind_of?(Hash)
|
496
|
+
return encode_listattribute(att) if att.kind_of?(Array)
|
474
497
|
|
475
498
|
#
|
476
499
|
# default
|
@@ -482,18 +505,24 @@ module OpenWFE
|
|
482
505
|
# "Cannot encode attribute of class '#{att.class}'"
|
483
506
|
end
|
484
507
|
|
508
|
+
def encode_xmldocument (elt)
|
509
|
+
|
510
|
+
e = REXML::Element.new(E_XML_DOCUMENT)
|
511
|
+
e.text = Base64::encode64(elt.to_s)
|
512
|
+
e
|
513
|
+
end
|
485
514
|
|
486
515
|
def encode_xmlattribute (elt)
|
487
516
|
|
488
|
-
return elt if elt.name ==
|
517
|
+
return elt if elt.name == E_RAW_XML
|
489
518
|
|
490
519
|
#
|
491
520
|
# else, wrap within <raw-xml>...</raw-xml>
|
492
521
|
|
493
|
-
e = REXML::Element.new(
|
522
|
+
e = REXML::Element.new(E_RAW_XML)
|
494
523
|
e << elt
|
495
524
|
|
496
|
-
|
525
|
+
e
|
497
526
|
end
|
498
527
|
|
499
528
|
|
@@ -502,7 +531,7 @@ module OpenWFE
|
|
502
531
|
e = REXML::Element.new(E_BASE64)
|
503
532
|
e.text = att.content
|
504
533
|
|
505
|
-
|
534
|
+
e
|
506
535
|
end
|
507
536
|
|
508
537
|
|
@@ -512,7 +541,7 @@ module OpenWFE
|
|
512
541
|
#elt << REXML::Text.new(value.to_s())
|
513
542
|
elt.add_text(value.to_s())
|
514
543
|
|
515
|
-
|
544
|
+
elt
|
516
545
|
end
|
517
546
|
|
518
547
|
|
data/lib/openwfe/util/kotoba.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
#--
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2007, John Mettraux OpenWFE.org
|
4
4
|
# All rights reserved.
|
5
5
|
#
|
6
6
|
# Redistribution and use in source and binary forms, with or without
|
@@ -53,7 +53,7 @@
|
|
53
53
|
#
|
54
54
|
# Kotoba is meant to be used for generating human readable (or more
|
55
55
|
# easily rememberable) identifiers. Its first usage is within the
|
56
|
-
# OpenWFEru Ruby workflow and bpm engine for generating '
|
56
|
+
# OpenWFEru Ruby workflow and bpm engine for generating 'kawaii'
|
57
57
|
# business process intance ids.
|
58
58
|
#
|
59
59
|
# == Kotoba from the command line
|
@@ -0,0 +1,177 @@
|
|
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 'thread'
|
43
|
+
require 'openwfe/utils'
|
44
|
+
|
45
|
+
|
46
|
+
module OpenWFE
|
47
|
+
|
48
|
+
module WorkqueueMixin
|
49
|
+
|
50
|
+
WQF_LOW = 0.500
|
51
|
+
|
52
|
+
#
|
53
|
+
# Starts the workqueue with a given frequency (seconds)
|
54
|
+
#
|
55
|
+
def start_workqueue
|
56
|
+
|
57
|
+
@workqueue_mutex = Mutex.new
|
58
|
+
@workqueue = []
|
59
|
+
@workqueue_frequency = 0
|
60
|
+
|
61
|
+
OpenWFE::call_in_thread "expression_pool", self do
|
62
|
+
while true
|
63
|
+
sleep @workqueue_frequency
|
64
|
+
break if @workqueue_frequency == nil
|
65
|
+
do_process_workqueue
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Returns true if there is or there just was activity for the ]
|
72
|
+
# work queue.
|
73
|
+
#
|
74
|
+
def is_workqueue_busy?
|
75
|
+
(@workqueue.size > 0 or @workqueue_frequency < WQF_LOW)
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Stops the workqueue.
|
80
|
+
#
|
81
|
+
def stop_workqueue
|
82
|
+
@workqueue_frequency = nil
|
83
|
+
do_process_workqueue
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# the method called by the mixer to actually queue the work.
|
88
|
+
#
|
89
|
+
def queue_work (*args)
|
90
|
+
@workqueue_mutex.synchronize do
|
91
|
+
|
92
|
+
if @workqueue
|
93
|
+
@workqueue.push args
|
94
|
+
#
|
95
|
+
# work will be done later (millisec order)
|
96
|
+
# by the work thread
|
97
|
+
else
|
98
|
+
do_process_workelement args
|
99
|
+
#
|
100
|
+
# degraded mode : as if there were no workqueue
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
#
|
106
|
+
# Returns the current workqueue size
|
107
|
+
#
|
108
|
+
def workqueue_size
|
109
|
+
return 0 unless @workqueue
|
110
|
+
@workqueue.size
|
111
|
+
end
|
112
|
+
|
113
|
+
#
|
114
|
+
# Called by the workqueue thread, copies the workqueue and clears
|
115
|
+
# it, and then processes the elt in the copied workqueue.
|
116
|
+
# (meanwhile, the empty workqueue gets filled by queue_work()
|
117
|
+
# calls)
|
118
|
+
#
|
119
|
+
# This method calls the do_process_workelement() method of
|
120
|
+
# its 'mixer' with each work element queued.
|
121
|
+
#
|
122
|
+
def do_process_workqueue
|
123
|
+
|
124
|
+
q = nil
|
125
|
+
|
126
|
+
@workqueue_mutex.synchronize do
|
127
|
+
|
128
|
+
if @workqueue.size < 1
|
129
|
+
increment_workqueue_frequency
|
130
|
+
return
|
131
|
+
end
|
132
|
+
|
133
|
+
q = Array.new(@workqueue)
|
134
|
+
@workqueue.clear
|
135
|
+
|
136
|
+
@workqueue_frequency = 0
|
137
|
+
#
|
138
|
+
# back to maximum reponsiveness
|
139
|
+
end
|
140
|
+
|
141
|
+
#ldebug { "do_process_workqueue() #{q.size} items to process" }
|
142
|
+
|
143
|
+
q.each do |elt|
|
144
|
+
begin
|
145
|
+
|
146
|
+
do_process_workelement elt
|
147
|
+
|
148
|
+
rescue Exception => e
|
149
|
+
|
150
|
+
lwarn do
|
151
|
+
"#{self.service_name} caught an exception\n" +
|
152
|
+
OpenWFE::exception_to_s(e)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
protected
|
159
|
+
|
160
|
+
#
|
161
|
+
# No activity spotted, so decrease responsiveness
|
162
|
+
#
|
163
|
+
def increment_workqueue_frequency
|
164
|
+
|
165
|
+
return if @workqueue_frequency == nil
|
166
|
+
|
167
|
+
@workqueue_frequency *= 3
|
168
|
+
|
169
|
+
if @workqueue_frequency == 0
|
170
|
+
@workqueue_frequency = 0.001
|
171
|
+
elsif @workqueue_frequency > WQF_LOW
|
172
|
+
@workqueue_frequency = WQF_LOW
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
data/lib/openwfe/utils.rb
CHANGED
@@ -112,27 +112,34 @@ module OpenWFE
|
|
112
112
|
|
113
113
|
return nil if object == nil
|
114
114
|
|
115
|
-
return object if object.kind_of?
|
116
|
-
return object if object.kind_of?
|
117
|
-
return object if object.kind_of?
|
118
|
-
return object if object.kind_of?
|
115
|
+
return object if object.kind_of?(Float)
|
116
|
+
return object if object.kind_of?(Fixnum)
|
117
|
+
return object if object.kind_of?(TrueClass)
|
118
|
+
return object if object.kind_of?(FalseClass)
|
119
119
|
|
120
|
-
return object.dup if object.kind_of?
|
120
|
+
return object.dup if object.kind_of?(String)
|
121
121
|
|
122
122
|
#return deep_clone(object) if object.kind_of? REXML::Document
|
123
|
-
|
124
|
-
|
123
|
+
|
124
|
+
#return REXML::Document.new(object.to_s) \
|
125
|
+
# if object.kind_of? REXML::Document
|
126
|
+
|
127
|
+
if object.kind_of?(REXML::Element)
|
128
|
+
d = REXML::Document.new object.to_s
|
129
|
+
return d if object.kind_of?(REXML::Document)
|
130
|
+
return d.root
|
131
|
+
end
|
125
132
|
|
126
133
|
o = object.class.new
|
127
134
|
|
128
135
|
#
|
129
136
|
# some kind of collection ?
|
130
137
|
|
131
|
-
if object.kind_of?
|
138
|
+
if object.kind_of?(Array)
|
132
139
|
object.each do |i|
|
133
140
|
o << fulldup(i)
|
134
141
|
end
|
135
|
-
elsif object.kind_of?
|
142
|
+
elsif object.kind_of?(Hash)
|
136
143
|
object.each do |k, v|
|
137
144
|
o[copy(k)] = fulldup(v)
|
138
145
|
end
|
@@ -158,7 +165,7 @@ module OpenWFE
|
|
158
165
|
end
|
159
166
|
end
|
160
167
|
|
161
|
-
|
168
|
+
o
|
162
169
|
end
|
163
170
|
|
164
171
|
def OpenWFE.to_underscore (string)
|
@@ -195,7 +202,7 @@ module OpenWFE
|
|
195
202
|
return URI::parse(string)
|
196
203
|
rescue Exception => e
|
197
204
|
end
|
198
|
-
|
205
|
+
nil
|
199
206
|
end
|
200
207
|
|
201
208
|
#
|
@@ -209,7 +216,7 @@ module OpenWFE
|
|
209
216
|
#
|
210
217
|
return false unless string
|
211
218
|
return false if string.length < start.length
|
212
|
-
|
219
|
+
string[0, start.length] == start
|
213
220
|
end
|
214
221
|
|
215
222
|
#
|
@@ -218,7 +225,7 @@ module OpenWFE
|
|
218
225
|
def OpenWFE.ends_with (string, _end)
|
219
226
|
return false unless string
|
220
227
|
return false if string.length < _end.length
|
221
|
-
|
228
|
+
string[-_end.length..-1] == _end
|
222
229
|
end
|
223
230
|
|
224
231
|
#
|
@@ -254,6 +261,8 @@ module OpenWFE
|
|
254
261
|
# raw_expression.apply(wi)
|
255
262
|
# end
|
256
263
|
#
|
264
|
+
# Returns the new thread instance.
|
265
|
+
#
|
257
266
|
def OpenWFE.call_in_thread (caller_name, caller_object=nil, &block)
|
258
267
|
|
259
268
|
return unless block
|
@@ -262,10 +271,12 @@ module OpenWFE
|
|
262
271
|
begin
|
263
272
|
#$SAFE = safe_level
|
264
273
|
#
|
274
|
+
# (note)
|
265
275
|
# doesn't work : the block inherits the safety level
|
266
276
|
# of its surroundings, it's a closure, ne ?
|
267
277
|
|
268
278
|
block.call
|
279
|
+
|
269
280
|
rescue Exception => e
|
270
281
|
msg = "#{caller_name} caught an exception\n" + exception_to_s(e)
|
271
282
|
if caller_object and caller_object.respond_to? :lwarn
|
@@ -370,6 +381,34 @@ module OpenWFE
|
|
370
381
|
return has_attribute?(rest, key)
|
371
382
|
end
|
372
383
|
|
384
|
+
#
|
385
|
+
# Returns a list of lines matching the pattern in the given file.
|
386
|
+
#
|
387
|
+
# This is also possible :
|
388
|
+
#
|
389
|
+
# OpenWFE::grep "^..) ", "path/to/file.txt" do |line|
|
390
|
+
# puts " - '#{line.downcase}'"
|
391
|
+
# end
|
392
|
+
#
|
393
|
+
def OpenWFE.grep (pattern, filepath, &block)
|
394
|
+
|
395
|
+
result = []
|
396
|
+
r = Regexp.new pattern
|
397
|
+
|
398
|
+
File.open filepath do |file|
|
399
|
+
file.readlines.each do |l|
|
400
|
+
if r.match l
|
401
|
+
if block
|
402
|
+
block.call l
|
403
|
+
else
|
404
|
+
result << l
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
409
|
+
result unless block
|
410
|
+
end
|
411
|
+
|
373
412
|
#
|
374
413
|
# This method is used within the InFlowWorkItem and the CsvTable classes.
|
375
414
|
#
|
data/lib/openwfe/version.rb
CHANGED
@@ -39,6 +39,7 @@
|
|
39
39
|
#
|
40
40
|
|
41
41
|
require 'openwfe/utils'
|
42
|
+
require 'openwfe/omixins'
|
42
43
|
require 'openwfe/rudefinitions'
|
43
44
|
require 'openwfe/storage/yamlfilestorage'
|
44
45
|
require 'openwfe/participants/participant'
|
@@ -65,6 +66,7 @@ module OpenWFE
|
|
65
66
|
#
|
66
67
|
module StoreParticipantMixin
|
67
68
|
include LocalParticipant
|
69
|
+
include FeiMixin
|
68
70
|
|
69
71
|
#def initialize ()
|
70
72
|
#end
|
@@ -132,9 +134,10 @@ module OpenWFE
|
|
132
134
|
# identifier.
|
133
135
|
#
|
134
136
|
def delete (wi_or_fei)
|
135
|
-
fei = wi_or_fei
|
136
|
-
fei = fei.fei if fei.is_a? InFlowWorkItem
|
137
|
-
super fei
|
137
|
+
#fei = wi_or_fei
|
138
|
+
#fei = fei.fei if fei.is_a? InFlowWorkItem
|
139
|
+
#super fei
|
140
|
+
super extract_fei(wi_or_fei)
|
138
141
|
end
|
139
142
|
|
140
143
|
#
|
@@ -159,7 +162,7 @@ module OpenWFE
|
|
159
162
|
if (not workflow_instance_id) or workitem.fei.parent_wfid == workflow_instance_id
|
160
163
|
end
|
161
164
|
|
162
|
-
|
165
|
+
result
|
163
166
|
end
|
164
167
|
|
165
168
|
#
|
data/test/fei_test.rb
CHANGED
@@ -9,9 +9,10 @@
|
|
9
9
|
|
10
10
|
require 'test/unit'
|
11
11
|
require 'rutest_utils'
|
12
|
+
#require 'openwfe/owfe'
|
12
13
|
require 'openwfe/workitem'
|
13
14
|
require 'openwfe/flowexpressionid'
|
14
|
-
|
15
|
+
require 'openwfe/rudefinitions'
|
15
16
|
|
16
17
|
|
17
18
|
class FeiTest < Test::Unit::TestCase
|
@@ -131,6 +132,16 @@ class FeiTest < Test::Unit::TestCase
|
|
131
132
|
"failure 1"
|
132
133
|
end
|
133
134
|
|
135
|
+
#def test_to_fei
|
136
|
+
# fei = new_fei
|
137
|
+
# wi = OpenWFE::InFlowItem.new
|
138
|
+
# wi.last_expression_id = fei
|
139
|
+
# assert_nil OpenWFE::to_fei(nil)
|
140
|
+
# assert_equal fei, OpenWFE::to_fei(fei)
|
141
|
+
# assert_equal fei, OpenWFE::to_fei(wi)
|
142
|
+
# assert_equal fei, OpenWFE::to_fei(fei.to_s)
|
143
|
+
#end
|
144
|
+
|
134
145
|
protected
|
135
146
|
|
136
147
|
def puts_hash (h)
|