ruote 0.9.18 → 0.9.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (323) hide show
  1. data/README.txt +2 -0
  2. data/examples/about_state.rb +29 -29
  3. data/examples/bigflow.rb +9 -9
  4. data/examples/csv_weather.rb +4 -4
  5. data/examples/engine_template.rb +141 -129
  6. data/examples/flowtracing.rb +8 -8
  7. data/examples/homeworkreview.rb +15 -15
  8. data/examples/kotoba.rb +9 -9
  9. data/examples/mano_tracker.rb +63 -63
  10. data/examples/openwferu.rb +22 -20
  11. data/examples/quotereporter.rb +79 -79
  12. data/lib/openwfe/contextual.rb +72 -72
  13. data/lib/openwfe/def.rb +21 -21
  14. data/lib/openwfe/engine.rb +19 -19
  15. data/lib/openwfe/engine/engine.rb +578 -614
  16. data/lib/openwfe/engine/expool_methods.rb +144 -115
  17. data/lib/openwfe/engine/file_persisted_engine.rb +77 -77
  18. data/lib/openwfe/engine/participant_methods.rb +96 -96
  19. data/lib/openwfe/engine/status_methods.rb +271 -247
  20. data/lib/openwfe/engine/update_exp_methods.rb +69 -69
  21. data/lib/openwfe/exceptions.rb +25 -25
  22. data/lib/openwfe/expool/errorjournal.rb +334 -348
  23. data/lib/openwfe/expool/expool_pause_methods.rb +98 -0
  24. data/lib/openwfe/expool/expressionpool.rb +793 -800
  25. data/lib/openwfe/expool/expstorage.rb +284 -313
  26. data/lib/openwfe/expool/history.rb +193 -105
  27. data/lib/openwfe/expool/journal.rb +163 -163
  28. data/lib/openwfe/expool/journal_replay.rb +228 -228
  29. data/lib/openwfe/expool/parser.rb +178 -142
  30. data/lib/openwfe/{orest/exception.rb → expool/paused_error.rb} +49 -32
  31. data/lib/openwfe/expool/representation.rb +59 -59
  32. data/lib/openwfe/expool/threadedexpstorage.rb +137 -134
  33. data/lib/openwfe/expool/wfidgen.rb +289 -287
  34. data/lib/openwfe/expool/yamlexpstorage.rb +154 -154
  35. data/lib/openwfe/expressions/condition.rb +175 -168
  36. data/lib/openwfe/expressions/environment.rb +165 -165
  37. data/lib/openwfe/expressions/expressionmap.rb +135 -131
  38. data/lib/openwfe/expressions/fe_cancel.rb +68 -68
  39. data/lib/openwfe/expressions/fe_command.rb +190 -190
  40. data/lib/openwfe/expressions/fe_concurrence.rb +531 -531
  41. data/lib/openwfe/expressions/fe_cron.rb +152 -197
  42. data/lib/openwfe/expressions/fe_cursor.rb +152 -186
  43. data/lib/openwfe/expressions/fe_define.rb +118 -118
  44. data/lib/openwfe/expressions/fe_do.rb +109 -109
  45. data/lib/openwfe/expressions/fe_equals.rb +219 -219
  46. data/lib/openwfe/expressions/fe_filter.rb +98 -98
  47. data/lib/openwfe/expressions/fe_filter_definition.rb +122 -122
  48. data/lib/openwfe/expressions/fe_fqv.rb +203 -203
  49. data/lib/openwfe/expressions/fe_http.rb +212 -0
  50. data/lib/openwfe/expressions/fe_if.rb +214 -214
  51. data/lib/openwfe/expressions/fe_iterator.rb +91 -91
  52. data/lib/openwfe/expressions/fe_listen.rb +268 -268
  53. data/lib/openwfe/expressions/fe_losfor.rb +73 -73
  54. data/lib/openwfe/expressions/fe_misc.rb +343 -351
  55. data/lib/openwfe/expressions/fe_participant.rb +206 -206
  56. data/lib/openwfe/expressions/fe_reserve.rb +153 -142
  57. data/lib/openwfe/expressions/fe_save.rb +226 -226
  58. data/lib/openwfe/expressions/fe_sequence.rb +66 -56
  59. data/lib/openwfe/expressions/fe_set.rb +80 -80
  60. data/lib/openwfe/expressions/fe_sleep.rb +132 -125
  61. data/lib/openwfe/expressions/fe_step.rb +113 -111
  62. data/lib/openwfe/expressions/fe_subprocess.rb +139 -136
  63. data/lib/openwfe/expressions/fe_timeout.rb +74 -78
  64. data/lib/openwfe/expressions/fe_wait.rb +48 -49
  65. data/lib/openwfe/expressions/fe_when.rb +106 -106
  66. data/lib/openwfe/expressions/filter.rb +60 -60
  67. data/lib/openwfe/expressions/flowexpression.rb +618 -612
  68. data/lib/openwfe/expressions/iterator.rb +158 -158
  69. data/lib/openwfe/expressions/merge.rb +53 -53
  70. data/lib/openwfe/expressions/raw.rb +396 -397
  71. data/lib/openwfe/expressions/rprocdef.rb +261 -266
  72. data/lib/openwfe/expressions/time.rb +238 -243
  73. data/lib/openwfe/expressions/timeout.rb +135 -135
  74. data/lib/openwfe/expressions/value.rb +55 -55
  75. data/lib/openwfe/extras/engine/db_persisted_engine.rb +94 -0
  76. data/lib/openwfe/extras/expool/dberrorjournal.rb +189 -0
  77. data/lib/openwfe/extras/expool/dbexpstorage.rb +355 -0
  78. data/lib/openwfe/extras/expool/dbhistory.rb +135 -0
  79. data/lib/openwfe/extras/listeners/sqslisteners.rb +146 -0
  80. data/lib/openwfe/extras/misc/activityfeed.rb +264 -0
  81. data/lib/openwfe/extras/misc/basecamp.rb +485 -0
  82. data/lib/openwfe/extras/participants/activeparticipants.rb +749 -0
  83. data/lib/openwfe/extras/participants/atomfeed_participants.rb +173 -0
  84. data/lib/openwfe/extras/participants/atompub_participants.rb +267 -0
  85. data/lib/openwfe/extras/participants/basecamp_participants.rb +87 -0
  86. data/lib/openwfe/extras/participants/csvparticipants.rb +127 -0
  87. data/lib/openwfe/extras/participants/sqsparticipants.rb +125 -0
  88. data/lib/openwfe/extras/participants/twitterparticipants.rb +176 -0
  89. data/lib/openwfe/filterdef.rb +191 -191
  90. data/lib/openwfe/flowexpressionid.rb +271 -269
  91. data/lib/openwfe/listeners/listener.rb +61 -61
  92. data/lib/openwfe/listeners/listeners.rb +81 -81
  93. data/lib/openwfe/listeners/socketlisteners.rb +189 -189
  94. data/lib/openwfe/logging.rb +74 -74
  95. data/lib/openwfe/omixins.rb +55 -54
  96. data/lib/openwfe/orest/definitions.rb +90 -90
  97. data/lib/openwfe/orest/osocket.rb +91 -91
  98. data/lib/openwfe/orest/xmlcodec.rb +471 -459
  99. data/lib/openwfe/participants.rb +19 -19
  100. data/lib/openwfe/participants/enoparticipants.rb +187 -187
  101. data/lib/openwfe/participants/participant.rb +100 -100
  102. data/lib/openwfe/participants/participantmap.rb +170 -170
  103. data/lib/openwfe/participants/participants.rb +316 -316
  104. data/lib/openwfe/participants/soapparticipants.rb +90 -90
  105. data/lib/openwfe/participants/socketparticipants.rb +143 -143
  106. data/lib/openwfe/participants/storeparticipants.rb +198 -198
  107. data/lib/openwfe/rexml.rb +44 -0
  108. data/lib/openwfe/rudefinitions.rb +87 -91
  109. data/lib/openwfe/service.rb +65 -65
  110. data/lib/openwfe/storage/yamlcustom.rb +71 -71
  111. data/lib/openwfe/storage/yamlfilestorage.rb +190 -190
  112. data/lib/openwfe/tools/flowtracer.rb +41 -45
  113. data/lib/openwfe/util/dollar.rb +125 -139
  114. data/lib/openwfe/util/irb.rb +42 -42
  115. data/lib/openwfe/util/observable.rb +93 -99
  116. data/lib/openwfe/util/ometa.rb +36 -36
  117. data/lib/openwfe/util/treechecker.rb +122 -0
  118. data/lib/openwfe/util/workqueue.rb +73 -73
  119. data/lib/openwfe/util/xml.rb +285 -279
  120. data/lib/openwfe/utils.rb +415 -442
  121. data/lib/openwfe/version.rb +1 -1
  122. data/lib/openwfe/workitem.rb +444 -437
  123. data/lib/openwfe/worklist/oldrest.rb +161 -161
  124. data/lib/openwfe/worklist/storelocks.rb +218 -218
  125. data/lib/openwfe/worklist/storeparticipant.rb +19 -19
  126. data/lib/openwfe/worklist/worklist.rb +223 -223
  127. data/test/back_0916_test.rb +57 -59
  128. data/test/bm/bm_1_xml_vs_prog.rb +25 -22
  129. data/test/bm/bm_2_step.rb +81 -81
  130. data/test/bm/ft_0f_5ms.rb +13 -13
  131. data/test/bm/ft_26_load.rb +177 -179
  132. data/test/bm/ft_26b_load.rb +57 -59
  133. data/test/bm/ft_26c_load.rb +70 -65
  134. data/test/bm/ft_recu.rb +51 -51
  135. data/test/clone_test.rb +145 -99
  136. data/test/concurrence_test.rb +41 -41
  137. data/test/condition_test.rb +104 -90
  138. data/test/description_test.rb +46 -45
  139. data/test/eno_test.rb +36 -36
  140. data/test/expmap_test.rb +26 -26
  141. data/test/extras/README.txt +5 -0
  142. data/test/extras/active_connection.rb +48 -0
  143. data/test/extras/active_with_engine_test.rb +140 -0
  144. data/test/extras/activityfeed_test.rb +85 -0
  145. data/test/extras/ap_0_test.rb +287 -0
  146. data/test/extras/ap_1_test.rb +53 -0
  147. data/test/extras/ap_test_base.rb +24 -0
  148. data/test/extras/atomfeedp_test.rb +113 -0
  149. data/test/extras/atompubp_test.rb +91 -0
  150. data/test/extras/basecamp_test.rb +53 -0
  151. data/test/extras/db_errorjournal_utest.rb +75 -0
  152. data/test/extras/db_expstorage_utest.rb +171 -0
  153. data/test/extras/db_history_0_test.rb +58 -0
  154. data/test/extras/ft_19_csv.rb +58 -0
  155. data/test/extras/ft_71_b14008.rb +85 -0
  156. data/test/extras/sqs_test.rb +57 -0
  157. data/test/extras/twitter_test.rb +62 -0
  158. data/test/fe_lookup_att_test.rb +41 -41
  159. data/test/fei_test.rb +131 -131
  160. data/test/file_persisted_engine_test.rb +30 -30
  161. data/test/file_persistence_test.rb +112 -111
  162. data/test/filep_cancel_test.rb +58 -58
  163. data/test/filter_test.rb +67 -67
  164. data/test/flowtestbase.rb +207 -219
  165. data/test/ft_0.rb +35 -35
  166. data/test/ft_0b_sequence.rb +15 -15
  167. data/test/ft_0c_testname.rb +12 -12
  168. data/test/ft_0d_participant.rb +9 -9
  169. data/test/ft_0e_multibody.rb +11 -11
  170. data/test/ft_10_loop.rb +103 -104
  171. data/test/ft_11_ppd.rb +285 -289
  172. data/test/ft_11b_ppd.rb +26 -26
  173. data/test/ft_12_blockparticipant.rb +57 -57
  174. data/test/ft_13_eno.rb +31 -31
  175. data/test/ft_14_subprocess.rb +45 -45
  176. data/test/ft_14b_subprocess.rb +107 -107
  177. data/test/ft_14c_subprocess.rb +33 -33
  178. data/test/ft_15_iterator.rb +127 -127
  179. data/test/ft_15b_iterator.rb +41 -41
  180. data/test/ft_16_fqv.rb +44 -44
  181. data/test/ft_17_condition.rb +48 -48
  182. data/test/ft_18_pname.rb +26 -26
  183. data/test/ft_1_unset.rb +140 -140
  184. data/test/ft_1b_unset.rb +17 -17
  185. data/test/ft_20_cron.rb +33 -33
  186. data/test/ft_21_cron.rb +51 -51
  187. data/test/ft_21b_cron_pause.rb +41 -41
  188. data/test/ft_22_history.rb +45 -41
  189. data/test/ft_23_when.rb +51 -51
  190. data/test/ft_23b_when.rb +43 -43
  191. data/test/ft_23c_wait.rb +48 -48
  192. data/test/ft_23d_cww.rb +28 -28
  193. data/test/ft_24_def.rb +15 -15
  194. data/test/ft_25_cancel.rb +57 -54
  195. data/test/ft_27_getflowpos.rb +79 -83
  196. data/test/ft_28_fileparticipant.rb +25 -25
  197. data/test/ft_29_httprb.rb +57 -57
  198. data/test/ft_2_concurrence.rb +99 -97
  199. data/test/ft_2b_concurrence.rb +132 -132
  200. data/test/ft_2c_concurrence.rb +37 -37
  201. data/test/ft_30_socketlistener.rb +133 -133
  202. data/test/ft_31_flowname.rb +15 -16
  203. data/test/ft_32_journal.rb +48 -48
  204. data/test/ft_32c_journal.rb +54 -54
  205. data/test/ft_32d_journal.rb +43 -46
  206. data/test/ft_33_description.rb +62 -62
  207. data/test/ft_34_cancelwfid.rb +37 -37
  208. data/test/ft_35_localdefs.rb +36 -34
  209. data/test/ft_36_subprocids.rb +61 -61
  210. data/test/ft_37_pnames.rb +33 -33
  211. data/test/ft_38_tag.rb +82 -82
  212. data/test/ft_38b_tag.rb +97 -97
  213. data/test/ft_38c_tag.rb +50 -50
  214. data/test/ft_38d_tag.rb +53 -0
  215. data/test/ft_39_reserve.rb +33 -33
  216. data/test/ft_39b_reserve.rb +59 -59
  217. data/test/ft_3_equals.rb +131 -131
  218. data/test/ft_3b_lookup_vf.rb +43 -43
  219. data/test/ft_40_defined.rb +33 -33
  220. data/test/ft_41_case.rb +80 -80
  221. data/test/ft_42_environments.rb +48 -48
  222. data/test/ft_43_pat10.rb +51 -51
  223. data/test/ft_44_save.rb +37 -37
  224. data/test/ft_44b_restore.rb +151 -151
  225. data/test/ft_45_citerator.rb +149 -149
  226. data/test/ft_45b_citerator.rb +77 -0
  227. data/test/ft_46_pparams.rb +27 -27
  228. data/test/ft_47_filter.rb +100 -100
  229. data/test/ft_48_fe_filter.rb +41 -41
  230. data/test/ft_49_condition.rb +101 -94
  231. data/test/ft_4_misc.rb +185 -190
  232. data/test/ft_50_xml_attribute.rb +101 -104
  233. data/test/ft_51_stack.rb +30 -30
  234. data/test/ft_52_obs_participant.rb +73 -73
  235. data/test/ft_53_null_noop_participant.rb +31 -31
  236. data/test/ft_54_listen.rb +183 -183
  237. data/test/ft_54b_listen.rb +32 -32
  238. data/test/ft_54c_listen.rb +60 -60
  239. data/test/ft_55_ptimeout.rb +29 -30
  240. data/test/ft_56_timeout.rb +29 -29
  241. data/test/ft_57_a.rb +105 -102
  242. data/test/ft_58_ejournal.rb +83 -80
  243. data/test/ft_58b_ejournal.rb +82 -0
  244. data/test/ft_59_ps.rb +148 -86
  245. data/test/ft_5_time.rb +77 -77
  246. data/test/ft_60_ecancel.rb +98 -98
  247. data/test/ft_61_elsub.rb +23 -23
  248. data/test/ft_62_procparticipant.rb +46 -46
  249. data/test/ft_63_pause.rb +82 -69
  250. data/test/ft_64_alias.rb +56 -57
  251. data/test/ft_65_stringlaunch.rb +29 -29
  252. data/test/ft_66_subforget.rb +42 -42
  253. data/test/ft_67_schedlaunch.rb +58 -59
  254. data/test/ft_68_ifparticipant.rb +39 -39
  255. data/test/ft_69_cancelmissing.rb +23 -21
  256. data/test/ft_6_lambda.rb +37 -37
  257. data/test/ft_70_lookupvar.rb +25 -25
  258. data/test/ft_71_log.rb +35 -35
  259. data/test/ft_72_lookup_processes.rb +43 -40
  260. data/test/ft_73_cancel_sub.rb +79 -79
  261. data/test/ft_74_block_and_workitem_dup.rb +42 -42
  262. data/test/ft_75_ruby_attributes.rb +53 -51
  263. data/test/ft_76_merge_isolate.rb +57 -57
  264. data/test/ft_77_segments.rb +13 -13
  265. data/test/ft_78_eval.rb +94 -94
  266. data/test/ft_79_tticket.rb +79 -79
  267. data/test/ft_79b_tticket.rb +73 -73
  268. data/test/ft_79c_outcome.rb +36 -36
  269. data/test/ft_7_lose.rb +73 -73
  270. data/test/ft_7b_lose.rb +49 -49
  271. data/test/ft_80_spname.rb +65 -65
  272. data/test/ft_81_exp.rb +30 -30
  273. data/test/ft_82_trecu.rb +30 -24
  274. data/test/ft_83_badpause.rb +35 -35
  275. data/test/ft_84_updateexp.rb +118 -118
  276. data/test/ft_84b_subrepr.rb +72 -0
  277. data/test/ft_85_dolhash.rb +18 -18
  278. data/test/ft_86_dollar_fv.rb +33 -33
  279. data/test/ft_87_define.rb +47 -47
  280. data/test/ft_88_http.rb +100 -0
  281. data/test/ft_8_forget.rb +25 -25
  282. data/test/ft_9_cursor.rb +119 -110
  283. data/test/ft_9b_cursor.rb +70 -70
  284. data/test/ft_tests.rb +6 -0
  285. data/test/hash_test.rb +52 -34
  286. data/test/hparticipant_test.rb +92 -88
  287. data/test/lookup_att_test.rb +70 -70
  288. data/test/lookup_vf_test.rb +52 -52
  289. data/test/misc_test.rb +55 -51
  290. data/test/obs_test.rb +82 -82
  291. data/test/param_test.rb +181 -181
  292. data/test/participant_test.rb +46 -46
  293. data/test/pending.rb +12 -12
  294. data/test/ps_representation.rb +70 -70
  295. data/test/rake_ltest.rb +2 -2
  296. data/test/rake_qtest.rb +11 -11
  297. data/test/raw_prog_test.rb +303 -308
  298. data/test/restart_cron_test.rb +74 -74
  299. data/test/restart_paused_test.rb +52 -47
  300. data/test/restart_sleep_test.rb +80 -80
  301. data/test/restart_when_test.rb +64 -64
  302. data/test/ruby_procdef_test.rb +71 -71
  303. data/test/rutest_utils.rb +32 -32
  304. data/test/sec_test.rb +143 -142
  305. data/test/slock_test.rb +41 -41
  306. data/test/storage_test.rb +15 -15
  307. data/test/timeout_test.rb +53 -53
  308. data/test/treechecker_test.rb +111 -0
  309. data/test/util_xml_test.rb +57 -57
  310. data/test/wfid_test.rb +93 -93
  311. data/test/wi_test.rb +58 -58
  312. metadata +64 -19
  313. data/examples/scheduler_cron_usage.rb +0 -48
  314. data/examples/scheduler_usage.rb +0 -56
  315. data/lib/openwfe/orest/controlclient.rb +0 -119
  316. data/lib/openwfe/orest/oldrestservlet.rb +0 -279
  317. data/lib/openwfe/orest/restclient.rb +0 -176
  318. data/lib/openwfe/orest/workitem.rb +0 -206
  319. data/lib/openwfe/orest/worklistclient.rb +0 -272
  320. data/test/bm/ft_26d_load.rb +0 -97
  321. data/test/ft_59b_ps_for_pat.rb +0 -58
  322. data/test/ft_64_clone.rb +0 -69
  323. data/test/orest_test.rb +0 -251
