openwferu 0.9.15 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/README.txt +4 -2
  2. data/lib/openwfe/engine/engine.rb +143 -25
  3. data/lib/openwfe/engine/file_persisted_engine.rb +3 -3
  4. data/lib/openwfe/expool/errorjournal.rb +48 -25
  5. data/lib/openwfe/expool/expressionpool.rb +77 -106
  6. data/lib/openwfe/expool/expstorage.rb +6 -5
  7. data/lib/openwfe/expool/threadedexpstorage.rb +190 -0
  8. data/lib/openwfe/expool/yamlexpstorage.rb +5 -150
  9. data/lib/openwfe/expressions/condition.rb +6 -6
  10. data/lib/openwfe/expressions/environment.rb +7 -2
  11. data/lib/openwfe/expressions/expressionmap.rb +14 -0
  12. data/lib/openwfe/expressions/fe_command.rb +2 -1
  13. data/lib/openwfe/expressions/fe_concurrence.rb +40 -18
  14. data/lib/openwfe/expressions/fe_cron.rb +14 -11
  15. data/lib/openwfe/expressions/fe_cursor.rb +2 -3
  16. data/lib/openwfe/expressions/fe_define.rb +34 -31
  17. data/lib/openwfe/expressions/fe_equals.rb +11 -21
  18. data/lib/openwfe/expressions/fe_filter_definition.rb +0 -2
  19. data/lib/openwfe/expressions/fe_fqv.rb +1 -3
  20. data/lib/openwfe/expressions/fe_if.rb +37 -12
  21. data/lib/openwfe/expressions/fe_iterator.rb +1 -1
  22. data/lib/openwfe/expressions/fe_listen.rb +147 -28
  23. data/lib/openwfe/expressions/fe_losfor.rb +13 -1
  24. data/lib/openwfe/expressions/fe_misc.rb +70 -11
  25. data/lib/openwfe/expressions/fe_participant.rb +3 -3
  26. data/lib/openwfe/expressions/fe_reserve.rb +1 -1
  27. data/lib/openwfe/expressions/fe_save.rb +11 -12
  28. data/lib/openwfe/expressions/fe_sequence.rb +22 -29
  29. data/lib/openwfe/expressions/fe_sleep.rb +11 -7
  30. data/lib/openwfe/expressions/fe_subprocess.rb +24 -10
  31. data/lib/openwfe/expressions/fe_value.rb +35 -15
  32. data/lib/openwfe/expressions/fe_when.rb +2 -4
  33. data/lib/openwfe/expressions/flowexpression.rb +73 -37
  34. data/lib/openwfe/expressions/merge.rb +2 -4
  35. data/lib/openwfe/expressions/raw.rb +40 -31
  36. data/lib/openwfe/expressions/raw_prog.rb +18 -9
  37. data/lib/openwfe/expressions/raw_xml.rb +1 -8
  38. data/lib/openwfe/expressions/simplerep.rb +27 -5
  39. data/lib/openwfe/expressions/time.rb +45 -15
  40. data/lib/openwfe/expressions/timeout.rb +2 -1
  41. data/lib/openwfe/expressions/wtemplate.rb +2 -2
  42. data/lib/openwfe/flowexpressionid.rb +62 -16
  43. data/lib/openwfe/listeners/listener.rb +28 -37
  44. data/lib/openwfe/listeners/listeners.rb +1 -1
  45. data/lib/openwfe/listeners/socketlisteners.rb +7 -15
  46. data/lib/openwfe/logging.rb +5 -4
  47. data/lib/openwfe/{rest → orest}/controlclient.rb +3 -5
  48. data/lib/openwfe/{rest → orest}/definitions.rb +0 -2
  49. data/lib/openwfe/{rest → orest}/exception.rb +0 -0
  50. data/lib/openwfe/{rest → orest}/oldrestservlet.rb +1 -1
  51. data/lib/openwfe/{rest → orest}/osocket.rb +1 -1
  52. data/lib/openwfe/{rest → orest}/restclient.rb +0 -2
  53. data/lib/openwfe/orest/workitem.rb +206 -0
  54. data/lib/openwfe/{rest → orest}/worklistclient.rb +15 -5
  55. data/lib/openwfe/{rest → orest}/xmlcodec.rb +4 -1
  56. data/lib/openwfe/participants/enoparticipants.rb +4 -14
  57. data/lib/openwfe/participants/participantmap.rb +16 -12
  58. data/lib/openwfe/participants/participants.rb +46 -1
  59. data/lib/openwfe/participants/socketparticipants.rb +1 -6
  60. data/lib/openwfe/service.rb +15 -6
  61. data/lib/openwfe/storage/yamlcustom.rb +3 -0
  62. data/lib/openwfe/storage/yamlfilestorage.rb +3 -1
  63. data/lib/openwfe/util/dollar.rb +21 -14
  64. data/lib/openwfe/util/lru.rb +29 -10
  65. data/lib/openwfe/util/observable.rb +4 -1
  66. data/lib/openwfe/util/otime.rb +3 -0
  67. data/lib/openwfe/util/scheduler.rb +346 -114
  68. data/lib/openwfe/utils.rb +67 -13
  69. data/lib/openwfe/version.rb +1 -1
  70. data/lib/openwfe/workitem.rb +22 -165
  71. data/lib/openwfe/worklist/oldrest.rb +2 -2
  72. data/test/bm/bm_1_xml_vs_prog.rb +56 -0
  73. data/test/{ft_26_load.rb → bm/ft_26_load.rb} +0 -0
  74. data/test/{ft_26b_load.rb → bm/ft_26b_load.rb} +0 -0
  75. data/test/{ft_26c_load.rb → bm/ft_26c_load.rb} +16 -4
  76. data/test/clone_test.rb +62 -0
  77. data/test/cron_test.rb +56 -1
  78. data/test/cronline_test.rb +17 -8
  79. data/test/description_test.rb +57 -0
  80. data/test/dollar_test.rb +17 -6
  81. data/test/eno_test.rb +22 -9
  82. data/test/fe_lookup_att_test.rb +50 -0
  83. data/test/fei_test.rb +18 -9
  84. data/test/flowtestbase.rb +24 -2
  85. data/test/ft_0.rb +10 -12
  86. data/test/ft_0e_multibody.rb +34 -0
  87. data/test/ft_10_loop.rb +4 -6
  88. data/test/ft_11_ppd.rb +5 -20
  89. data/test/ft_14b_subprocess.rb +2 -2
  90. data/test/ft_15_iterator.rb +56 -4
  91. data/test/ft_15b_iterator.rb +48 -0
  92. data/test/ft_16_fqv.rb +18 -3
  93. data/test/ft_23c_wait.rb +7 -5
  94. data/test/ft_25_cancel.rb +5 -3
  95. data/test/ft_27_getflowpos.rb +14 -11
  96. data/test/ft_28_fileparticipant.rb +3 -4
  97. data/test/ft_2_concurrence.rb +8 -12
  98. data/test/ft_2b_concurrence.rb +3 -2
  99. data/test/ft_30_socketlistener.rb +5 -6
  100. data/test/ft_32c_journal.rb +2 -2
  101. data/test/ft_32d_journal.rb +5 -6
  102. data/test/ft_33_description.rb +8 -3
  103. data/test/ft_34_cancelwfid.rb +3 -3
  104. data/test/ft_38_tag.rb +7 -10
  105. data/test/ft_39_reserve.rb +4 -2
  106. data/test/ft_3_equals.rb +18 -13
  107. data/test/ft_44b_restore.rb +2 -6
  108. data/test/ft_49_condition.rb +16 -12
  109. data/test/ft_4_misc.rb +51 -12
  110. data/test/ft_50_xml_attribute.rb +1 -1
  111. data/test/ft_54_listen.rb +96 -10
  112. data/test/ft_54b_listen.rb +68 -0
  113. data/test/ft_55_ptimeout.rb +1 -2
  114. data/test/ft_58_ejournal.rb +8 -33
  115. data/test/ft_59_ps.rb +2 -3
  116. data/test/ft_59b_ps_for_pat.rb +59 -0
  117. data/test/ft_5_time.rb +45 -4
  118. data/test/ft_60_ecancel.rb +7 -7
  119. data/test/ft_61_elsub.rb +1 -1
  120. data/test/ft_64_alias.rb +1 -1
  121. data/test/ft_67_schedlaunch.rb +29 -16
  122. data/test/ft_69_cancelmissing.rb +1 -1
  123. data/test/ft_6_lambda.rb +8 -6
  124. data/test/ft_70_lookupvar.rb +2 -2
  125. data/test/ft_71_log.rb +60 -0
  126. data/test/ft_72_lookup_processes.rb +79 -0
  127. data/test/ft_73_cancel_sub.rb +144 -0
  128. data/test/ft_74_block_and_workitem_dup.rb +63 -0
  129. data/test/ft_75_ruby_attributes.rb +87 -0
  130. data/test/ft_76_merge_isolate.rb +90 -0
  131. data/test/ft_7_lose.rb +2 -1
  132. data/test/ft_tests.rb +9 -0
  133. data/test/lookup_att_test.rb +90 -0
  134. data/test/misc_test.rb +33 -50
  135. data/test/orest_test.rb +1 -1
  136. data/test/participant_test.rb +32 -8
  137. data/test/pending.rb +6 -7
  138. data/test/rake_ltest.rb +3 -0
  139. data/test/rake_qtest.rb +4 -1
  140. data/test/raw_prog_test.rb +1 -1
  141. data/test/restart_cron_test.rb +6 -6
  142. data/test/restart_sleep_test.rb +8 -8
  143. data/test/ruby_procdef_test.rb +2 -2
  144. data/test/rutest_utils.rb +9 -3
  145. data/test/scheduler_1_test.rb +88 -0
  146. data/test/scheduler_test.rb +49 -4
  147. data/test/sec_test.rb +18 -11
  148. metadata +51 -34
  149. data/test/cron_test_2.rb +0 -50
