openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -37,8 +37,8 @@
37
37
  # John Mettraux at openwfe.org
38
38
  #
39
39
 
40
+ require 'rufus/scheduler'
40
41
  require 'openwfe/utils'
41
- require 'openwfe/util/scheduler'
42
42
  require 'openwfe/expressions/flowexpression'
43
43
 
44
44
 
@@ -49,20 +49,44 @@ module OpenWFE
49
49
  # It's an expression thus it's storable in the expression pool.
50
50
  #
51
51
  class Environment < FlowExpression
52
- include Schedulable
52
+ include Rufus::Schedulable
53
53
 
54
54
  names :environment
55
55
 
56
+ V_PAUSED = VAR_PAUSED[1..-1]
57
+
58
+ #
59
+ # the variables stored in this environment.
60
+ #
56
61
  attr_accessor :variables
57
62
 
58
- def initialize \
59
- (fei, parent, environment_id, application_context, attributes)
63
+ #def initialize (
64
+ # fei, parent, environment_id, application_context, attributes)
65
+ # super(fei, parent, environment_id, application_context, attributes)
66
+ # @variables = {}
67
+ #end
60
68
 
61
- super(fei, parent, environment_id, application_context, attributes)
69
+ def initialize
70
+
71
+ super
62
72
 
63
73
  @variables = {}
64
74
  end
65
75
 
76
+ def self.new_env (
77
+ fei, parent_id, environment_id, app_context, attributes)
78
+
79
+ env = self.new
80
+
81
+ env.fei = fei
82
+ env.parent_id = parent_id
83
+ env.environment_id = environment_id
84
+ env.application_context = app_context
85
+ env.attributes = attributes
86
+
87
+ env
88
+ end
89
+
66
90
  #
67
91
  # Looks up for the value of a variable in this environment.
68
92
  #
@@ -91,7 +115,7 @@ module OpenWFE
91
115
  synchronize do
92
116
 
93
117
  @variables[key] = value
94
- store_itself()
118
+ store_itself
95
119
  end
96
120
  end
97
121
 
@@ -104,7 +128,7 @@ module OpenWFE
104
128
  ldebug { "#{fei.to_debug_s} delete() '#{key}'" }
105
129
 
106
130
  @variables.delete key
107
- store_itself()
131
+ store_itself
108
132
  end
109
133
  end
110
134
 
@@ -122,11 +146,11 @@ module OpenWFE
122
146
 
123
147
  #ldebug { "unbind() '#{key}' => #{value.class}" }
124
148
 
125
- if value.kind_of? FlowExpressionId
149
+ if value.kind_of?(FlowExpressionId)
126
150
 
127
- get_expression_pool().remove(value)
151
+ get_expression_pool.remove value
128
152
 
129
- elsif value.kind_of? FlowExpression
153
+ elsif value.kind_of?(FlowExpression)
130
154
 
131
155
  value.cancel
132
156
  end
@@ -138,7 +162,7 @@ module OpenWFE
138
162
  #
139
163
  def is_engine_environment?
140
164
 
141
- (@fei == get_expression_pool().engine_environment_id)
165
+ (@fei == get_expression_pool.engine_environment_id)
142
166
  end
143
167
 
144
168
  #
@@ -161,12 +185,16 @@ module OpenWFE
161
185
 
162
186
  #ldebug { "reschedule() - item of class #{value.class}" }
163
187
 
164
- next unless value.kind_of? Schedulable
188
+ get_expression_pool.paused_instances[@fei.wfid] = true \
189
+ if key == V_PAUSED
190
+
191
+ next unless value.kind_of?(Rufus::Schedulable)
192
+
165
193
  value.application_context = @application_context
166
194
  value.reschedule(scheduler)
167
195
  end
168
196
 
169
- store_itself()
197
+ store_itself
170
198
  end
171
199
 
172
200
  #
@@ -182,18 +210,20 @@ module OpenWFE
182
210
  get_parent.get_root_environment
183
211
  end
184
212
 
213
+ #--
185
214
  #def get_subprocess_environment
186
215
  # return self if not @parent_id
187
216
  # return self if @parent_id.sub_instance_id != @fei.sub_instance_id
188
217
  # get_parent.get_subprocess_environment
189
218
  #end
219
+ #++
190
220
 
191
221
  #
192
222
  # Returns a deep copy of this environment.
193
223
  #
194
224
  def dup
195
225
 