@@ -2,31 +2,31 @@
2
2
  #--
3
3
  # Copyright (c) 2007, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
- #
6
- # Redistribution and use in source and binary forms, with or without
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
7
  # modification, are permitted provided that the following conditions are met:
8
- #
8
+ #
9
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
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
14
  # and/or other materials provided with the distribution.
15
- #
15
+ #
16
16
  # . Neither the name of the "OpenWFE" nor the names of its contributors may be
17
17
  # used to endorse or promote products derived from this software without
18
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
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
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
@@ -44,61 +44,61 @@
44
44
 
45
45
  module OpenWFE
46
46
 
47
- #
48
- # This mixin adds filtering capabilities to a FlowExpression.
49
- #
50
- # It's used by the 'participant' and 'filter' expressions.
51
- #
52
- module FilterMixin
47
+ #
48
+ # This mixin adds filtering capabilities to a FlowExpression.
49
+ #
50
+ # It's used by the 'participant' and 'filter' expressions.
51
+ #
52
+ module FilterMixin
53
53
 
54
- attr_accessor :filter
54
+ attr_accessor :filter
55
55
 
56
- #
57
- # Used when the workitem enters the 'filtered zone'. Will replace
58
- # the attributes of the workitem with filtered ones.
59
- # Assumes the original workitem is kept under @applied_workitem.
60
- #
61
- def filter_in workitem, filter_attribute_name=:filter
56
+ #
57
+ # Used when the workitem enters the 'filtered zone'. Will replace
58
+ # the attributes of the workitem with filtered ones.
59
+ # Assumes the original workitem is kept under @applied_workitem.
60
+ #
61
+ def filter_in workitem, filter_attribute_name=:filter
62
62
 