@@ -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"
@@ -85,7 +83,7 @@ module OpenWFE
85
83
  def lookup_values (workitem)
86
84
 
87
85
  value_a = lookup_value workitem
88
- value_b = lookup_value workitem, 'other'
86
+ value_b = lookup_value workitem, :prefix => 'other'
89
87
 
90
88
  value_c = lookup_variable_or_field workitem
91
89
 
@@ -104,26 +102,18 @@ module OpenWFE
104
102
  #
105
103
  def lookup_variable_or_field (workitem)
106
104
 
107
- v = lookup_attribute :variable, workitem
105
+ v = lookup_string_attribute :variable, workitem
108
106
  return lookup_variable(v) if v
109
107
 
110
- f = lookup_attribute :field, workitem
108
+ f = lookup_string_attribute :field, workitem
111
109
  return workitem.attributes[f] if f
112
110
 
113
111
  nil
114
112
  end
115
-
116
- #
117
- # This method has to be implemented by extending classes
118
- #
119
- def compare (a, b)
120
-
121
- raise "not yet implemented : '#{@fei.expressionName}'"
122
- end
123
113
  end
124
114
 
125
115
  #
126
- # <equals/>
116
+ # <equals value="x" other-value="y"/>
127
117
  #
128
118
  class EqualsExpression < ComparisonExpression