196
- env = Environment.new(
226
+ env = Environment.new_env(
197
227
  @fei.dup,
198
228
  @parent_id,
199
229
  @environment_id,
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -37,10 +37,11 @@
37
37
  # John Mettraux at openwfe.org
38
38
  #
39
39
 
40
+ require 'openwfe/expressions/raw'
40
41
  require 'openwfe/expressions/environment'
41
42
  require 'openwfe/expressions/fe_define'
42
43
  require 'openwfe/expressions/fe_misc'
43
- require 'openwfe/expressions/fe_value'
44
+ require 'openwfe/expressions/fe_set'
44
45
  require 'openwfe/expressions/fe_if'
45
46
  require 'openwfe/expressions/fe_equals'
46
47
  require 'openwfe/expressions/fe_sequence'
@@ -142,9 +143,18 @@ module OpenWFE
142
143
 
143
144
  register TimeoutExpression
144
145
 
146
+ register EvalExpression
147
+ register ExpExpression
148
+
145
149
  register Environment
146
150
  #
147
151
  # only used by get_expression_names()
152
+
153
+ register_ancestors RawExpression
154
+ #register_ancestors XmlRawExpression
155
+ #register_ancestors ProgRawExpression
156
+ #
157
+ # just register the ancestors for those two
148
158
  end
149
159
 
150
160
  #
@@ -185,7 +195,7 @@ module OpenWFE
185
195
  def get_expression_names (expression_class)
186
196
 
187
197
  return expression_class.expression_names \
188
- if expression_class.method_defined? :expression_names
198
+ if expression_class.method_defined?(:expression_names)
189
199
 
190
200
  names = []
191
201
  @expressions.each do |k, v|
@@ -194,6 +204,23 @@ module OpenWFE
194
204
  names
195
205
  end
196
206
 
207
+ #
208
+ # Returns an array of expression classes that have the given
209
+ # class/module among their ancestors.
210
+ #
211
+ def get_expression_classes (ancestor)
212
+
213
+ @ancestors[ancestor]
214
+ end
215
+
216
+ def to_s
217
+ s = ""
218
+ @expressions.keys.sort.each do |name|
219
+ s << "- '#{name}' -> '#{@expressions[name].to_s}'\n"
220
+ end
221
+ s
222
+ end
223
+
197
224
  #
198
225
  # Registers an Expression class within this expression map.
199
226
  # This method is usually never called from out of the ExpressionMap
@@ -206,27 +233,20 @@ module OpenWFE
206
233
  name = OpenWFE::to_dash(name)
207
234
  @expressions[name] = expression_class
208
235
  end
209
- expression_class.ancestors.each do |ancestor|
210
- (@ancestors[ancestor] ||= []) << expression_class
211
- end
236
+ register_ancestors expression_class
212
237
  end
213
238
 
214
- #
215
- # Returns an array of expression classes that have the given
216
- # class/module among their ancestors.
217
- #
218
- def get_expression_classes (ancestor)
239
+ protected
219
240
 
220
- @ancestors[ancestor]
221
- end
241
+ #
242
+ # registers all the ancestors of an expression class
243
+ #
244
+ def register_ancestors (expression_class)
222
245
 
223
- def to_s
224
- s = ""
225
- @expressions.keys.sort.each do |name|
226
- s << "- '#{name}' -> '#{@expressions[name].to_s}'\n"
246
+ expression_class.ancestors.each do |ancestor|
247
+ (@ancestors[ancestor] ||= []) << expression_class
248
+ end
227
249
  end
228
- s
229
- end
230
250
  end
231
251
 
232
252
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -209,7 +209,21 @@ module OpenWFE
209
209
  # It understands the same attributes and behaves as an interator that
210
210
  # forks its children concurrently.
211
211
  #
212
- # (See ConcurrenceExpression and IteratorExpression).
212
+ # Some examples :
213
+ #
214
+ # <concurrent-iterator on-value="sales, logistics, lob2" to-field="p">
215
+ # <participant field-ref="p" />
216
+ # </concurrent-iterator>
217
+ #
218
+ # Within a Ruby process definition :
219
+ #
220
+ # sequence do
221
+ # set :field => f, :value => %w{ Alan, Bob, Clarence }
222
+ # #...
223
+ # concurrent_iterator :on_field => "f", :to_field => "p" do
224
+ # participant "${p}"
225
+ # end
226
+ # end
213
227
  #
214
228
  class ConcurrentIteratorExpression < ConcurrenceExpression
215
229
 
@@ -219,10 +233,8 @@ module OpenWFE
219
233
 
220
234
  def apply (workitem)
221
235
 
222
- if @children.length < 1
223
- reply_to_parent workitem
224
- return
225
- end
236
+ return reply_to_parent(workitem) \
237
+ if @children.length < 1
226
238
 
227
239
  @template = @children[0]
228
240
 
@@ -232,10 +244,8 @@ module OpenWFE
232
244
 
233
245
  iterator = Iterator.new(self, workitem)
234
246
 
235
- unless iterator.has_next?
236
- reply_to_parent workitem
237
- return
238
- end
247
+ return reply_to_parent(workitem) \
248
+ unless iterator.has_next?
239
249
 
240
250
  while iterator.has_next?
241
251
 
@@ -246,7 +256,7 @@ module OpenWFE
246
256
  vars = iterator.next wi
247
257
 
248
258
  rawexp = get_expression_pool.prepare_from_template(
249
- self, iterator.index, template, vars)
259
+ self, nil, iterator.index, template, vars)
250
260
 
251
261
  @children << rawexp.fei
252
262
  end
@@ -257,6 +267,7 @@ module OpenWFE
257
267
  def reply_to_parent (workitem)
258
268
 
259
269
  get_expression_pool.remove(@template)
270
+
260
271
  super
261
272
  end
262
273
 
@@ -321,7 +332,7 @@ module OpenWFE
321
332
  merge_type = synchable.lookup_sym_attribute(
322
333
  :merge_type, workitem, :default => :mix)
323
334
 
324
- #synchable.ldebug { "new() merge_type is '#{merge_type}'" }
335
+ synchable.ldebug { "new() merge_type is '#{merge_type}'" }
325
336
 
326
337
  @merge_array = MergeArray.new synchable.fei, merge, merge_type
327
338
 
@@ -439,7 +450,7 @@ module OpenWFE
439
450
 
440
451
  workitem = @merge_array.do_merge
441
452
 
442
- synchable.reply_to_parent(workitem)
453
+ synchable.reply_to_parent workitem
443
454
  end
444
455
 
445
456
  def treat_remaining_children (synchable)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -38,8 +38,6 @@
38
38
  #
39
39
 
40
40
  require 'openwfe/utils'
41
- require 'openwfe/util/otime'
42
- require 'openwfe/util/scheduler'
43
41
  require 'openwfe/expressions/time'
44
42
 
45
43
 
@@ -62,8 +60,7 @@ module OpenWFE
62
60
  # engine is a persisted one, the cron will continue when the engine
63
61
  # restarts).
64
62
  #
65
- # Since OpenWFEru 0.9.14, it's possible to specify 'every' instead of
66
- # 'tab' :
63
+ # It's possible to specify 'every' instead of 'tab' :
67
64
  #
68
65
  # cron :every => "10m3s" do
69
66
  # send_reminder
@@ -79,14 +76,13 @@ module OpenWFE
79
76
  attr_accessor \
80
77
  :raw_child, :tab, :every, :name, :counter
81
78
 
79
+
82
80
  def apply (workitem)
83
81
 
84
- @counter = 0
82
+ return reply_to_parent(workitem) \
83
+ if @children.size < 1
85
84
 
86
- if @children.size < 1
87
- reply_to_parent workitem
88
- return
89
- end
85
+ @counter = 0
90
86
 
91
87
  @applied_workitem = workitem.dup
92
88
  @applied_workitem.flow_expression_id = nil
@@ -100,7 +96,7 @@ module OpenWFE
100
96
  @raw_child, _fei = get_expression_pool.fetch(@children[0])
101
97
  @raw_child.parent_id = nil
102
98
 
103
- clean_children()
99
+ clean_children
104
100
 
105
101
  @children = nil
106
102
 
@@ -109,7 +105,7 @@ module OpenWFE
109
105
  #
110
106
  # schedule self
111
107
 
112
- reschedule(get_scheduler)
108
+ reschedule get_scheduler
113
109
 
114
110
  #
115
111
  # store self as a variable
@@ -142,14 +138,18 @@ module OpenWFE
142
138
  begin
143
139
 
144
140
  get_expression_pool.launch_template(
145
- @fei.wfid, @counter, @raw_child, @applied_workitem.dup)
141
+ @fei.wfid, nil, @counter, @raw_child, @applied_workitem.dup)
146
142
 