63
- @filter = get_filter filter_attribute_name, workitem
63
+ @filter = get_filter filter_attribute_name, workitem
64
64
 
65
- return unless @filter
65
+ return unless @filter
66
66
 
67
- workitem.attributes = @filter.filter_in workitem.attributes
68
- workitem.filter = @filter.dup
69
- end
67
+ workitem.attributes = @filter.filter_in workitem.attributes
68
+ workitem.filter = @filter.dup
69
+ end
70
70
 
71
- #
72
- # Prepares the workitem for leaving the 'filtered zone'. Makes sure
73
- # hidden and unwritable fields haven't been tampered with. Enforces
74
- # the 'add_ok', 'remove_ok', 'closed' filter directives.
75
- # Assumes the original workitem is kept under @applied_workitem.
76
- #
77
- def filter_out incoming_workitem
71
+ #
72
+ # Prepares the workitem for leaving the 'filtered zone'. Makes sure
73
+ # hidden and unwritable fields haven't been tampered with. Enforces
74
+ # the 'add_ok', 'remove_ok', 'closed' filter directives.
75
+ # Assumes the original workitem is kept under @applied_workitem.
76
+ #
77
+ def filter_out incoming_workitem
78
78
 
79
- return unless @filter
79
+ return unless @filter
80
80
 
81
- incoming_workitem.filter = nil
81
+ incoming_workitem.filter = nil
82
82
 
83
- incoming_workitem.attributes = @filter.filter_out(
84
- @applied_workitem.attributes, incoming_workitem.attributes)
85
- end
83
+ incoming_workitem.attributes = @filter.filter_out(
84
+ @applied_workitem.attributes, incoming_workitem.attributes)
85
+ end
86
86
 
87
- protected
87
+ protected
88
88
 
89
- #
90
- # Fetches the filter pointed at via the 'filter' attribute
91
- # of the including expression class.
92
- #
93
- def get_filter filter_attribute_name, workitem
89
+ #
90
+ # Fetches the filter pointed at via the 'filter' attribute
91
+ # of the including expression class.
92
+ #
93
+ def get_filter filter_attribute_name, workitem
94
94
 
95
- filter_name = lookup_attribute filter_attribute_name, workitem
95
+ filter_name = lookup_attribute filter_attribute_name, workitem
96
96
 
97
- return nil unless filter_name
97
+ return nil unless filter_name
98
98
 
99
- lookup_variable filter_name
100
- end
101
- end
99
+ lookup_variable filter_name
100
+ end
101
+ end
102
102
 
103
103
  end
104
104
 
@@ -47,801 +47,807 @@ require 'openwfe/util/dollar'
47
47
 
48
48
  module OpenWFE
49
49
 
50
+ #
51
+ # When this variable is set to true (at the process root),
52
+ # it means the process is paused.
53
+ #
54
+ VAR_PAUSED = '/__paused__'
55
+
56
+ #
57
+ # FlowExpression
58
+ #
59
+ # The base class for all OpenWFE flow expression classes.
60
+ # It gathers all the methods for attributes and variable lookup.
61
+ #
62
+ class FlowExpression < ObjectWithMeta
63
+ include Contextual, Logging, OwfeServiceLocator
64
+
50
65
  #
51
- # When this variable is set to true (at the process root),
52
- # it means the process is paused.
66
+ # The 'flow expression id' the unique identifier within a
67
+ # workflow instance for this expression instance.
53
68
  #
54
- VAR_PAUSED = '/__paused__'
69
+ attr_accessor :fei
55
70
 
56
71
  #
57
- # FlowExpression
72
+ # The 'flow expression id' of the parent expression.
73
+ # Will yield 'nil' if this expression is the root of its process
74
+ # instance.
75
+ #
76
+ attr_accessor :parent_id
77
+
58
78
  #