129
119
 
@@ -147,13 +137,13 @@ module OpenWFE
147
137
 
148
138
  def apply (workitem)
149
139
 
150
- fname = lookup_attribute(:field_value, workitem)
151
- fname = lookup_attribute(:field, workitem) unless fname
140
+ fname = lookup_string_attribute(:field_value, workitem)
141
+ fname = lookup_string_attribute(:field, workitem) unless fname
152
142
 
153
- fmatch = lookup_attribute(:field_match, workitem)
143
+ fmatch = lookup_string_attribute(:field_match, workitem)
154
144
 
155
- vname = lookup_attribute(:variable_value, workitem)
156
- vname = lookup_attribute(:variable, workitem) unless vname
145
+ vname = lookup_string_attribute(:variable_value, workitem)
146
+ vname = lookup_string_attribute(:variable, workitem) unless vname
157
147
 
158
148
  result = if fname
159
149
  workitem.has_attribute? fname
@@ -165,8 +155,8 @@ module OpenWFE
165
155
  false
166
156
  end
167
157
 
168
- result = ( ! result) if result != nil \
169
- if fei.expression_name == 'undefined'
158
+ result = ( ! result) \
159
+ if result != nil and fei.expression_name == 'undefined'
170
160
 
171
161
  workitem.set_result result
172
162
 
@@ -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"
@@ -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,7 +37,7 @@
39
37
  # John Mettraux at openwfe.org
40
38
  #
41
39
 
42
- require 'openwfe/rest/xmlcodec'
40
+ require 'openwfe/orest/xmlcodec'
43
41
  require 'openwfe/expressions/flowexpression'