147
143
  #
148
144
  # update count and store self
149
145
 
150
146
  @counter += 1
151
147
 
152
- #set_variable(@name, self)
148
+ if @name[0, 2] == '//'
149
+ set_variable @name, self
150
+ else
151
+ store_itself
152
+ end
153
153
 
154
154
  rescue
155
155
  lerror do
@@ -168,10 +168,11 @@ module OpenWFE
168
168
 
169
169
  #return unless @applied_workitem
170
170
 
171
- @scheduler_job_id = @name.dup
172
-
173
- @scheduler_job_id = "#{@fei.wfid}__#{@scheduler_job_id}" \
174
- unless OpenWFE::starts_with(@name, "//")
171
+ @scheduler_job_id = if @name[0, 2] == "//"
172
+ @name
173
+ else
174
+ "#{@fei.wfid}__#{@scheduler_job_id}"
175
+ end
175
176
 
176
177
  if @tab
177
178
  get_scheduler.schedule(
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -78,39 +78,43 @@ module OpenWFE
78
78
 
79
79
  names :cursor
80
80
 
81
- attr_accessor \
82
- :loop_id,
83
- :current_child_id,
84
- :current_child_fei
81
+ #
82
+ # the integer identifier for the current loop
83
+ #
84
+ attr_accessor :loop_id
85
+
86
+ #
87
+ # what is the index of the child we're currently executing
88
+ #
89
+ attr_accessor :current_child_id
90
+
85
91
 
86
92
  def apply (workitem)
87
93
 
94
+ new_environment
95
+
88
96
  @loop_id = 0
89
97
 
90
98
  @current_child_id = -1
91
99
 
92
- clean_children_list()
100
+ clean_children_list
93
101
 
94
- reply(workitem)
102
+ reply workitem
95
103
  end
96
104
 
97
105
  def reply (workitem)
98
106
 
99
- if @children.length < 1
100
- #
101
- # well, currently, no infinite empty loop allowed
102
- #
103
- reply_to_parent(workitem)
104
- return
105
- end
107
+ return reply_to_parent(workitem) \
108
+ if @children.length < 1
109
+ #
110
+ # well, currently, no infinite empty loop allowed
106
111
 
107
112
  command, step = determine_command_and_step workitem
108
113
 
109
114
  ldebug { "reply() command is '#{command} #{step}'" }
110
115
 
111
116
  if command == C_BREAK or command == C_CANCEL
112
- reply_to_parent workitem
113
- return
117
+ return reply_to_parent(workitem)
114
118
  end
115
119
 
116
120
  if command == C_REWIND or command == C_CONTINUE
@@ -132,26 +136,29 @@ module OpenWFE
132
136
  @current_child_id = 0 if @current_child_id < 0
133
137
 
134
138
  if @current_child_id >= @children.length
135
- if not is_loop
136
- reply_to_parent(workitem)
137
- return
138
- end
139
+
140
+ return reply_to_parent(workitem) unless is_loop
141
+
139
142
  @loop_id += 1
140
143
  @current_child_id = 0
141
144
  end
142
145
  end
143
146
 
144
- @current_child_fei = nil
145
-
146
- store_itself()
147
-
148
- @current_child_fei = @children[@current_child_id]
147
+ template_fei = @children[@current_child_id]
149
148
 
150
149
  #
151
150
  # launch the next child as a template
152
151
 
152
+ #@current_child_fei = get_expression_pool.launch_template(
153
153
  get_expression_pool.launch_template(
154
- self, @loop_id, @current_child_fei, workitem, nil)
154
+ self,
155
+ @environment_id,
156
+ @loop_id,
157
+ template_fei,
158
+ workitem,
159
+ nil)
160
+
161
+ store_itself
155
162
  end