59
- # The base class for all OpenWFE flow expression classes.
60
- # It gathers all the methods for attributes and variable lookup.
79
+ # The 'flow expression id' of the environment this expression works
80
+ # with.
61
81
  #
62
- class FlowExpression < ObjectWithMeta
63
- include Contextual, Logging, OwfeServiceLocator
82
+ attr_accessor :environment_id
64
83
 
65
- #
66
- # The 'flow expression id' the unique identifier within a
67
- # workflow instance for this expression instance.
68
- #
69
- attr_accessor :fei
84
+ #
85
+ # The attributes of the expression, as found in the process definition.
86
+ #
87
+ # <participant ref='toto' timeout='1d10h' />
88
+ #
89
+ # The attributes will be ref => "toto" and timeout => "1d10h" (yes,
90
+ # 'attributes' contains a hash.
91
+ #
92
+ attr_accessor :attributes
70
93
 
71
- #
72
- # The 'flow expression id' of the parent expression.
73
- # Will yield 'nil' if this expression is the root of its process
74
- # instance.
75
- #
76
- attr_accessor :parent_id
94
+ #
95
+ # An array of 'flow expression id' instances. These are the ids of
96
+ # the expressions children to this one.
97
+ #
98
+ # <sequence>
99
+ # <participant ref="toto" />
100
+ # <participant ref="bert" />
101
+ # </sequence>
102
+ #
103
+ # The expression instance for 'sequence' will hold the feis of toto and
104
+ # bert in its children array.
105
+ #
106
+ attr_accessor :children
77
107
 
78
- #
79
- # The 'flow expression id' of the environment this expression works
80
- # with.
81
- #
82
- attr_accessor :environment_id
108
+ #
109
+ # When the FlowExpression instance is applied, this time stamp is set
110
+ # to the current date.
111
+ #
112
+ attr_accessor :apply_time
83
113
 
84
- #
85
- # The attributes of the expression, as found in the process definition.
86
- #
87
- # <participant ref='toto' timeout='1d10h' />
88
- #
89
- # The attributes will be ref => "toto" and timeout => "1d10h" (yes,
90
- # 'attributes' contains a hash.
91
- #
92
- attr_accessor :attributes
114
+ #
115
+ # Used by raw expressions to store the not yet interpreted branches
116
+ # of a process, used by other expressions to store their
117
+ # representation at 'eval time'.
118
+ #
119
+ attr_accessor :raw_representation
93
120
 
94
- #
95
- # An array of 'flow expression id' instances. These are the ids of
96
- # the expressions children to this one.
97
- #
98
- # <sequence>
99
- # <participant ref="toto" />
100
- # <participant ref="bert" />
101
- # </sequence>
102
- #
103
- # The expression instance for 'sequence' will hold the feis of toto and
104
- # bert in its children array.
105
- #
106
- attr_accessor :children
121
+ #
122
+ # Meant to contain a boolean value. If set to 'true' it means that
123
+ # this expression raw_representation has been modified after
124
+ # the expression instantiation.
125
+ #
126
+ # It's used to keep track effectively of in-flight modifications
127
+ # of process instances.
128
+ #
129
+ attr_accessor :raw_rep_updated
107
130
 
108
- #
109
- # When the FlowExpression instance is applied, this time stamp is set
110
- # to the current date.
111
- #
112
- attr_accessor :apply_time
131
+ #
132
+ # When was this expression last updated ?
133
+ #
134
+ attr_accessor :updated_at
113
135
 
114
- #
115
- # Used by raw expressions to store the not yet interpreted branches
116
- # of a process, used by other expressions to store their
117
- # representation at 'eval time'.
118
- #
119
- attr_accessor :raw_representation
120
136
 
137
+ #
138
+ # The classical no-params constructors.
139
+ #
140
+ def initialize
141
+
142
+ super
121
143
  #
122
- # Meant to contain a boolean value. If set to 'true' it means that
123
- # this expression raw_representation has been modified after
124
- # the expression instantiation.
125
- #
126
- # It's used to keep track effectively of in-flight modifications
127
- # of process instances.
128
- #
129
- attr_accessor :raw_rep_updated
144
+ # very necessary as this class includes the MonitorMixin
145
+ end
130
146
 
147
+ #
148
+ # Builds a new instance of an expression
149
+ #
150
+ def self.new_exp (fei, parent_id, env_id, app_context, attributes)
131
151
 
132
- #
133
- # The classical no-params constructors.
134
- #
135
- def initialize
152
+ e = self.new
136
153
 
137
- super
138
- #
139
- # very necessary as this class includes the MonitorMixin
140
- end
154
+ e.fei = fei
155
+ e.parent_id = parent_id
156
+ e.environment_id = env_id
157
+ e.application_context = app_context
158
+ e.attributes = attributes
141
159
 
142
- #
143
- # Builds a new instance of an expression
144
- #
145
- def self.new_exp (fei, parent_id, env_id, app_context, attributes)
160
+ e.children = []
161
+ e.apply_time = nil
146
162
 
147
- e = self.new
163
+ e
164
+ end
148
165
 
149
- e.fei = fei
150
- e.parent_id = parent_id
151
- e.environment_id = env_id
152
- e.application_context = app_context
153
- e.attributes = attributes
166
+ #--
167
+ # the two most important methods for flow expressions
168
+ #++
154
169
 
155
- e.children = []
156
- e.apply_time = nil
170
+ #
171
+ # this default implementation immediately replies to the
172
+ # parent expression
173
+ #
174
+ def apply (workitem)
157
175
 
158
- e
159
- end
176
+ get_parent.reply(workitem) if @parent_id
177
+ end
160
178
 
161
- #--
162
- # the two most important methods for flow expressions
163
- #++
179
+ #
180
+ # this default implementation immediately replies to the
181
+ # parent expression
182
+ #
183
+ def reply (workitem)
164
184
 
165
- #
166
- # this default implementation immediately replies to the
167
- # parent expression
168
- #
169
- def apply (workitem)
185
+ reply_to_parent workitem
186
+ end
170
187
 
171
- get_parent.reply(workitem) if @parent_id
172
- end
188
+ #
189
+ # Triggers the reply to the parent expression (of course, via the
190
+ # expression pool).
191
+ # Expressions do call this method when their job is done and the flow
192
+ # should resume without them.
193
+ #
194
+ def reply_to_parent (workitem)
173
195
 
174
- #
175
- # this default implementation immediately replies to the
176
- # parent expression
177
- #
178
- def reply (workitem)
196
+ get_expression_pool.reply_to_parent self, workitem
197
+ end
179
198
 
180
- reply_to_parent workitem
181
- end
199
+ #
200
+ # a default implementation for cancel :
201
+ # cancels all the children
202
+ # Attempts to return an InFlowWorkItem
203
+ #
204
+ def cancel
182
205
 
183
- #
184
- # Triggers the reply to the parent expression (of course, via the
185
- # expression pool).
186
- # Expressions do call this method when their job is done and the flow
187
- # should resume without them.
188
- #
189
- def reply_to_parent (workitem)
206
+ return nil unless @children
190
207
 
191
- get_expression_pool.reply_to_parent self, workitem
192
- end
208
+ inflowitem = nil
193
209
 
194
- #
195
- # a default implementation for cancel :
196
- # cancels all the children
197
- # Attempts to return an InFlowWorkItem
198
- #
199
- def cancel
210
+ @children.each do |child|
200
211
 
201
- return nil unless @children
212
+ next if child.is_a?(String)
202
213
 
203
- inflowitem = nil
214
+ i = get_expression_pool.cancel child
215
+ inflowitem ||= i
216
+ end
204
217
 
205
- @children.each do |child|
218
+ inflowitem
219
+ end
206
220
 
207
- next if child.is_a?(String)
221
+ #
222
+ # some convenience methods
208
223
 
209
- i = get_expression_pool.cancel child
210
- inflowitem ||= i
211
- end
224
+ #
225
+ # Returns the parent expression (not as a FlowExpressionId but directly
226
+ # as the FlowExpression instance it is).
227
+ #
228
+ def get_parent
212
229
 
213
- inflowitem
214
- end
230
+ get_expression_pool.fetch_expression @parent_id
231
+ end
215
232
 
216
- #
217
- # some convenience methods
233
+ #
234
+ # Stores itself in the expression pool.
235
+ # It's very important for expressions in persisted context to save
236
+ # themselves as soon as their state changed.
237
+ # Else this information would be lost at engine restart or
238
+ # simply if the expression got swapped out of memory and reloaded later.
239
+ #
240
+ def store_itself
218
241
 