44
42
 
45
43
 
@@ -99,17 +99,26 @@ module OpenWFE
99
99
 
100
100
  names :if
101
101
 
102
- attr_accessor \
103
- :condition_replied
102
+ #
103
+ # This boolean is set to true when the conditional claused has
104
+ # been evaluated and the 'if' is waiting for the consequence's
105
+ # reply.
106
+ #
107
+ attr_accessor :condition_replied
108
+
104
109
 
105
110
  def apply (workitem)
106
111
 
107
- workitem.unset_result
112
+ #workitem.unset_result
113
+ #
114
+ # since OpenWFEru 0.9.16 previous __result__ values
115
+ # are not erased before an 'if'.
108
116
 
109
117
  test = eval_condition(:test, workitem, :not)
110
118
 
111
119
  if @children.length < 1
112
- workitem.set_result test if test
120
+ #workitem.set_result test if test
121
+ workitem.set_result((test != nil and test != false))
113
122
  reply_to_parent(workitem)
114
123
  return
115
124
  end
@@ -129,10 +138,8 @@ module OpenWFE
129
138
 
130
139
  def reply (workitem)
131
140
 
132
- if @condition_replied
133
- reply_to_parent(workitem)
134
- return
135
- end
141
+ return reply_to_parent(workitem) \
142
+ if @condition_replied
136
143
 
137
144
  result = workitem.attributes[FIELD_RESULT]
138
145
 
@@ -143,7 +150,14 @@ module OpenWFE
143
150
  apply_consequence result, workitem
144
151
  end
145
152
 
153
+ #
154
+ # This reply_to_parent takes care of cleaning all the children
155
+ # before replying to the parent expression, this is important
156
+ # because only the 'then' or the 'else' child got evaluated, the
157
+ # remaining one has to be cleaned out here.
158
+ #
146
159
  def reply_to_parent(workitem)
160
+
147
161
  clean_children()
148
162
  super workitem
149
163
  end
@@ -202,13 +216,24 @@ module OpenWFE
202
216
 
203
217
  names :case, :switch
204
218
 
205
- attr_accessor \
206
- :offset,
207
- :evaluating_condition
219
+ #
220
+ # keeping track of where we are in the case iteration
221
+ #
222
+ attr_accessor :offset
223
+
224
+ #
225
+ # set to 'true' when the case expression is actually evaluating
226
+ # a condition (ie not triggering a consequence).
227
+ #
228
+ attr_accessor :evaluating_condition
229
+
208
230
 
209
231
  def apply (workitem)
210
232
 
211
- workitem.unset_result
233
+ #workitem.unset_result
234
+ #
235
+ # since OpenWFEru 0.9.16 previous __result__ values
236
+ # are not erased before a 'case'.
212
237
 
213
238
  @offset = nil
214
239
 
@@ -174,7 +174,7 @@ module OpenWFE
174
174
  @iteration_index = 0
175
175
 
176
176
  raw_list = iterator_expression.lookup_vf_attribute(
177
- workitem, :value, :on)
177
+ workitem, :value, :prefix => :on)
178
178
 
179
179
  @iteration_list = extract_iteration_list(raw_list)
180
180
 
@@ -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,6 +37,7 @@
39
37
  # John Mettraux at openwfe.org
40
38
  #
41
39
 
40
+ require 'openwfe/expressions/merge'
42
41
  require 'openwfe/expressions/timeout'
43
42
  require 'openwfe/expressions/condition'
44
43
  require 'openwfe/expressions/flowexpression'
@@ -101,53 +100,140 @@ module OpenWFE
101
100
  # be instructed to stop listening after a certain amount of time (here,
102
101
  # after one month and two weeks).
103
102
  #
