openwferu 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +4 -5
- data/lib/openwfe/engine/engine.rb +14 -14
- data/lib/openwfe/expool/expressionpool.rb +60 -45
- data/lib/openwfe/expool/expstorage.rb +1 -1
- data/lib/openwfe/expressions/condition.rb +47 -34
- data/lib/openwfe/expressions/environment.rb +29 -7
- data/lib/openwfe/expressions/expressionmap.rb +16 -1
- data/lib/openwfe/expressions/fe_concurrence.rb +142 -55
- data/lib/openwfe/expressions/fe_cursor.rb +146 -41
- data/lib/openwfe/expressions/fe_define.rb +52 -35
- data/lib/openwfe/expressions/fe_filter.rb +129 -0
- data/lib/openwfe/expressions/fe_filter_definition.rb +170 -0
- data/lib/openwfe/expressions/fe_iterator.rb +23 -10
- data/lib/openwfe/expressions/fe_losfor.rb +7 -6
- data/lib/openwfe/expressions/fe_participant.rb +19 -9
- data/lib/openwfe/expressions/fe_raw.rb +11 -16
- data/lib/openwfe/expressions/fe_save.rb +225 -0
- data/lib/openwfe/expressions/fe_sequence.rb +15 -10
- data/lib/openwfe/expressions/fe_subprocess.rb +0 -6
- data/lib/openwfe/expressions/fe_value.rb +7 -19
- data/lib/openwfe/expressions/filter.rb +104 -0
- data/lib/openwfe/expressions/flowexpression.rb +102 -36
- data/lib/openwfe/expressions/merge.rb +80 -0
- data/lib/openwfe/expressions/raw_prog.rb +21 -18
- data/lib/openwfe/filterdef.rb +259 -0
- data/lib/openwfe/flowexpressionid.rb +36 -3
- data/lib/openwfe/participants/participants.rb +7 -1
- data/lib/openwfe/rest/xmlcodec.rb +1 -1
- data/lib/openwfe/util/dollar.rb +4 -2
- data/lib/openwfe/util/scheduler.rb +3 -1
- data/lib/openwfe/util/sqs.rb +1 -2
- data/lib/openwfe/utils.rb +13 -0
- data/lib/openwfe/version.rb +1 -1
- data/lib/openwfe/workitem.rb +1 -1
- data/test/filter_test.rb +109 -0
- data/test/flowtestbase.rb +12 -1
- data/test/ft_11_ppd.rb +13 -1
- data/test/ft_11b_ppd.rb +45 -0
- data/test/ft_17_condition.rb +1 -1
- data/test/ft_2b_concurrence.rb +24 -0
- data/test/ft_2c_concurrence.rb +22 -1
- data/test/ft_3_equals.rb +26 -0
- data/test/ft_42_environments.rb +78 -0
- data/test/ft_43_pat10.rb +109 -0
- data/test/ft_44_save.rb +81 -0
- data/test/ft_44b_restore.rb +159 -0
- data/test/ft_45_citerator.rb +104 -0
- data/test/ft_46_pparams.rb +62 -0
- data/test/ft_47_filter.rb +165 -0
- data/test/ft_48_fe_filter.rb +91 -0
- data/test/ft_49_condition.rb +65 -0
- data/test/ft_50_xml_attribute.rb +89 -0
- data/test/ft_9_cursor.rb +36 -6
- data/test/ft_tests.rb +11 -1
- data/test/misc_test.rb +8 -0
- data/test/rake_qtest.rb +2 -2
- data/test/rutest_utils.rb +6 -1
- data/test/sec_test.rb +2 -2
- metadata +20 -2
data/README.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= OpenWFEru, Standard Library Documentation
|
2
2
|
|
3
3
|
== Prerequisites
|
4
|
-
Ruby 1.8.
|
4
|
+
Ruby 1.8.4 or later
|
5
5
|
|
6
6
|
== Supported platforms
|
7
7
|
TODO
|
@@ -61,9 +61,8 @@ libraries:
|
|
61
61
|
[rake] Handle builds, generating documentation, and running unit tests
|
62
62
|
[rubygems] Handles creation of the gems
|
63
63
|
[rote] A framework being used to help with managing the offline written docs
|
64
|
-
[redcloth]
|
64
|
+
[redcloth] OpenWFEru uses textile-markup for its docs. Redcloth provides an engine for it.
|
65
65
|
[tidy] General cleanup
|
66
|
-
[libxml-ruby] Allows XSD validation
|
67
66
|
|
68
67
|
It's best if you use gems to install these as the process can get rather
|
69
68
|
tedious by hand.
|
@@ -89,10 +88,10 @@ On Ubuntu you can install libxml2 with:
|
|
89
88
|
The main project site lives at rubyforge at:
|
90
89
|
http://rubyforge.org/projects/openwferu
|
91
90
|
or
|
92
|
-
http://
|
91
|
+
http://openwferu.rubyforge.org
|
93
92
|
|
94
93
|
In the meantime the old site hosted at openwfe.org is at:
|
95
94
|
http://www.openwfe.org/openwfe-ruby.html
|
96
95
|
|
97
|
-
If you're interested in helping : http://groups.google.com/group/openwferu-
|
96
|
+
If you're interested in helping : http://groups.google.com/group/openwferu-users/topics
|
98
97
|
|
@@ -136,29 +136,29 @@ module OpenWFE
|
|
136
136
|
#
|
137
137
|
def launch (launch_object, async=false)
|
138
138
|
|
139
|
-
launchitem =
|
139
|
+
launchitem = if launch_object.kind_of?(OpenWFE::LaunchItem)
|
140
140
|
|
141
|
-
|
141
|
+
launch_object
|
142
142
|
|
143
|
-
|
143
|
+
elsif launch_object.kind_of?(Class)
|
144
144
|
|
145
|
-
|
146
|
-
|
147
|
-
launchitem = LaunchItem.new(launch_object)
|
145
|
+
LaunchItem.new launch_object
|
148
146
|
|
149
147
|
elsif launch_object.kind_of? String
|
150
148
|
|
151
|
-
|
149
|
+
li = OpenWFE::LaunchItem.new
|
152
150
|
|
153
|
-
if launch_object[0] == '<'
|
154
|
-
|
155
|
-
|
151
|
+
if launch_object[0, 1] == '<'
|
152
|
+
li.workflowDefinitionUrl = "field:__definition"
|
153
|
+
li['definition'] = launch_object
|
156
154
|
else
|
157
|
-
|
155
|
+
li.workflowDefinitionUrl = launch_object
|
158
156
|
end
|
157
|
+
|
158
|
+
li
|
159
159
|
end
|
160
160
|
|
161
|
-
get_expression_pool.launch
|
161
|
+
get_expression_pool.launch launchitem, async
|
162
162
|
end
|
163
163
|
|
164
164
|
#
|
@@ -170,11 +170,11 @@ module OpenWFE
|
|
170
170
|
#
|
171
171
|
def reply (workitem)
|
172
172
|
|
173
|
-
if workitem.kind_of?
|
173
|
+
if workitem.kind_of?(InFlowWorkItem)
|
174
174
|
|
175
175
|
get_expression_pool.reply(workitem.flow_expression_id, workitem)
|
176
176
|
|
177
|
-
elsif workitem.kind_of?
|
177
|
+
elsif workitem.kind_of?(LaunchItem)
|
178
178
|
|
179
179
|
get_expression_pool.launch(workitem, false)
|
180
180
|
|
@@ -183,7 +183,7 @@ module OpenWFE
|
|
183
183
|
|
184
184
|
definition = if wfdurl.match "^field:"
|
185
185
|
wfdfield = wfdurl[6..-1]
|
186
|
-
launchitem.attributes.delete
|
186
|
+
launchitem.attributes.delete wfdfield
|
187
187
|
else
|
188
188
|
read_uri(wfdurl)
|
189
189
|
end
|
@@ -191,9 +191,9 @@ module OpenWFE
|
|
191
191
|
raise "didn't find process definition at '#{wfdurl}'" \
|
192
192
|
unless definition
|
193
193
|
|
194
|
-
raw_expression = build_raw_expression
|
194
|
+
raw_expression = build_raw_expression launchitem, definition
|
195
195
|
|
196
|
-
raw_expression.check_parameters
|
196
|
+
raw_expression.check_parameters launchitem
|
197
197
|
#
|
198
198
|
# will raise an exception if there are requirements
|
199
199
|
# and one of them is not met
|
@@ -246,10 +246,14 @@ module OpenWFE
|
|
246
246
|
end
|
247
247
|
|
248
248
|
#
|
249
|
-
#
|
249
|
+
# Prepares a raw expression from a template.
|
250
|
+
# Returns that raw expression.
|
250
251
|
#
|
251
|
-
|
252
|
-
|
252
|
+
# Used in the concurrent-iterator when building up the children list
|
253
|
+
# and of course used by the launch_template() method.
|
254
|
+
#
|
255
|
+
def prepare_from_template (
|
256
|
+
requesting_expression, sub_id, template, params=nil)
|
253
257
|
|
254
258
|
rawexp = if template.is_a? RawExpression
|
255
259
|
template
|
@@ -293,34 +297,34 @@ module OpenWFE
|
|
293
297
|
"#{requesting_expression.fei.workflow_instance_id}.#{sub_id}"
|
294
298
|
end
|
295
299
|
|
296
|
-
#ldebug do
|
297
|
-
# p = ""
|
298
|
-
# p = rawexp.parent_id.to_debug_s if rawexp.parent_id
|
299
|
-
# "launch_template()\n"+
|
300
|
-
# " rawexp.fei is #{rawexp.fei.to_debug_s}\n"+
|
301
|
-
# " rawexp.parent_id is #{p}"
|
302
|
-
#end
|
303
|
-
|
304
300
|
#ldebug do
|
305
301
|
# "launch_template() spawning wfid " +
|
306
302
|
# "#{rawexp.fei.workflow_instance_id.to_s}"
|
307
303
|
#end
|
308
304
|
|
309
|
-
env = rawexp.new_environment()
|
310
|
-
#
|
311
|
-
params.each { |k, v| env[k] = v } if params
|
305
|
+
env = rawexp.new_environment(params)
|
312
306
|
#
|
313
307
|
# the new scope gets its own environment
|
314
308
|
|
315
309
|
rawexp.store_itself()
|
316
310
|
|
317
|
-
|
311
|
+
rawexp
|
312
|
+
end
|
318
313
|
|
319
|
-
|
314
|
+
#
|
315
|
+
# launches a subprocess
|
316
|
+
#
|
317
|
+
def launch_template (
|
318
|
+
requesting_expression, sub_id, template, workitem, params=nil)
|
320
319
|
|
321
|
-
|
320
|
+
rawexp = prepare_from_template(
|
321
|
+
requesting_expression, sub_id, template, params)
|
322
322
|
|
323
|
-
|
323
|
+
workitem.flow_expression_id = rawexp.fei
|
324
|
+
|
325
|
+
apply rawexp, workitem
|
326
|
+
|
327
|
+
rawexp.fei
|
324
328
|
end
|
325
329
|
|
326
330
|
#
|
@@ -329,15 +333,15 @@ module OpenWFE
|
|
329
333
|
#
|
330
334
|
def evaluate (rawExpression, workitem)
|
331
335
|
|
332
|
-
exp = rawExpression.instantiate_real_expression
|
333
|
-
fei = exp.evaluate
|
336
|
+
exp = rawExpression.instantiate_real_expression workitem
|
337
|
+
fei = exp.evaluate workitem
|
334
338
|
|
335
339
|
#remove(rawExpression)
|
336
340
|
#
|
337
341
|
# not necessary, the raw expression gets overriden by
|
338
342
|
# the real expression
|
339
343
|
|
340
|
-
|
344
|
+
fei
|
341
345
|
end
|
342
346
|
|
343
347
|
#
|
@@ -408,16 +412,23 @@ module OpenWFE
|
|
408
412
|
# Forgets the given expression (makes sure to substitute its
|
409
413
|
# parent_id with the GONE_PARENT_ID constant)
|
410
414
|
#
|
411
|
-
def forget (exp)
|
415
|
+
def forget (parent_exp, exp)
|
412
416
|
|
413
417
|
exp, fei = fetch(exp)
|
414
418
|
|
419
|
+
#ldebug { "forget() forgetting #{fei}" }
|
420
|
+
|
415
421
|
return if not exp
|
416
422
|
|
417
423
|
onotify :forget, fei
|
418
424
|
|
425
|
+
parent_exp.children.delete(fei)
|
426
|
+
|
419
427
|
exp.parent_id = GONE_PARENT_ID
|
428
|
+
exp.dup_environment
|
420
429
|
exp.store_itself()
|
430
|
+
|
431
|
+
ldebug { "forget() forgot #{fei}" }
|
421
432
|
end
|
422
433
|
|
423
434
|
#
|
@@ -479,7 +490,7 @@ module OpenWFE
|
|
479
490
|
#
|
480
491
|
# parent still present, reply to it
|
481
492
|
|
482
|
-
reply
|
493
|
+
reply exp.parent_id, workitem
|
483
494
|
end
|
484
495
|
|
485
496
|
#
|
@@ -558,7 +569,7 @@ module OpenWFE
|
|
558
569
|
#
|
559
570
|
def fetch_expression (exp)
|
560
571
|
exp, _fei = fetch(exp)
|
561
|
-
|
572
|
+
exp
|
562
573
|
end
|
563
574
|
|
564
575
|
#
|
@@ -568,12 +579,13 @@ module OpenWFE
|
|
568
579
|
def fetch_root (exp_or_wfid)
|
569
580
|
|
570
581
|
return fetch_expression_with_wfid(exp_or_wfid) \
|
571
|
-
if exp_or_wfid.is_a?
|
582
|
+
if exp_or_wfid.is_a?(String)
|
572
583
|
|
573
584
|
exp = fetch_expression(exp_or_wfid)
|
574
585
|
|
575
586
|
return exp unless exp.parent_id
|
576
|
-
|
587
|
+
|
588
|
+
fetch_root(fetch_expression(exp.parent_id))
|
577
589
|
end
|
578
590
|
|
579
591
|
#
|
@@ -591,7 +603,7 @@ module OpenWFE
|
|
591
603
|
ee.store_itself()
|
592
604
|
end
|
593
605
|
|
594
|
-
|
606
|
+
ee
|
595
607
|
end
|
596
608
|
end
|
597
609
|
|
@@ -602,7 +614,7 @@ module OpenWFE
|
|
602
614
|
def remove (exp)
|
603
615
|
|
604
616
|
exp, _fei = fetch(exp) \
|
605
|
-
if exp.kind_of?
|
617
|
+
if exp.kind_of?(FlowExpressionId)
|
606
618
|
|
607
619
|
return if not exp
|
608
620
|
|
@@ -682,8 +694,8 @@ module OpenWFE
|
|
682
694
|
|
683
695
|
get_expression_storage.real_each do |fei, fexp|
|
684
696
|
|
685
|
-
next if fexp.kind_of?
|
686
|
-
next if fexp.kind_of?
|
697
|
+
next if fexp.kind_of?(Environment)
|
698
|
+
next if fexp.kind_of?(RawExpression)
|
687
699
|
next unless fexp.apply_time
|
688
700
|
|
689
701
|
pi = fei.parent_wfid
|
@@ -756,7 +768,7 @@ module OpenWFE
|
|
756
768
|
|
757
769
|
env, fei = fetch(environment_id)
|
758
770
|
|
759
|
-
env.unbind
|
771
|
+
env.unbind
|
760
772
|
|
761
773
|
#get_expression_storage().delete(environment_id)
|
762
774
|
|
@@ -769,11 +781,11 @@ module OpenWFE
|
|
769
781
|
#
|
770
782
|
def build_workitem (launchitem)
|
771
783
|
|
772
|
-
wi = InFlowWorkItem.new
|
784
|
+
wi = InFlowWorkItem.new
|
773
785
|
|
774
|
-
wi.attributes = launchitem.attributes.dup
|
786
|
+
wi.attributes = launchitem.attributes.dup
|
775
787
|
|
776
|
-
|
788
|
+
wi
|
777
789
|
end
|
778
790
|
|
779
791
|
#
|
@@ -815,9 +827,11 @@ module OpenWFE
|
|
815
827
|
# "param of class #{param.class.name}"
|
816
828
|
#end
|
817
829
|
|
818
|
-
return param
|
819
|
-
|
820
|
-
|
830
|
+
return param \
|
831
|
+
if param.is_a?(SimpleExpRepresentation)
|
832
|
+
|
833
|
+
return param.do_make \
|
834
|
+
if param.is_a?(ProcessDefinition) or param.is_a?(Class)
|
821
835
|
|
822
836
|
raise "cannot handle definition of class #{param.class.name}" \
|
823
837
|
unless param.is_a? String
|
@@ -844,8 +858,8 @@ module OpenWFE
|
|
844
858
|
|
845
859
|
o = OpenWFE::eval_safely(param, SAFETY_LEVEL)
|
846
860
|
|
847
|
-
return o.
|
848
|
-
|
861
|
+
return o.do_make \
|
862
|
+
if o.is_a?(ProcessDefinition) or o.is_a?(Class)
|
849
863
|
|
850
864
|
o
|
851
865
|
end
|
@@ -873,7 +887,8 @@ module OpenWFE
|
|
873
887
|
fei.wfid = get_wfid_generator.generate launchitem
|
874
888
|
fei.expression_id = "0"
|
875
889
|
fei.expression_name = exp_name
|
876
|
-
|
890
|
+
|
891
|
+
fei
|
877
892
|
end
|
878
893
|
|
879
894
|
#
|
@@ -898,8 +913,8 @@ module OpenWFE
|
|
898
913
|
#puts procdef.raw_expression_class
|
899
914
|
#puts procdef.raw_expression_class.public_methods
|
900
915
|
|
901
|
-
|
902
|
-
|
916
|
+
procdef.raw_expression_class.new(
|
917
|
+
fei, nil, nil, @application_context, procdef)
|
903
918
|
end
|
904
919
|
|
905
920
|
end
|
@@ -79,22 +79,23 @@ module OpenWFE
|
|
79
79
|
return nil \
|
80
80
|
unless conditional
|
81
81
|
|
82
|
-
|
82
|
+
ldebug { "eval_condition() 0 for '#{conditional}'" }
|
83
83
|
|
84
|
-
conditional = from_xml
|
84
|
+
conditional = from_xml conditional
|
85
85
|
|
86
|
-
|
86
|
+
ldebug { "eval_condition() 1 for '#{conditional}'" }
|
87
|
+
|
88
|
+
begin
|
89
|
+
return to_boolean(do_eval(conditional))
|
90
|
+
rescue Exception => e
|
91
|
+
# probably needs some quoting...
|
92
|
+
end
|
87
93
|
|
88
94
|
conditional = do_quote(conditional)
|
89
95
|
|
90
96
|
ldebug { "eval_condition() 2 for '#{conditional}'" }
|
91
97
|
|
92
|
-
|
93
|
-
result = do_eval(conditional)
|
94
|
-
|
95
|
-
ldebug { "eval_condition() 3 result is '#{result}'" }
|
96
|
-
|
97
|
-
return (result == "true" or result == true)
|
98
|
+
to_boolean(do_eval(conditional))
|
98
99
|
end
|
99
100
|
|
100
101
|
#
|
@@ -121,21 +122,16 @@ module OpenWFE
|
|
121
122
|
|
122
123
|
protected
|
123
124
|
|
125
|
+
private
|
126
|
+
|
124
127
|
#
|
125
|
-
#
|
126
|
-
#
|
128
|
+
# Returns true if result is the "true" String or the true
|
129
|
+
# boolean value. Returns false else.
|
127
130
|
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
# end
|
133
|
-
# return attnames[0]
|
134
|
-
# #
|
135
|
-
# # some kind of a default (for error messages)
|
136
|
-
#end
|
137
|
-
|
138
|
-
private
|
131
|
+
def to_boolean (result)
|
132
|
+
ldebug { "to_boolean() result is '#{result}'" }
|
133
|
+
(result == "true" or result == true)
|
134
|
+
end
|
139
135
|
|
140
136
|
def from_xml (string)
|
141
137
|
|
@@ -145,22 +141,39 @@ module OpenWFE
|
|
145
141
|
s
|
146
142
|
end
|
147
143
|
|
144
|
+
#
|
145
|
+
# Quotes the given string so that it can easily get evaluated
|
146
|
+
# as Ruby code (a string comparison actually).
|
147
|
+
#
|
148
148
|
def do_quote (string)
|
149
149
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
op = find_operator string
|
151
|
+
|
152
|
+
return '"' + string + '"' unless op
|
153
|
+
|
154
|
+
op, i = op
|
154
155
|
|
155
|
-
|
156
|
+
s = '"'
|
157
|
+
s << string[0..i-1].strip
|
158
|
+
s << '" '
|
159
|
+
s << string[i, op.length]
|
160
|
+
s << ' "'
|
161
|
+
s << string[i+op.length..-1].strip
|
162
|
+
s << '"'
|
163
|
+
s
|
164
|
+
end
|
156
165
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
166
|
+
#
|
167
|
+
# Returns the operator and its index (position) in the string.
|
168
|
+
# Returns nil if not operator was found in the string.
|
169
|
+
#
|
170
|
+
def find_operator (string)
|
171
|
+
[ "==", "!=", "<=", ">=", "<", ">" ].each do |op|
|
172
|
+
i = string.index op
|
173
|
+
next unless i
|
174
|
+
return [ op, i ]
|
175
|
+
end
|
176
|
+
nil
|
164
177
|
end
|
165
178
|
|
166
179
|
#
|