219
- #
220
- # Returns the parent expression (not as a FlowExpressionId but directly
221
- # as the FlowExpression instance it is).
222
- #
223
- def get_parent
242
+ ldebug { "store_itself() for #{@fei.to_debug_s}" }
243
+ #ldebug { "store_itself() \n#{OpenWFE::caller_to_s(0, 6)}" }
224
244
 
225
- get_expression_pool.fetch_expression @parent_id
226
- end
245
+ get_expression_pool.update self
246
+ end
227
247
 
228
- #
229
- # Stores itself in the expression pool.
230
- # It's very important for expressions in persisted context to save
231
- # themselves as soon as their state changed.
232
- # Else this information would be lost at engine restart or
233
- # simply if the expression got swapped out of memory and reloaded later.
234
- #
235
- def store_itself
248
+ #
249
+ # Returns the environment instance this expression uses.
250
+ # An environment is a container (a scope) for variables in the process
251
+ # definition.
252
+ # Environments themselves are FlowExpression instances.
253
+ #
254
+ def get_environment
236
255
 
237
- ldebug { "store_itself() for #{@fei.to_debug_s}" }
238
- #ldebug { "store_itself() \n#{OpenWFE::caller_to_s(0, 6)}" }
256
+ fetch_environment || get_expression_pool.fetch_engine_environment
257
+ end
239
258
 
240
- get_expression_pool.update self
241
- end
259
+ #
260
+ # A shortcut for fetch_environment.get_root_environment
261
+ #
262
+ # Returns the environment of the top process (the environement
263
+ # just before the engine environment in the hierarchy).
264
+ #
265
+ def get_root_environment
242
266
 
243
- #
244
- # Returns the environment instance this expression uses.
245
- # An environment is a container (a scope) for variables in the process
246
- # definition.
247
- # Environments themselves are FlowExpression instances.
248
- #
249
- def get_environment
267
+ fetch_environment.get_root_environment
268
+ end
250
269
 
251
- fetch_environment || get_expression_pool.fetch_engine_environment
252
- end
270
+ #
271
+ # Just fetches the environment for this expression.
272
+ #
273
+ def fetch_environment
253
274
 
254
- #
255
- # A shortcut for fetch_environment.get_root_environment
256
- #
257
- # Returns the environment of the top process (the environement
258
- # just before the engine environment in the hierarchy).
259
- #
260
- def get_root_environment
275
+ get_expression_pool.fetch_expression @environment_id
276
+ end
261
277
 
262
- fetch_environment.get_root_environment
263
- end
278
+ #
279
+ # Returns true if the expression's environment was generated
280
+ # for itself (usually DefineExpression do have such envs)
281
+ #
282
+ def owns_its_environment?
264
283
 
265
- #
266
- # Just fetches the environment for this expression.
267
- #
268
- def fetch_environment
284
+ #ldebug do
285
+ # "owns_its_environment?()\n" +
286
+ # " #{@fei.to_debug_s}\n" +
287
+ # " #{@environment_id.to_debug_s}"
288
+ #end
269
289
 
270
- get_expression_pool.fetch_expression @environment_id
271
- end
290
+ return false if not @environment_id
272
291
 
273
- #
274
- # Returns true if the expression's environment was generated
275
- # for itself (usually DefineExpression do have such envs)
276
- #
277
- def owns_its_environment?
292
+ ei = @fei.dup
293
+ vi = @environment_id.dup
278
294
 
279
- #ldebug do
280
- # "owns_its_environment?()\n" +
281
- # " #{@fei.to_debug_s}\n" +
282
- # " #{@environment_id.to_debug_s}"
283
- #end
295
+ ei.expression_name = "neutral"
296
+ vi.expression_name = "neutral"
284
297
 
285
- return false if not @environment_id
298
+ #ldebug do
299
+ # "owns_its_environment?()\n"+
300
+ # " exp #{ei.to_debug_s}\n"+
301
+ # " env #{vi.to_debug_s}"
302
+ #end
286
303
 
287
- ei = @fei.dup
288
- vi = @environment_id.dup
304
+ (ei == vi)
305
+ end
289
306
 
290
- ei.expression_name = "neutral"
291
- vi.expression_name = "neutral"
307
+ #
308
+ # Returns true if this expression belongs to a paused flow
309
+ #
310
+ def paused?
292
311
 
293
- #ldebug do
294
- # "owns_its_environment?()\n"+
295
- # " exp #{ei.to_debug_s}\n"+
296
- # " env #{vi.to_debug_s}"
297
- #end
312
+ #(lookup_variable(VAR_PAUSED) == true)
313
+ get_expression_pool.is_paused?(self)
314
+ end
298
315
 
299
- (ei == vi)
300
- end
316
+ #
317
+ # Sets a variable in the current environment. Is usually
318
+ # called by the 'set' expression.
319
+ #
320
+ # The variable name may be prefixed by / to indicate process level scope
321
+ # or by // to indicate engine level (global) scope.
322
+ #
323
+ def set_variable (varname, value)
301
324
 
302
- #
303
- # Returns true if this expression belongs to a paused flow
304
- #
305
- def paused?
325
+ env, var = lookup_environment varname
306
326
 
307
- #(lookup_variable(VAR_PAUSED) == true)
308
- get_expression_pool.is_paused?(self)
309
- end
327
+ ldebug do
328
+ "set_variable() '#{varname}' to '#{value}' " +
329
+ "in #{env.fei.to_debug_s}"
330
+ end
310
331
 
311
- #
312
- # Sets a variable in the current environment. Is usually
313
- # called by the 'set' expression.
314
- #
315
- # The variable name may be prefixed by / to indicate process level scope
316
- # or by // to indicate engine level (global) scope.
317
- #
318
- def set_variable (varname, value)
332
+ env[var] = value
333
+ end
319
334
 
320
- env, var = lookup_environment(varname)
335
+ alias :sv :set_variable
321
336
 
322
- ldebug do
323
- "set_variable() '#{varname}' to '#{value}' " +
324
- "in #{env.fei.to_debug_s}"
325
- end
337
+ #
338
+ # Looks up the value of a variable in the current environment.
339
+ # If not found locally will lookup at the process level and even
340
+ # further in the engine scope.
341
+ #
342
+ # The variable name may be prefixed by / to indicate process level scope
343
+ # or by // to indicate engine level (global) scope.
344
+ #
345
+ def lookup_variable (varname)
326
346
 
327
- env[var] = value
328
- end
347
+ env, var = lookup_environment varname
348
+ env[var]
349
+ end
329
350
 
330
- #
331
- # Looks up the value of a variable in the current environment.
332
- # If not found locally will lookup at the process level and even
333
- # further in the engine scope.
334
- #
335
- # The variable name may be prefixed by / to indicate process level scope
336
- # or by // to indicate engine level (global) scope.
337
- #
338
- def lookup_variable (varname)
351
+ alias :lv :lookup_variable
339
352
 
340
- #puts "lv : #{varname}"
341
- #puts OpenWFE.caller_to_s(0, 5)
353
+ #
354
+ # Unsets a variable in the current environment.
355
+ #
356
+ # The variable name may be prefixed by / to indicate process level scope
357
+ # or by // to indicate engine level (global) scope.
358
+ #
359
+ def delete_variable (varname)
342
360
 
343
- env, var = lookup_environment(varname)
344
- env[var]
345
- end
361
+ env, var = lookup_environment varname
362
+ env.delete var
363
+ end
346
364
 
347
- #
348
- # Unsets a variable in the current environment.
349
- #
350
- # The variable name may be prefixed by / to indicate process level scope
351
- # or by // to indicate engine level (global) scope.
352
- #
353
- def delete_variable (varname)
365
+ alias :unset_variable :delete_variable
354
366
 
355
- env, var = lookup_environment(varname)
356
- env.delete var
357
- end
367
+ #
368
+ # Looks up the value for an attribute of this expression.
369
+ #
370
+ # if the expression is
371
+ #
372
+ # <participant ref="toto" />
373
+ #
374
+ # then
375
+ #
376
+ # participant_expression.lookup_attribute("toto", wi)
377
+ #
378
+ # will yield "toto"
379
+ #
380
+ # The various methods for looking up attributes do perform dollar
381
+ # variable substitution.
382
+ # It's ok to pass a Symbol for the attribute name.
383
+ #
384
+ def lookup_attribute (attname, workitem, options={})
358
385
 
359
- alias :unset_variable :delete_variable
386
+ default = options[:default]
387
+ escape = options[:escape]
388
+ tostring = options[:to_s]
360
389
 
361
- #
362
- # Looks up the value for an attribute of this expression.
363
- #
364
- # if the expression is
365
- #
366
- # <participant ref="toto" />
367
- #
368
- # then
369
- #
370
- # participant_expression.lookup_attribute("toto", wi)
371
- #
372
- # will yield "toto"
373
- #
374
- # The various methods for looking up attributes do perform dollar
375
- # variable substitution.
376
- # It's ok to pass a Symbol for the attribute name.
377
- #
378
- def lookup_attribute (attname, workitem, options={})
390
+ attname = OpenWFE::symbol_to_name(attname) \
391
+ if attname.kind_of?(Symbol)
379
392
 