103
+ # Since OpenWFEru 0.9.16, the listen expression is usable without a
104
+ # child expression. It blocks until a valid messages comes in the
105
+ # channel, at which point it resumes the process, with workitem that came
106
+ # as the message (not with the workitem at apply time).
107
+ # (no merge implemented for now).
108
+ #
109
+ # sequence do
110
+ # listen :to => "channel_z", :upon => :reply
111
+ # participant :the_rest_of_the_process
112
+ # end
113
+ #
114
+ # In this example, the process will block until a workitem comes for
115
+ # a participant named 'channel_z'.
116
+ #
117
+ # Note that since OpenWFEru 0.9.16, the engine accept (in its reply()
118
+ # method) workitems that don't belong to a process intance (ie workitems
119
+ # that have a nil flow_expression_id). So it's entirely feasible to
120
+ # send 'notifications only' workitems to the OpenWFEru engine.
121
+ # (see http://openwferu.rubyforge.org/svn/trunk/openwfe-ruby/test/ft_54b_listen.rb)
122
+ #
123
+ # Since OpenWFEru 0.9.16, this expression has been aliased 'intercept'
124
+ # and 'receive'. It also accepts the 'on' parameter as an alias parameter
125
+ # to the 'to' parameter. Think "listen to" and "receive on".
126
+ #
127
+ # A 'merge' attribute was added as well in 0.9.16, if set to true (the
128
+ # default value being false), the incoming workitem will be merged
129
+ # with a copy of the workitem that 'applied' (activated) the listen
130
+ # expression.
131
+ #
104
132
  class ListenExpression < FlowExpression
105
- include TimeoutMixin, ConditionMixin
133
+ include TimeoutMixin
134
+ include ConditionMixin
135
+ include MergeMixin
136
+
137
+ names :listen, :intercept, :receive
138
+
139
+ #
140
+ # the channel on which this expression 'listens'
141
+ #
142
+ attr_accessor :participant_regex
143
+
144
+ #
145
+ # is set to true if the expression listen to 1! workitem and
146
+ # then replies to its parent.
147
+ # When set to true, it listens until the process it belongs to
148
+ # terminates.
149
+ # The default value is true.
150
+ #
151
+ attr_accessor :once
106
152
 
107
- names :listen
153
+ #
154
+ # can take :apply or :reply as a value, if not set (nil), will listen
155
+ # on both 'directions'.
156
+ #
157
+ attr_accessor :upon
158
+
159
+ #
160
+ # 'listen' accepts a :merge attribute, when set to true, this
161
+ # field will contain a copy of the workitem that activated the
162
+ # listen activity. This copy will be merged with incoming (listened
163
+ # for) workitems when triggering the listen child.
164
+ #
165
+ attr_accessor :applied_workitem
166
+
167
+ #
168
+ # how many messages were received (can more than 0 or 1 if 'once'
169
+ # is set to false).
170
+ #
171
+ attr_accessor :call_count
108
172
 
109
- attr_accessor \
110
- :participant_regex,
111
- :once,
112
- :upon,
113
- :call_count
114
173
 
115
174
  def apply (workitem)
116
175
 
117
- if @children.size < 1
118
- reply_to_parent workitem
119
- return
120
- end
176
+ #if @children.size < 1
177
+ # reply_to_parent workitem
178
+ # return
179
+ #end
180
+ #
181
+ # 'listen' now blocks if there is no children
182
+
183
+ @participant_regex = lookup_string_attribute(:to, workitem)
121
184
 
122
- @participant_regex = lookup_attribute :to, workitem
185
+ @participant_regex = lookup_string_attribute(:on, workitem) \
186
+ unless @participant_regex
123
187
 
124
188
  raise "attribute 'to' is missing for expression 'listen'" \
125
189
  unless @participant_regex
126
190
 
191
+ ldebug { "apply() listening to '#{@participant_regex}'" }
192
+
193
+ #
194
+ # once
195
+
127
196
  @once = lookup_boolean_attribute :once, workitem, true
128
197
 
198
+ @once = true if @children.size < 1
199
+ # a 'blocking listen' can only get triggered once.
200
+
129
201
  ldebug { "apply() @once is #{@once}" }
130
202
 
131
- @upon = lookup_attribute(:upon, workitem, "apply")[0, 5].downcase
132
- @upon = if @upon == "reply"
133
- :reply
134
- else
135
- :apply
136
- end
203
+ #
204
+ # merge
205
+
206
+ merge = lookup_boolean_attribute :merge, workitem, false
207
+
208
+ ldebug { "apply() merge is #{@merge}" }
209
+
210
+ @applied_workitem = workitem.dup if merge
211
+
212
+ #
213
+ # upon
214
+
215
+ @upon = lookup_sym_attribute(
216
+ :upon, workitem, :default => :apply)
217
+
218
+ @upon = (@upon == :reply) ? :reply : :apply
219
+
220
+ ldebug { "apply() @upon is #{@upon}" }
137
221
 