156
163
 
157
164
  #
@@ -159,8 +166,8 @@ module OpenWFE
159
166
  #
160
167
  def cancel
161
168
 
162
- get_expression_pool.cancel(@current_child_fei) \
163
- if @current_child_fei
169
+ cfei = current_child_fei
170
+ get_expression_pool.cancel(cfei) if cfei
164
171
 
165
172
  super
166
173
  end
@@ -169,11 +176,26 @@ module OpenWFE
169
176
  # Returns false, the child class LoopExpression does return true.
170
177
  #
171
178
  def is_loop
179
+
172
180
  false
173
181
  end
174
182
 
175
183
  protected
176
184
 
185
+ #
186
+ # Determines the fei of the child being currently executed.
187
+ # This method is used by cancel().
188
+ #
189
+ def current_child_fei
190
+
191
+ cfei = @children[@current_child_id].dup
192
+
193
+ return nil unless cfei
194
+
195
+ cfei.wfid = cfei.wfid + '.' + @loop_id.to_s
196
+ cfei
197
+ end
198
+
177
199
  #
178
200
  # Makes sure that only flow expression are left in the cursor
179
201
  # children list (text and comment nodes get discarded).
@@ -193,11 +215,30 @@ module OpenWFE
193
215
  # The 'loop' expression is like 'cursor' but it doesn't exit until
194
216
  # it's broken (with 'break' or 'cancel').
195
217
  #
218
+ # <loop>
219
+ # <participant ref="toto" />
220
+ # <break if="${f:done} == true" />
221
+ # </loop>
222
+ #
223
+ # or, in a Ruby process definition :
224
+ #
225
+ # _loop do
226
+ # participant "toto"
227
+ # _break :if => "${f:done} == true"
228
+ # end
229
+ #
230
+ # (notice the _ (underscores) to distinguish the OpenWFEru expressions
231
+ # from the native Ruby ones).
232
+ #
196
233
  class LoopExpression < CursorExpression
197
234
 
198
235
  names :loop
199
236
 
237
+ #
238
+ # Returns true as, well, it's a loop...
239
+ #
200
240
  def is_loop
241
+
201
242
  true
202
243
  end
203
244
  end