380
- default = options[:default]
381
- escape = options[:escape]
382
- tostring = options[:to_s]
393
+ #ldebug { "lookup_attribute() '#{attname}' in #{@fei.to_debug_s}" }
383
394
 
384
- attname = OpenWFE::symbol_to_name(attname) \
385
- if attname.kind_of?(Symbol)
395
+ text = @attributes[attname]
386
396
 
387
- #ldebug { "lookup_attribute() '#{attname}' in #{@fei.to_debug_s}" }
397
+ text = if text == nil
388
398
 
389
- text = @attributes[attname]
399
+ default
390
400
 
391
- text = if text == nil
401
+ elsif escape == true
392
402
 
393
- default
403
+ text
394
404
 
395
- elsif escape == true
405
+ else
396
406
 
397
- text
407
+ OpenWFE::dosub text, self, workitem
408
+ end
398
409
 
399
- else
410
+ text = text.to_s if text and tostring
400
411
 
401
- OpenWFE::dosub text, self, workitem
402
- end
412
+ text
413
+ end
403
414
 
404
- text = text.to_s if text and tostring
415
+ #
416
+ # Returns the attribute value as a String (or nil if it's not found).
417
+ #
418
+ def lookup_string_attribute (attname, workitem, options={})
405
419
 
406
- text
407
- end
420
+ result = lookup_attribute attname, workitem, options
421
+ result = result.to_s if result
422
+ result
423
+ end
408
424
 
409
- #
410
- # Returns the attribute value as a String (or nil if it's not found).
411
- #
412
- def lookup_string_attribute (attname, workitem, options={})
425
+ #
426
+ # Like lookup_attribute() but returns the value downcased [
427
+ # (and stripped).
428
+ # Returns nil if no such attribute was found.
429
+ #
430
+ def lookup_downcase_attribute (attname, workitem, options={})
413
431
 
414
- result = lookup_attribute attname, workitem, options
415
- result = result.to_s if result
416
- result
417
- end
432
+ result = lookup_string_attribute attname, workitem, options
433
+ result = result.strip.downcase if result
434
+ result
435
+ end
418
436
 
419
- #
420
- # Like lookup_attribute() but returns the value downcased [
421
- # (and stripped).
422
- # Returns nil if no such attribute was found.
423
- #
424
- def lookup_downcase_attribute (attname, workitem, options={})
437
+ #
438
+ # Returns the value of the attribute as a Symbol.
439
+ # Returns nil if there is no attribute under the given name.
440
+ #
441
+ def lookup_sym_attribute (attname, workitem, options={})
425
442
 
426
- result = lookup_string_attribute attname, workitem, options
427
- result = result.strip.downcase if result
428
- result
429
- end
443
+ result = lookup_downcase_attribute attname, workitem, options
444
+ result = result.to_sym if result
445
+ result
446
+ end
430
447
 
431
- #
432
- # Returns the value of the attribute as a Symbol.
433
- # Returns nil if there is no attribute under the given name.
434
- #
435
- def lookup_sym_attribute (attname, workitem, options={})
448
+ #
449
+ # A convenience method for looking up a boolean value.
450
+ # It's ok to pass a Symbol for the attribute name.
451
+ #
452
+ def lookup_boolean_attribute (attname, workitem, default=false)
436
453
 
437
- result = lookup_downcase_attribute attname, workitem, options
438
- result = result.to_sym if result
439
- result
440
- end
454
+ result = lookup_downcase_attribute attname, workitem
455
+ return default if result == nil
441
456
 
442
- #
443
- # A convenience method for looking up a boolean value.
444
- # It's ok to pass a Symbol for the attribute name.
445
- #
446
- def lookup_boolean_attribute (attname, workitem, default=false)
457
+ (result == 'true')
458
+ end
447
459
 
448
- result = lookup_downcase_attribute attname, workitem
449
- return default if result == nil
460
+ #
461
+ # looks up an attribute, if it's an array, returns it. Else
462
+ # (probably a string) will split it (comma) and return it
463
+ # (each element trimmed).
464
+ #
465
+ def lookup_array_attribute (attname, workitem, options={})
450
466
 
451
- (result == 'true')
452
- end
467
+ tostring = options.delete :to_s
453
468
 
454
- #
455
- # looks up an attribute, if it's an array, returns it. Else
456
- # (probably a string) will split it (comma) and return it
457
- # (each element trimmed).
458
- #
459
- def lookup_array_attribute (attname, workitem, options={})
469
+ v = lookup_attribute attname, workitem, options
460
470
 
461
- tostring = options.delete :to_s
471
+ return nil unless v
462
472
 
463
- v = lookup_attribute attname, workitem, options
473
+ v = v.to_s.split(",").collect { |e| e.strip } \
474
+ unless v.is_a?(Array)
464
475
 
465
- return nil unless v
476
+ v = v.collect { |e| e.to_s } \
477
+ if tostring
466
478
 
467
- v = v.to_s.split(",").collect { |e| e.strip } \
468
- unless v.is_a?(Array)
479
+ v
480
+ end
469
481
 
470
- v = v.collect { |e| e.to_s } \
471
- if tostring
482
+ #
483
+ # Returns true if the expression has the given attribute.
484
+ # The attname parameter can be a String or a Symbol.
485
+ #
486
+ def has_attribute (attname)
472
487
 
473
- v
474
- end
488
+ attname = OpenWFE::symbol_to_name(attname) \
489
+ if attname.kind_of?(Symbol)
475
490
 
476
- #
477
- # Returns true if the expression has the given attribute.
478
- # The attname parameter can be a String or a Symbol.
479
- #
480
- def has_attribute (attname)
491
+ (@attributes[attname] != nil)
492
+ end
481
493
 
482
- attname = OpenWFE::symbol_to_name(attname) \
483
- if attname.kind_of?(Symbol)
494
+ #
495
+ # Returns a hash of all the FlowExpression attributes with their
496
+ # values having undergone dollar variable substitution.
497
+ # If the _attributes parameter is set (to an Array instance) then
498
+ # only the attributes named in that list will be looked up.
499
+ #
500
+ # It's ok to pass an array of Symbol instances for the attributes
501
+ # parameter.
502
+ #
503
+ def lookup_attributes (workitem, _attributes=nil)
484
504
 
485
- (@attributes[attname] != nil)
486
- end
505
+ return {} unless @attributes
487
506
 
488
- #
489
- # Returns a hash of all the FlowExpression attributes with their
490
- # values having undergone dollar variable substitution.
491
- # If the _attributes parameter is set (to an Array instance) then
492
- # only the attributes named in that list will be looked up.
493
- #
494
- # It's ok to pass an array of Symbol instances for the attributes
495
- # parameter.
496
- #
497
- def lookup_attributes (workitem, _attributes=nil)
507
+ (_attributes || @attributes.keys).inject({}) do |r, k|
498
508
 
499
- return {} unless @attributes
509
+ k = k.to_s
510
+ v = @attributes[k]
500
511
 
501
- (_attributes || @attributes.keys).inject({}) do |r, k|
512
+ r[k] = OpenWFE::dosub v, self, workitem
502
513
 
503
- k = k.to_s
504
- v = @attributes[k]
514
+ r
515
+ end
516
+ end
505
517
 
506
- r[k] = OpenWFE::dosub v, self, workitem
518
+ #
519
+ # creates a new environment just for this expression
520
+ #
521
+ def new_environment (initial_vars=nil)
507
522
 
508
- r
509
- end
510
- end
523
+ ldebug { "new_environment() for #{@fei.to_debug_s}" }
511
524
 
512
- #
513
- # creates a new environment just for this expression
514
- #
515
- def new_environment (initial_vars=nil)
525
+ @environment_id = @fei.dup
526
+ @environment_id.expression_name = EN_ENVIRONMENT
516
527
 
517
- ldebug { "new_environment() for #{@fei.to_debug_s}" }
528
+ parent_fei = nil
529
+ parent = nil
518
530
 
519
- @environment_id = @fei.dup
520
- @environment_id.expression_name = EN_ENVIRONMENT
531
+ parent, _fei = get_expression_pool.fetch(@parent_id) \
532
+ if @parent_id
521
533
 
522
- parent_fei = nil
523
- parent = nil
534
+ parent_fei = parent.environment_id if parent
524
535
 
525
- parent, _fei = get_expression_pool.fetch(@parent_id) \
526
- if @parent_id
536
+ env = Environment.new_env(
537
+ @environment_id, parent_fei, nil, @application_context, nil)
527
538
 