138
222
  @call_count = 0
139
223
 
140
- determine_timeout()
224
+ determine_timeout
141
225
  reschedule(get_scheduler)
142
226
 
143
227
  store_itself
144
228
  end
145
229
 
146
230
  def cancel
231
+
147
232
  stop_observing
148
233
  end
149
234
 
150
235
  def reply_to_parent (workitem)
236
+
151
237
  stop_observing
152
238
  super
153
239
  end
@@ -156,6 +242,7 @@ module OpenWFE
156
242
  # Only called in case of timeout.
157
243
  #
158
244
  def trigger (params)
245
+
159
246
  reply_to_parent workitem
160
247
  end
161
248
 
@@ -167,6 +254,8 @@ module OpenWFE
167
254
 
168
255
  upon = args[0]
169
256
 
257
+ ldebug { "call() channel : '#{channel}' upon '#{upon}'" }
258
+
170
259
  return if upon != @upon
171
260
 
172
261
  workitem = args[1].dup
@@ -181,21 +270,43 @@ module OpenWFE
181
270
 
182
271
  return if @once and @call_count > 0
183
272
 
184
- ldebug { "call() through for #{workitem.fei.to_s}" }
273
+ #
274
+ # workitem does match...
275
+
276
+ ldebug do
277
+ "call() "+
278
+ "through for fei #{workitem.fei} / "+
279
+ "'#{workitem.participant_name}'"
280
+ end
185
281
 
186
282
  @call_count += 1
187
283
  store_itself()
188
284
 
189
285
  #ldebug { "call() @call_count is #{@call_count}" }
190
286
 
191
- parent = if @once
192
- self
287
+ #
288
+ # eventual merge
289
+
290
+ workitem = merge_workitems @applied_workitem.dup, workitem \
291
+ if @applied_workitem
292
+
293
+ #
294
+ # reply or launch nested child expression
295
+
296
+ if @children.size > 0
297
+ #
298
+ # listen with child
299
+
300
+ parent = @once ? self : nil
301
+
302
+ get_expression_pool.launch_template(
303
+ parent, @call_count - 1, @children[0], workitem, nil)
193
304
  else
194
- nil
305
+ #
306
+ # 'blocking listen'
307
+
308
+ reply_to_parent workitem
195
309
  end
196
-
197
- get_expression_pool.launch_template(
198
- parent, @call_count - 1, @children[0], workitem, nil)
199
310
  end
200
311
  end
201
312
 
@@ -211,11 +322,19 @@ module OpenWFE
211
322
 
212
323
  protected
213
324
 
325
+ #
326
+ # Start observing a [participant name] channel.
327
+ #
214
328
  def start_observing
329
+
215
330
  get_participant_map.add_observer @participant_regex, self
216
331
  end
217
332
 
333
+ #
334
+ # Expression's job is over, deregister.
335
+ #
218
336
  def stop_observing
337
+
219
338
  get_participant_map.remove_observer self
220
339
  end
221
340
  end
@@ -52,18 +52,24 @@ module OpenWFE
52
52
  # <participant ref="toto" />
53
53
  # </lose>
54
54
  #
55
- # Useful only some special process cases.
55
+ # Useful only some special process cases (like a concurrence
56
+ # expecting only a certain number of replies).
57
+ #
58
+ # The brother expressions is 'forget', but 'forget' triggers its child
59
+ # and immediately replies, whereas 'lose' doesn't reply.
56
60
  #
57
61
  class LoseExpression < FlowExpression
58
62
 
59
63
  names :lose
60
64
 
61
65
  def apply (workitem)
66
+
62
67
  get_expression_pool.apply(children[0], workitem) \
63
68
  if (@children and @children.length > 0)
64
69
  end
65
70
 
66
71
  def reply (workitem)
72
+
67
73
  get_expression_pool.remove(self)
68
74
  end
69
75
  end
@@ -72,6 +78,12 @@ module OpenWFE
72
78
  # This expression triggers its child (in its own thread) and then
73
79
  # forgets about it. It immediately replies to its parent expression.
74
80
  #
81
+ # The brother expression 'lose' triggers its child but never replies to its
82
+ # parent expression.
83
+ #
84
+ # The 'forget' expression is useful for triggering process segments
85
+ # that are, well, dead ends.
86
+ #
75
87
  class ForgetExpression < FlowExpression