528
- parent_fei = parent.environment_id if parent
539
+ env.variables.merge! initial_vars if initial_vars
529
540
 
530
- env = Environment.new_env(
531
- @environment_id, parent_fei, nil, @application_context, nil)
541
+ env[@fei.wfname] = self.raw_representation \
542
+ if (not @parent_id) and (self.is_a?(RawExpression))
543
+ #
544
+ # keeping track of the raw representation
545
+ # of the top expression (for top recursion)
532
546
 
533
- env.variables.merge! initial_vars if initial_vars
547
+ ldebug { "new_environment() is #{env.fei.to_debug_s}" }
534
548
 
535
- env[@fei.wfname] = self.raw_representation \
536
- if (not @parent_id) and (self.is_a?(RawExpression))
537
- #
538
- # keeping track of the raw representation
539
- # of the top expression (for top recursion)
549
+ env.store_itself
540
550
 
541
- ldebug { "new_environment() is #{env.fei.to_debug_s}" }
551
+ env
552
+ end
542
553
 
543
- env.store_itself
554
+ #
555
+ # This method is called in expressionpool.forget(). It duplicates
556
+ # the expression's current environment (deep copy) and attaches
557
+ # it as the expression own environment.
558
+ # Returns the duplicated environment.
559
+ #
560
+ def dup_environment
544
561
 
545
- env
546
- end
562
+ env = fetch_environment
563
+ env = env.dup
564
+ env.fei = @fei.dup
565
+ env.fei.expression_name = EN_ENVIRONMENT
566
+ @environment_id = env.fei
547
567
 
548
- #
549
- # This method is called in expressionpool.forget(). It duplicates
550
- # the expression's current environment (deep copy) and attaches
551
- # it as the expression own environment.
552
- # Returns the duplicated environment.
553
- #
554
- def dup_environment
568
+ env.store_itself
569
+ end
555
570
 
556
- env = fetch_environment
557
- env = env.dup
558
- env.fei = @fei.dup
559
- env.fei.expression_name = EN_ENVIRONMENT
560
- @environment_id = env.fei
571
+ #
572
+ # Takes care of removing all the children of this expression, if any.
573
+ #
574
+ def clean_children
561
575
 
562
- env.store_itself
563
- end
576
+ return unless @children
564
577
 
565
- #
566
- # Takes care of removing all the children of this expression, if any.
567
- #
568
- def clean_children
578
+ @children.each do |child_fei|
579
+ get_expression_pool.remove(child_fei) \
580
+ if child_fei.kind_of?(FlowExpressionId)
581
+ end
582
+ end
569
583
 
570
- return unless @children
584
+ #
585
+ # Removes a child from the expression children list.
586
+ #
587
+ def remove_child (child_fei)
571
588
 
572
- @children.each do |child_fei|
573
- get_expression_pool.remove(child_fei) \
574
- if child_fei.kind_of?(FlowExpressionId)
575
- end
576
- end
589
+ #fei = @children.delete child_fei
590
+ #store_itself if fei
577
591
 
578
- #
579
- # Removes a child from the expression children list.
580
- #
581
- def remove_child (child_fei)
592
+ i = @children.index child_fei
582
593
 
583
- #fei = @children.delete child_fei
584
- #store_itself if fei
594
+ return unless i
585
595
 
586
- i = @children.index child_fei
596
+ @children.delete_at i
597
+ raw_children.delete_at i
598
+ @raw_rep_updated = true
587
599
 
588
- return unless i
600
+ store_itself
601
+ end
589
602
 
590
- @children.delete_at i
591
- raw_children.delete_at i
592
- @raw_rep_updated = true
603
+ #
604
+ # Currently only used by dollar.rb and its ${r:some_ruby_code},
605
+ # returns the binding in this flow expression.
606
+ #
607
+ def get_binding
593
608
 
594
- store_itself
595
- end
609
+ binding()
610
+ end
596
611
 
597
- #
598
- # Currently only used by dollar.rb and its ${r:some_ruby_code},
599
- # returns the binding in this flow expression.
600
- #
601
- def get_binding
612
+ #--
613
+ # Used like the classical Ruby synchronize, but as the OpenWFE
614
+ # expression pool manages its own set of monitors, it's one of those
615
+ # monitors that is used. But the synchronize code looks like the class
616
+ # just included the MonitorMixin. No hassle.
617
+ #
618
+ #def synchronize
619
+ # #ldebug { "synchronize() ---in--- for #{@fei.to_debug_s}" }
620
+ # get_expression_pool.get_monitor(@fei).synchronize do
621
+ # yield
622
+ # end
623
+ # #ldebug { "synchronize() --out-- for #{@fei.to_debug_s}" }
624
+ #end
625
+ #++
602
626
 
603
- binding()
604
- end
627
+ #
628
+ # Returns the text stored among the children
629
+ #
630
+ def fetch_text_content (workitem, escape=false)
605
631
 
606
- #--
607
- # Used like the classical Ruby synchronize, but as the OpenWFE
608
- # expression pool manages its own set of monitors, it's one of those
609
- # monitors that is used. But the synchronize code looks like the class
610
- # just included the MonitorMixin. No hassle.
611
- #
612
- #def synchronize
613
- # #ldebug { "synchronize() ---in--- for #{@fei.to_debug_s}" }
614
- # get_expression_pool.get_monitor(@fei).synchronize do
615
- # yield
616
- # end
617
- # #ldebug { "synchronize() --out-- for #{@fei.to_debug_s}" }
618
- #end
619
- #++
632
+ cs = children || raw_children
620
633
 
621
- #
622
- # Returns the text stored as the children of the given expression
623
- #
624
- def fetch_text_content (workitem, escape=false)
634
+ text = cs.inject("") do |r, child|
625
635
 
626
- text = ""
636
+ if child.is_a?(RawExpression)
627
637
 
628
- children.each do |child|
638
+ r << child.fei.to_s
629
639
 
630
- if child.is_a?(RawExpression)
640
+ elsif child.is_a?(FlowExpressionId)
631
641
 
632
- text << child.fei.to_s
642
+ r << get_expression_pool\
643
+ .fetch_expression(child).raw_representation.to_s
633
644
 
634
- elsif child.is_a?(FlowExpressionId)
645
+ else
635
646
 
636
- text << get_expression_pool\
637
- .fetch_expression(child).raw_representation.to_s
647
+ r << child.to_s
648
+ end
649
+ end
638
650
 
639
- else
651
+ return nil if text == ""
640
652
 
641
- text << child.to_s
642
- end
643
- end
653
+ text = OpenWFE::dosub(text, self, workitem) \
654
+ unless escape
644
655
 
645
- return nil if text == ""
656
+ text
657
+ end
646
658
 
647
- text = OpenWFE::dosub(text, self, workitem) \
648
- unless escape
659
+ #
660
+ # looks up for 'value', 'variable-value' and then for 'field-value'
661
+ # if necessary.
662
+ #
663
+ def lookup_value (workitem, options={})
649
664
 
650
- text
651
- end
665
+ lookup_vf_attribute(workitem, 'value', options) ||
666
+ lookup_vf_attribute(workitem, 'val', options)
667
+ end
652
668
 
653
- #
654
- # looks up for 'value', 'variable-value' and then for 'field-value'
655
- # if necessary.
656
- #
657
- def lookup_value (workitem, options={})
669
+ #
670
+ # looks up for 'ref', 'variable-ref' and then for 'field-ref'
671
+ # if necessary.
672
+ #
673
+ def lookup_ref (workitem, prefix='')
658
674
 
659
- lookup_vf_attribute(workitem, 'value', options) ||
660
- lookup_vf_attribute(workitem, 'val', options)
661
- end
675
+ ref = lookup_vf_attribute workitem, 'ref', :prefix => prefix
676
+ return ref.to_s if ref
677
+ nil
678
+ end
662
679
 
663
- #
664
- # looks up for 'ref', 'variable-ref' and then for 'field-ref'
665
- # if necessary.
666
- #
667
- def lookup_ref (workitem, prefix='')
680
+ #
681
+ # Looks up for value attributes like 'field-ref' or 'variable-value'
682
+ #
683
+ def lookup_vf_attribute (workitem, att_name, options={})
668
684
 
669
- ref = lookup_vf_attribute workitem, 'ref', :prefix => prefix
670
- return ref.to_s if ref
671
- nil
672
- end
685
+ att_name = att_name.to_s
673
686
 
674
- #
675
- # Looks up for value attributes like 'field-ref' or 'variable-value'
676
- #
677
- def lookup_vf_attribute (workitem, att_name, options={})
687
+ prefix = options[:prefix] || ''
688
+ prefix = prefix.to_s
678
689
 
679
- att_name = att_name.to_s
690
+ dash = (att_name.size > 0 and prefix.size > 0) ? "-" : ""
680
691
 