76
88
 
77
89
  names :forget
@@ -43,18 +43,36 @@ require 'openwfe/expressions/flowexpression'
43
43
 
44
44
  module OpenWFE
45
45
 
46
+ #
47
+ # A debug/test expression (it's mostly used in the test suite
48
+ # used for the development of OpenWFEru).
49
+ # Outputs a message to the STDOUT (via the "puts" Ruby method).
50
+ #
51
+ # <print>hello</print>
52
+ #
53
+ # _print "hello"
54
+ # _print do
55
+ # "in a block"
56
+ # end
57
+ #
58
+ # Note that when expressing the process in Ruby, an underscore has to be
59
+ # placed in front of the expression name to avoid a collision with the
60
+ # Ruby 'print' function.
61
+ #
62
+ # If there is an object bound in the application context under the
63
+ # name '__tracer', this expression will append its message to this
64
+ # instance instead of emitting to the STDOUT. (this is how the
65
+ # OpenWFEru test suite uses this expression).
66
+ #
46
67
  class PrintExpression < FlowExpression
47
68
 
48
69
  names :print
49
70
 
50
- #
51
- # apply / reply
52
-
53
71
  def apply (workitem)
54
72
 
55
73
  escape = lookup_boolean_attribute('escape', workitem, false)
56
74
 
57
- text = fetch_text_content(workitem, escape)
75
+ text = fetch_text_content workitem, escape
58
76
  text << "\n"
59
77
 
60
78
  tracer = @application_context['__tracer']
@@ -65,16 +83,10 @@ module OpenWFE
65
83
  puts text
66
84
  end
67
85
 
68
- reply_to_parent(workitem)
86
+ reply_to_parent workitem
69
87
  end
70
-
71
- #def reply (workitem)
72
- #end
73
-
74
88
  end
75
89
 
76
- #
77
- # <reval/>
78
90
  #
79
91
  # Evals some Ruby code contained within the process definition
80
92
  # or within the workitem.
@@ -146,5 +158,52 @@ module OpenWFE
146
158
  end
147
159
  end
148
160
 
161
+ #
162
+ # This expression simply emits a message to the application
163
+ # log (by default logs/openwferu.log).
164
+ #
165
+ # <sequence>
166
+ # <log>before participant alpha</log>
167
+ # <participant ref="alpha" />
168
+ # <log>after participant alpha</log>
169
+ # <log level="warn">after participant alpha</log>
170
+ # </sequence>
171
+ #
172
+ # And an example with a Ruby process definition :
173
+ #
174
+ # sequence do
175
+ # log "simple debug message"
176
+ # log do
177
+ # "another debug message"
178
+ # end
179
+ # log :message => "yet another debug message"
180
+ # log :message => "an info level message", :level => "info"
181
+ # end
182
+ #
183
+ # Possible log levels are 'debug' (the default), 'info', 'warn' and
184
+ # 'fatal'.
185
+ #
186
+ class LogExpression < FlowExpression
187
+
188
+ names :log
189
+
190
+ def apply (workitem)
191
+
192
+ escape = lookup_boolean_attribute('escape', workitem, false)
193
+ text = fetch_text_content(workitem, escape)
194
+ text = lookup_attribute('message', workitem) unless text
195
+
196
+ level = lookup_attribute('level', workitem)
197
+ level = level.downcase.to_sym if level
198
+
199
+ level = :debug \
200
+ unless [ :info, :warn, :error, :fatal ].include?(level)
201
+
202
+ get_engine.llog(level, text) if text
203
+
204
+ reply_to_parent workitem
205
+ end
206
+ end
207
+
149
208
  end
150
209
 
@@ -122,9 +122,9 @@ module OpenWFE
122
122
 
123
123
  names :participant
124
124
 
125
- attr_accessor \
126
- :participant_name,
127
- :applied_workitem
125
+ attr_accessor :participant_name
126
+ attr_accessor :applied_workitem
127
+
128
128
 
129
129
  def apply (workitem)
130
130
 
@@ -88,7 +88,7 @@ module OpenWFE
88
88
  return
89
89
  end
90
90
 
91
- @mutex_name = lookup_attribute :mutex, workitem
91
+ @mutex_name = lookup_string_attribute :mutex, workitem
92
92
 
93
93
  super
94
94
  end