681
- prefix = options[:prefix] || ''
682
- prefix = prefix.to_s
692
+ v = lookup_attribute(
693
+ "#{prefix}#{dash}#{att_name}", workitem, options)
683
694
 
684
- dash = (att_name.size > 0 and prefix.size > 0) ? "-" : ""
695
+ att_name = "-#{att_name}" if att_name.size > 0
696
+ prefix = "#{prefix}-" if prefix.size > 0
685
697
 
686
- v = lookup_attribute(
687
- "#{prefix}#{dash}#{att_name}", workitem, options)
698
+ return v if v
688
699
 
689
- att_name = "-#{att_name}" if att_name.size > 0
690
- prefix = "#{prefix}-" if prefix.size > 0
700
+ v = lookup_attribute(
701
+ "#{prefix}variable#{att_name}", workitem, options) ||
702
+ lookup_attribute(
703
+ "#{prefix}var#{att_name}", workitem, options) ||
704
+ lookup_attribute(
705
+ "#{prefix}v#{att_name}", workitem, options)
691
706
 
692
- return v if v
707
+ return lookup_variable(v) if v
693
708
 
694
- v = lookup_attribute(
695
- "#{prefix}variable#{att_name}", workitem, options) ||
696
- lookup_attribute(
697
- "#{prefix}var#{att_name}", workitem, options) ||
698
- lookup_attribute(
699
- "#{prefix}v#{att_name}", workitem, options)
709
+ f = lookup_attribute(
710
+ "#{prefix}field#{att_name}", workitem, options) ||
711
+ lookup_attribute(
712
+ "#{prefix}f#{att_name}", workitem, options)
700
713
 
701
- return lookup_variable(v) if v
714
+ #return workitem.attributes[f] if f
715
+ return workitem.attributes[f.to_s] if f
702
716
 
703
- f = lookup_attribute(
704
- "#{prefix}field#{att_name}", workitem, options) ||
705
- lookup_attribute(
706
- "#{prefix}f#{att_name}", workitem, options)
717
+ nil
718
+ end
707
719
 
708
- #return workitem.attributes[f] if f
709
- return workitem.attributes[f.to_s] if f
720
+ #
721
+ # Since OpenWFEru 0.9.17, each expression keeps his @raw_representation
722
+ # this is a shortcut for exp.raw_representation[2]
723
+ #
724
+ def raw_children
710
725
 
711
- nil
712
- end
726
+ @raw_representation[2]
727
+ end
713
728
 
714
- #
715
- # Since OpenWFEru 0.9.17, each expression keeps his @raw_representation
716
- # this is a shortcut for exp.raw_representation[2]
717
- #
718
- def raw_children
729
+ SUBIDMUTEX = Mutex.new
719
730
 
720
- @raw_representation[2]
721
- end
731
+ #
732
+ # Returns the next sub process id available (this counter
733
+ # is stored in the process environment under the key :next_sub_id)
734
+ #
735
+ def get_next_sub_id
722
736
 
723
- SUBIDMUTEX = Mutex.new
737
+ #env = get_environment
738
+ env = get_root_environment
724
739
 
725
- #
726
- # Returns the next sub process id available (this counter
727
- # is stored in the process environment under the key :next_sub_id)
728
- #
729
- def get_next_sub_id
740
+ c = nil
730
741
 
731
- #env = get_environment
732
- env = get_root_environment
742
+ #env.synchronize do
733
743
 
734
- c = nil
744
+ c = env.variables[:next_sub_id]
745
+ n = if c
746
+ c + 1
747
+ else
748
+ c = 0
749
+ 1
750
+ end
751
+ env.variables[:next_sub_id] = n
752
+ env.store_itself
753
+ #end
735
754
 
736
- #env.synchronize do
755
+ c
756
+ end
737
757
 
738
- c = env.variables[:next_sub_id]
739
- n = if c
740
- c + 1
741
- else
742
- c = 0
743
- 1
744
- end
745
- env.variables[:next_sub_id] = n
746
- env.store_itself
747
- #end
758
+ #
759
+ # Some eye candy
760
+ #
761
+ def to_s
748
762
 
749
- c
750
- end
763
+ s = "* #{@fei.to_debug_s} [#{self.class.name}]"
751
764
 
752
- #
753
- # Some eye candy
754
- #
755
- def to_s
765
+ s << "\n `--p--> #{@parent_id.to_debug_s}" \
766
+ if @parent_id
756
767
 
757
- s = "* #{@fei.to_debug_s} [#{self.class.name}]"
768
+ s << "\n `--e--> #{@environment_id.to_debug_s}" \
769
+ if @environment_id
758
770
 
759
- s << "\n `--p--> #{@parent_id.to_debug_s}" \
760
- if @parent_id
771
+ return s unless @children
761
772
 
762
- s << "\n `--e--> #{@environment_id.to_debug_s}" \
763
- if @environment_id
773
+ @children.each do |c|
774
+ sc = if c.kind_of?(OpenWFE::FlowExpressionId)
775
+ c.to_debug_s
776
+ else
777
+ ">#{c.to_s}<"
778
+ end
779
+ s << "\n `--c--> #{sc}"
780
+ end
764
781
 
765
- return s unless @children
782
+ s
783
+ end
766
784
 
767
- @children.each do |c|
768
- sc = if c.kind_of?(OpenWFE::FlowExpressionId)
769
- c.to_debug_s
770
- else
771
- ">#{c.to_s}<"
772
- end
773
- s << "\n `--c--> #{sc}"
774
- end
785
+ #
786
+ # a nice 'names' tag/method for registering the names of the
787
+ # Expression classes.
788
+ #
789
+ def self.names (*exp_names)
790
+
791
+ exp_names = exp_names.collect do |n|
792
+ n.to_s
793
+ end
794
+ meta_def :expression_names do
795
+ exp_names
796
+ end
797
+ end
775
798
 
776
- s
777
- end
799
+ #
800
+ # returns true if the expression class is a 'definition'.
801
+ #
802
+ def self.is_definition?
803
+ false
804
+ end
805
+ def self.is_definition
806
+ meta_def :is_definition? do
807
+ true
808
+ end
809
+ end
778
810
 
779
- #
780
- # a nice 'names' tag/method for registering the names of the
781
- # Expression classes.
782
- #
783
- def self.names (*exp_names)
784
-
785
- exp_names = exp_names.collect do |n|
786
- n.to_s
787
- end
788
- meta_def :expression_names do
789
- exp_names
790
- end
791
- end
811
+ #
812
+ # returns true if the expression class 'uses a template'
813
+ # (children will not immediately get expanded at 'parse' time)
814
+ #
815
+ def self.uses_template?
816
+ false
817
+ end
818
+ def self.uses_template
819
+ meta_def :uses_template? do
820
+ true
821
+ end
822
+ end
792
823
 
793
- #
794
- # returns true if the expression class is a 'definition'.
795
- #
796
- def self.is_definition?
797
- false
798
- end
799
- def self.is_definition
800
- meta_def :is_definition? do
801
- true
802
- end
803
- end
824
+ protected
804
825
 
805
- #
806
- # returns true if the expression class 'uses a template'
807
- # (children will not immediately get expanded at 'parse' time)
808
- #
809
- def self.uses_template?
810
- false
826
+ #
827
+ # If the varname starts with '//' will return the engine
828
+ # environment and the truncated varname...
829
+ # If the varname starts with '/' will return the root environment
830
+ # for the current process instance and the truncated varname...
831
+ #
832
+ def lookup_environment (varname)
833
+
834
+ if varname[0, 2] == '//'
835
+ return [
836
+ get_expression_pool.fetch_engine_environment,
837
+ varname[2..-1]
838
+ ]
811
839
  end
812
- def self.uses_template
813
- meta_def :uses_template? do
814
- true
815
- end
840
+
841
+ if varname[0, 1] == '/'
842
+ return [
843
+ get_environment.get_root_environment,
844
+ varname[1..-1]
845
+ ]
816
846
  end
817
847
 
818
- protected
819
-
820
- #
821
- # If the varname starts with '//' will return the engine
822
- # environment and the truncated varname...
823
- # If the varname starts with '/' will return the root environment
824
- # for the current process instance and the truncated varname...
825
- #
826
- def lookup_environment (varname)
827
-
828
- if varname[0, 2] == '//'
829
- return [
830
- get_expression_pool.fetch_engine_environment,
831
- varname[2..-1]
832
- ]
833
- end
834
-
835
- if varname[0, 1] == '/'
836
- return [
837
- get_environment.get_root_environment,
838
- varname[1..-1]
839
- ]
840
- end
841
-
842
- [ get_environment, varname ]
843
- end
844
- end
848
+ [ get_environment, varname ]
849
+ end
850
+ end
845
851
 
846
852
  end
847
853