ruote 0.9.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. data/README.txt +24 -0
  2. data/bin/validate-workflow.rb +89 -0
  3. data/examples/about_state.rb +81 -0
  4. data/examples/bigflow.rb +19 -0
  5. data/examples/csv_weather.rb +23 -0
  6. data/examples/engine_template.rb +247 -0
  7. data/examples/flowtracing.rb +24 -0
  8. data/examples/homeworkreview.rb +68 -0
  9. data/examples/kotoba.rb +22 -0
  10. data/examples/mano_tracker.rb +172 -0
  11. data/examples/openwferu.rb +58 -0
  12. data/examples/quotereporter.rb +157 -0
  13. data/examples/scheduler_cron_usage.rb +48 -0
  14. data/examples/scheduler_usage.rb +56 -0
  15. data/lib/openwfe.rb +41 -0
  16. data/lib/openwfe/contextual.rb +111 -0
  17. data/lib/openwfe/def.rb +46 -0
  18. data/lib/openwfe/engine.rb +37 -0
  19. data/lib/openwfe/engine/engine.rb +756 -0
  20. data/lib/openwfe/engine/expool_methods.rb +172 -0
  21. data/lib/openwfe/engine/file_persisted_engine.rb +105 -0
  22. data/lib/openwfe/engine/participant_methods.rb +133 -0
  23. data/lib/openwfe/engine/status_methods.rb +353 -0
  24. data/lib/openwfe/engine/update_exp_methods.rb +112 -0
  25. data/lib/openwfe/exceptions.rb +51 -0
  26. data/lib/openwfe/expool/errorjournal.rb +476 -0
  27. data/lib/openwfe/expool/expressionpool.rb +1144 -0
  28. data/lib/openwfe/expool/expstorage.rb +403 -0
  29. data/lib/openwfe/expool/history.rb +174 -0
  30. data/lib/openwfe/expool/journal.rb +224 -0
  31. data/lib/openwfe/expool/journal_replay.rb +321 -0
  32. data/lib/openwfe/expool/parser.rb +242 -0
  33. data/lib/openwfe/expool/representation.rb +121 -0
  34. data/lib/openwfe/expool/threadedexpstorage.rb +188 -0
  35. data/lib/openwfe/expool/wfidgen.rb +388 -0
  36. data/lib/openwfe/expool/yamlexpstorage.rb +224 -0
  37. data/lib/openwfe/expressions/condition.rb +244 -0
  38. data/lib/openwfe/expressions/environment.rb +246 -0
  39. data/lib/openwfe/expressions/expressionmap.rb +258 -0
  40. data/lib/openwfe/expressions/fe_cancel.rb +109 -0
  41. data/lib/openwfe/expressions/fe_command.rb +241 -0
  42. data/lib/openwfe/expressions/fe_concurrence.rb +662 -0
  43. data/lib/openwfe/expressions/fe_cron.rb +259 -0
  44. data/lib/openwfe/expressions/fe_cursor.rb +259 -0
  45. data/lib/openwfe/expressions/fe_define.rb +192 -0
  46. data/lib/openwfe/expressions/fe_do.rb +168 -0
  47. data/lib/openwfe/expressions/fe_equals.rb +291 -0
  48. data/lib/openwfe/expressions/fe_filter.rb +129 -0
  49. data/lib/openwfe/expressions/fe_filter_definition.rb +168 -0
  50. data/lib/openwfe/expressions/fe_fqv.rb +250 -0
  51. data/lib/openwfe/expressions/fe_if.rb +303 -0
  52. data/lib/openwfe/expressions/fe_iterator.rb +145 -0
  53. data/lib/openwfe/expressions/fe_listen.rb +371 -0
  54. data/lib/openwfe/expressions/fe_losfor.rb +111 -0
  55. data/lib/openwfe/expressions/fe_misc.rb +421 -0
  56. data/lib/openwfe/expressions/fe_participant.rb +269 -0
  57. data/lib/openwfe/expressions/fe_reserve.rb +212 -0
  58. data/lib/openwfe/expressions/fe_save.rb +274 -0
  59. data/lib/openwfe/expressions/fe_sequence.rb +117 -0
  60. data/lib/openwfe/expressions/fe_set.rb +139 -0
  61. data/lib/openwfe/expressions/fe_sleep.rb +166 -0
  62. data/lib/openwfe/expressions/fe_step.rb +159 -0
  63. data/lib/openwfe/expressions/fe_subprocess.rb +168 -0
  64. data/lib/openwfe/expressions/fe_timeout.rb +127 -0
  65. data/lib/openwfe/expressions/fe_wait.rb +78 -0
  66. data/lib/openwfe/expressions/fe_when.rb +142 -0
  67. data/lib/openwfe/expressions/filter.rb +104 -0
  68. data/lib/openwfe/expressions/flowexpression.rb +847 -0
  69. data/lib/openwfe/expressions/iterator.rb +221 -0
  70. data/lib/openwfe/expressions/merge.rb +84 -0
  71. data/lib/openwfe/expressions/raw.rb +547 -0
  72. data/lib/openwfe/expressions/rprocdef.rb +375 -0
  73. data/lib/openwfe/expressions/time.rb +333 -0
  74. data/lib/openwfe/expressions/timeout.rb +178 -0
  75. data/lib/openwfe/expressions/value.rb +126 -0
  76. data/lib/openwfe/filterdef.rb +259 -0
  77. data/lib/openwfe/flowexpressionid.rb +357 -0
  78. data/lib/openwfe/listeners/listener.rb +97 -0
  79. data/lib/openwfe/listeners/listeners.rb +139 -0
  80. data/lib/openwfe/listeners/socketlisteners.rb +272 -0
  81. data/lib/openwfe/logging.rb +122 -0
  82. data/lib/openwfe/omixins.rb +95 -0
  83. data/lib/openwfe/orest/controlclient.rb +119 -0
  84. data/lib/openwfe/orest/definitions.rb +113 -0
  85. data/lib/openwfe/orest/exception.rb +60 -0
  86. data/lib/openwfe/orest/oldrestservlet.rb +279 -0
  87. data/lib/openwfe/orest/osocket.rb +148 -0
  88. data/lib/openwfe/orest/restclient.rb +176 -0
  89. data/lib/openwfe/orest/workitem.rb +206 -0
  90. data/lib/openwfe/orest/worklistclient.rb +272 -0
  91. data/lib/openwfe/orest/xmlcodec.rb +670 -0
  92. data/lib/openwfe/participants.rb +38 -0
  93. data/lib/openwfe/participants/enoparticipants.rb +230 -0
  94. data/lib/openwfe/participants/participant.rb +141 -0
  95. data/lib/openwfe/participants/participantmap.rb +249 -0
  96. data/lib/openwfe/participants/participants.rb +407 -0
  97. data/lib/openwfe/participants/soapparticipants.rb +135 -0
  98. data/lib/openwfe/participants/socketparticipants.rb +202 -0
  99. data/lib/openwfe/participants/storeparticipants.rb +254 -0
  100. data/lib/openwfe/rudefinitions.rb +130 -0
  101. data/lib/openwfe/service.rb +103 -0
  102. data/lib/openwfe/storage/yamlcustom.rb +106 -0
  103. data/lib/openwfe/storage/yamlfilestorage.rb +245 -0
  104. data/lib/openwfe/tools/flowtracer.rb +81 -0
  105. data/lib/openwfe/util/dollar.rb +217 -0
  106. data/lib/openwfe/util/irb.rb +86 -0
  107. data/lib/openwfe/util/observable.rb +144 -0
  108. data/lib/openwfe/util/ometa.rb +62 -0
  109. data/lib/openwfe/util/workqueue.rb +124 -0
  110. data/lib/openwfe/util/xml.rb +418 -0
  111. data/lib/openwfe/utils.rb +554 -0
  112. data/lib/openwfe/version.rb +37 -0
  113. data/lib/openwfe/workitem.rb +499 -0
  114. data/lib/openwfe/worklist/oldrest.rb +244 -0
  115. data/lib/openwfe/worklist/storelocks.rb +293 -0
  116. data/lib/openwfe/worklist/storeparticipant.rb +44 -0
  117. data/lib/openwfe/worklist/worklist.rb +297 -0
  118. data/test/README.txt +27 -0
  119. data/test/back_0916_test.rb +111 -0
  120. data/test/bm/bm_1_xml_vs_prog.rb +56 -0
  121. data/test/bm/bm_2_step.rb +109 -0
  122. data/test/bm/ft_0f_5ms.rb +35 -0
  123. data/test/bm/ft_26_load.rb +210 -0
  124. data/test/bm/ft_26b_load.rb +86 -0
  125. data/test/bm/ft_26c_load.rb +97 -0
  126. data/test/bm/ft_26d_load.rb +97 -0
  127. data/test/bm/ft_recu.rb +71 -0
  128. data/test/clone_test.rb +122 -0
  129. data/test/concurrence_test.rb +77 -0
  130. data/test/condition_test.rb +155 -0
  131. data/test/console_test.rb +12 -0
  132. data/test/cron_ltest.rb +15 -0
  133. data/test/description_test.rb +87 -0
  134. data/test/eno_test.rb +76 -0
  135. data/test/expmap_test.rb +54 -0
  136. data/test/expool_20031219_0916.tgz +0 -0
  137. data/test/fe_lookup_att_test.rb +62 -0
  138. data/test/fei_test.rb +181 -0
  139. data/test/file_persisted_engine_test.rb +64 -0
  140. data/test/file_persistence_test.rb +134 -0
  141. data/test/filep_cancel_test.rb +123 -0
  142. data/test/filter_test.rb +109 -0
  143. data/test/flowtestbase.rb +351 -0
  144. data/test/ft_0.rb +68 -0
  145. data/test/ft_0b_sequence.rb +36 -0
  146. data/test/ft_0c_testname.rb +33 -0
  147. data/test/ft_0d_participant.rb +30 -0
  148. data/test/ft_0e_multibody.rb +34 -0
  149. data/test/ft_10_loop.rb +134 -0
  150. data/test/ft_11_ppd.rb +415 -0
  151. data/test/ft_11b_ppd.rb +54 -0
  152. data/test/ft_12_blockparticipant.rb +97 -0
  153. data/test/ft_13_eno.rb +52 -0
  154. data/test/ft_14_subprocess.rb +88 -0
  155. data/test/ft_14b_subprocess.rb +192 -0
  156. data/test/ft_14c_subprocess.rb +68 -0
  157. data/test/ft_15_iterator.rb +216 -0
  158. data/test/ft_15b_iterator.rb +74 -0
  159. data/test/ft_16_fqv.rb +73 -0
  160. data/test/ft_17_condition.rb +84 -0
  161. data/test/ft_18_pname.rb +56 -0
  162. data/test/ft_1_unset.rb +175 -0
  163. data/test/ft_1b_unset.rb +39 -0
  164. data/test/ft_20_cron.rb +53 -0
  165. data/test/ft_21_cron.rb +87 -0
  166. data/test/ft_21b_cron_pause.rb +82 -0
  167. data/test/ft_22_history.rb +74 -0
  168. data/test/ft_23_when.rb +77 -0
  169. data/test/ft_23b_when.rb +70 -0
  170. data/test/ft_23c_wait.rb +80 -0
  171. data/test/ft_23d_cww.rb +58 -0
  172. data/test/ft_24_def.rb +44 -0
  173. data/test/ft_25_cancel.rb +89 -0
  174. data/test/ft_27_getflowpos.rb +147 -0
  175. data/test/ft_28_fileparticipant.rb +63 -0
  176. data/test/ft_29_httprb.rb +106 -0
  177. data/test/ft_2_concurrence.rb +135 -0
  178. data/test/ft_2b_concurrence.rb +188 -0
  179. data/test/ft_2c_concurrence.rb +64 -0
  180. data/test/ft_30_socketlistener.rb +203 -0
  181. data/test/ft_31_flowname.rb +40 -0
  182. data/test/ft_32_journal.rb +91 -0
  183. data/test/ft_32c_journal.rb +102 -0
  184. data/test/ft_32d_journal.rb +84 -0
  185. data/test/ft_33_description.rb +107 -0
  186. data/test/ft_34_cancelwfid.rb +80 -0
  187. data/test/ft_35_localdefs.rb +75 -0
  188. data/test/ft_36_subprocids.rb +97 -0
  189. data/test/ft_37_pnames.rb +70 -0
  190. data/test/ft_38_tag.rb +127 -0
  191. data/test/ft_38b_tag.rb +161 -0
  192. data/test/ft_38c_tag.rb +100 -0
  193. data/test/ft_39_reserve.rb +63 -0
  194. data/test/ft_39b_reserve.rb +84 -0
  195. data/test/ft_3_equals.rb +170 -0
  196. data/test/ft_3b_lookup_vf.rb +83 -0
  197. data/test/ft_40_defined.rb +61 -0
  198. data/test/ft_41_case.rb +110 -0
  199. data/test/ft_42_environments.rb +75 -0
  200. data/test/ft_43_pat10.rb +85 -0
  201. data/test/ft_44_save.rb +70 -0
  202. data/test/ft_44b_restore.rb +212 -0
  203. data/test/ft_45_citerator.rb +214 -0
  204. data/test/ft_46_pparams.rb +62 -0
  205. data/test/ft_47_filter.rb +160 -0
  206. data/test/ft_48_fe_filter.rb +88 -0
  207. data/test/ft_49_condition.rb +126 -0
  208. data/test/ft_4_misc.rb +237 -0
  209. data/test/ft_50_xml_attribute.rb +155 -0
  210. data/test/ft_51_stack.rb +55 -0
  211. data/test/ft_52_obs_participant.rb +123 -0
  212. data/test/ft_53_null_noop_participant.rb +62 -0
  213. data/test/ft_54_listen.rb +288 -0
  214. data/test/ft_54b_listen.rb +66 -0
  215. data/test/ft_54c_listen.rb +99 -0
  216. data/test/ft_55_ptimeout.rb +59 -0
  217. data/test/ft_56_timeout.rb +59 -0
  218. data/test/ft_57_a.rb +145 -0
  219. data/test/ft_58_ejournal.rb +151 -0
  220. data/test/ft_59_ps.rb +150 -0
  221. data/test/ft_59b_ps_for_pat.rb +58 -0
  222. data/test/ft_5_time.rb +118 -0
  223. data/test/ft_60_ecancel.rb +161 -0
  224. data/test/ft_61_elsub.rb +51 -0
  225. data/test/ft_62_procparticipant.rb +71 -0
  226. data/test/ft_63_pause.rb +124 -0
  227. data/test/ft_64_alias.rb +102 -0
  228. data/test/ft_64_clone.rb +69 -0
  229. data/test/ft_65_stringlaunch.rb +59 -0
  230. data/test/ft_66_subforget.rb +70 -0
  231. data/test/ft_67_schedlaunch.rb +116 -0
  232. data/test/ft_68_ifparticipant.rb +70 -0
  233. data/test/ft_69_cancelmissing.rb +51 -0
  234. data/test/ft_6_lambda.rb +64 -0
  235. data/test/ft_70_lookupvar.rb +55 -0
  236. data/test/ft_71_log.rb +60 -0
  237. data/test/ft_72_lookup_processes.rb +76 -0
  238. data/test/ft_73_cancel_sub.rb +139 -0
  239. data/test/ft_74_block_and_workitem_dup.rb +63 -0
  240. data/test/ft_75_ruby_attributes.rb +87 -0
  241. data/test/ft_76_merge_isolate.rb +88 -0
  242. data/test/ft_77_segments.rb +35 -0
  243. data/test/ft_78_eval.rb +150 -0
  244. data/test/ft_79_tticket.rb +187 -0
  245. data/test/ft_79b_tticket.rb +172 -0
  246. data/test/ft_79c_outcome.rb +56 -0
  247. data/test/ft_7_lose.rb +104 -0
  248. data/test/ft_7b_lose.rb +78 -0
  249. data/test/ft_80_spname.rb +91 -0
  250. data/test/ft_81_exp.rb +60 -0
  251. data/test/ft_82_trecu.rb +46 -0
  252. data/test/ft_83_badpause.rb +58 -0
  253. data/test/ft_84_updateexp.rb +198 -0
  254. data/test/ft_85_dolhash.rb +43 -0
  255. data/test/ft_86_dollar_fv.rb +68 -0
  256. data/test/ft_87_define.rb +74 -0
  257. data/test/ft_8_forget.rb +44 -0
  258. data/test/ft_9_cursor.rb +145 -0
  259. data/test/ft_9b_cursor.rb +105 -0
  260. data/test/ft_tests.rb +124 -0
  261. data/test/hash_test.rb +75 -0
  262. data/test/hparticipant_test.rb +164 -0
  263. data/test/lookup_att_test.rb +90 -0
  264. data/test/lookup_vf_test.rb +94 -0
  265. data/test/misc_test.rb +90 -0
  266. data/test/nut_0_irb.rb +20 -0
  267. data/test/obs_test.rb +142 -0
  268. data/test/orest_test.rb +251 -0
  269. data/test/param_test.rb +290 -0
  270. data/test/participant_test.rb +101 -0
  271. data/test/pending.rb +23 -0
  272. data/test/ps_representation.rb +133 -0
  273. data/test/rake_ltest.rb +38 -0
  274. data/test/rake_qtest.rb +68 -0
  275. data/test/raw_prog_test.rb +412 -0
  276. data/test/restart_cron_test.rb +136 -0
  277. data/test/restart_paused_test.rb +98 -0
  278. data/test/restart_sleep_test.rb +140 -0
  279. data/test/restart_tests.rb +18 -0
  280. data/test/restart_when_test.rb +112 -0
  281. data/test/ruby_procdef_test.rb +132 -0
  282. data/test/rutest_utils.rb +63 -0
  283. data/test/sec_test.rb +205 -0
  284. data/test/slock_test.rb +80 -0
  285. data/test/storage_test.rb +44 -0
  286. data/test/test.rb +3 -0
  287. data/test/timeout_test.rb +105 -0
  288. data/test/util_xml_test.rb +112 -0
  289. data/test/wfid_test.rb +175 -0
  290. data/test/wi_test.rb +75 -0
  291. metadata +433 -0
data/README.txt ADDED
@@ -0,0 +1,24 @@
1
+ = OpenWFEru
2
+
3
+ == Overview
4
+
5
+ OpenWFEru is an open source workflow and BPM engine written in Ruby.
6
+
7
+ "Ruote" is the nickname of the engine/system, as "OpenWFEru" is quite hard to spell.
8
+
9
+ The quickstart is at : http://openwferu.rubyforge.org/quickstart.html
10
+
11
+
12
+ == Links
13
+
14
+ http://openwferu.rubyforge.org
15
+ http://rubyforge.org/projects/openwferu
16
+
17
+
18
+ == feedback
19
+
20
+ user mailing list : http://groups.google.com/group/openwferu-users
21
+ developers mailing list : http://groups.google.com/group/openwferu-dev
22
+
23
+ issue tracker : http://rubyforge.org/tracker/?atid=10023&group_id=2609&func=browse
24
+
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Program Name: validate-workflow.rb
4
+ # Purpose: A helper script that validates a workflow document against
5
+ # a XML Schema
6
+ # Author: Alain Hoang
7
+ # Notes: Uses Ruby's libxml library to handle the parsing
8
+
9
+ # Stdlib
10
+ require 'net/http'
11
+ require 'optparse'
12
+ require 'uri'
13
+
14
+ # From the gems archive
15
+ require 'rubygems'
16
+ require 'xml/libxml'
17
+
18
+
19
+ module OpenWFEru
20
+ FLOWDEF_URL = 'http://www.openwfe.org/flowdef.xsd'
21
+ # Validates a workflow definition against the Workflow XML Schema
22
+ # defined at http://www.openwfe.org/flowdef.xsd
23
+ class WorkflowValidator
24
+
25
+ attr_accessor :schema_url
26
+ attr_accessor :args
27
+
28
+ # Create a validator object using a WorkflowValidatorArgs object
29
+ def initialize(args)
30
+ @args = args
31
+ @args[:schema_url] ||= FLOWDEF_URL
32
+
33
+ xsd_str = Net::HTTP.get URI.parse(@args[:schema_url])
34
+ @schema = XML::Schema.from_string(xsd_str)
35
+ end
36
+
37
+ # validates a xml file against the OpenWFE XML Schema
38
+ def validate(file)
39
+ xmldoc = XML::Document.file(file)
40
+ xmldoc.validate_schema(@schema)
41
+ end
42
+ end
43
+
44
+ class WorkflowValidatorArgs < Hash
45
+ # Create an arguments object to send to a WorkflowValidator object
46
+ def initialize(args)
47
+ super()
48
+ opts = OptionParser.new do |opts|
49
+ opts.banner = "Usage: #$0 [-u url] <workflow def> [workflow def] ..."
50
+
51
+ opts.on('-u', '--url URL', 'Use XML Schema at URL') do |url|
52
+ self[:schema_url] = url
53
+ end
54
+
55
+ opts.on_tail('-h', '--help', 'display this help and exit') do
56
+ puts opts
57
+ exit
58
+ end
59
+ end
60
+ opts.parse!(args)
61
+ # Check for no args and exit if so
62
+ if args.empty?
63
+ puts opts
64
+ exit 1
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+
71
+ def main
72
+ # Create the arguments object and the validator object
73
+ args = OpenWFEru::WorkflowValidatorArgs.new(ARGV)
74
+ validator = OpenWFEru::WorkflowValidator.new(args)
75
+
76
+ # Loop through all arguments and validate the file
77
+ ARGV.each do |f|
78
+ print "Trying to validate #{f}... "
79
+ if FileTest.exists?(f) && validator.validate(f)
80
+ print "PASSED\n"
81
+ else
82
+ print "FAILED\n"
83
+ end
84
+ end
85
+ end
86
+
87
+ if $0 == __FILE__
88
+ main
89
+ end
@@ -0,0 +1,81 @@
1
+
2
+ #
3
+ # This is the code used in the blog post :
4
+ # http://jmettraux.wordpress.com/2007/12/03/state-machine/
5
+ #
6
+
7
+
8
+ # some setup
9
+
10
+ require 'openwfe/def'
11
+ require 'openwfe/engine'
12
+ require 'openwfe/participants'
13
+
14
+ engine = OpenWFE::Engine.new
15
+
16
+ alice = engine.register_participant(
17
+ :alice, OpenWFE::HashParticipant)
18
+ bob = engine.register_participant(
19
+ :bob, OpenWFE::HashParticipant)
20
+
21
+ class MyDefinition < OpenWFE::ProcessDefinition
22
+ sequence do
23
+ alice
24
+ bob
25
+ end
26
+ end
27
+
28
+ # later ...
29
+
30
+ #fei = engine.launch MyDefinition
31
+ #
32
+ #sleep 0.050
33
+ # # it's asynchronous, so...
34
+ #
35
+ #puts "alice holds #{alice.size} workitem(s)"
36
+ #puts "bob holds #{bob.size} workitem(s)"
37
+ #
38
+ #puts engine.process_status(fei)
39
+
40
+
41
+ class My2ndDefinition < OpenWFE::ProcessDefinition
42
+ sequence do
43
+ at :state => "redaction"
44
+ alice
45
+ at :state => "correction"
46
+ bob
47
+ alice
48
+ at :state => "approval"
49
+ charly
50
+ end
51
+
52
+ process_definition :name => "at" do
53
+ set :var => "/state", :val => "${state}"
54
+ end
55
+ end
56
+
57
+ #fei = engine.launch My2ndDefinition
58
+ #
59
+ #sleep 0.050
60
+ #
61
+ #puts "state : " + engine.lookup_variable(
62
+ # 'state', fei.workflow_instance_id)
63
+
64
+ class My3rdDefinition < OpenWFE::ProcessDefinition
65
+ sequence do
66
+ alice :tag => "redaction"
67
+ sequence :tag => "correction" do
68
+ bob
69
+ alice
70
+ end
71
+ charly :tag => "approval"
72
+ end
73
+ end
74
+
75
+ fei = engine.launch My3rdDefinition
76
+
77
+ sleep 0.050
78
+
79
+ puts "state : " + engine.process_status(
80
+ fei.workflow_instance_id).tags.inspect
81
+
@@ -0,0 +1,19 @@
1
+ #
2
+ # just a sample
3
+ #
4
+
5
+ class BigFlow0 < OpenWFE::ProcessDefinition
6
+
7
+ sequence do
8
+ alpha
9
+ concurrence do
10
+ bravo
11
+ cursor do
12
+ alpha
13
+ bravo
14
+ end
15
+ alpha :activity => "brush teeth"
16
+ end
17
+ bravo
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+
2
+ require 'rubygems'
3
+ require 'openwfe/extras/util/csvtable'
4
+
5
+ include OpenWFE::Extras
6
+
7
+ $table = CsvTable.new("http://spreadsheets.google.com/pub?key=pCkopoeZwCNsMWOVeDjR1TQ&output=csv&gid=0")
8
+
9
+ def decide (hash)
10
+
11
+ $table.transform hash
12
+
13
+ puts " weather : #{hash['weather']}, month : #{hash['month']}"
14
+ puts " => take umbrella ? #{hash['take_umbrella?']}"
15
+ puts
16
+ end
17
+
18
+ puts
19
+
20
+ decide({ "weather" => "raining", "month" => "december" })
21
+ decide({ "weather" => "sunny", "month" => "december" })
22
+ decide({ "weather" => "cloudy", "month" => "may" })
23
+
@@ -0,0 +1,247 @@
1
+
2
+ require 'rubygems'
3
+ #
4
+ # if OpenWFEru was installed via 'gem'
5
+
6
+ #
7
+ # setting up an OpenWFEru engine, step by step
8
+
9
+ require 'openwfe/engine/engine'
10
+ require 'openwfe/engine/file_persisted_engine'
11
+ require 'openwfe/participants/participants'
12
+
13
+
14
+ #
15
+ # === the ENGINE itself
16
+ #
17
+
18
+ #application_context = {}
19
+
20
+ #application_context[:engine_name] = "my_engine"
21
+ #
22
+ # the default value for the name of an engine is 'engine'
23
+ # this parameter is important when multiple engines do share some
24
+ # communication channel (message queue for example)
25
+ #
26
+ # This value appears in the FlowExpressionId of all the expressions
27
+ # and workitems of the engine.
28
+
29
+ #application_context[:work_directory] = "work"
30
+ #
31
+ # OpenWFEru engines take one optional argument : application_context
32
+ #
33
+ # the following engine constructions do not use this argument,
34
+ # but you can make them use it
35
+ #
36
+ # engine = OpenWFE::Engine.new(application_context)
37
+ #
38
+ # ...
39
+ #
40
+
41
+ #application_context[:remote_definitions_allowed] = true
42
+ #
43
+ # unless this parameter is set to true, the engine will not accept
44
+ # to launch processes whose definition is given by a URL, only
45
+ # local process definitions (file:) or direct process definitions
46
+ # will be allowed.
47
+
48
+ #application_context[:ruby_eval_allowed] = true
49
+ #
50
+ # if this parameter is set to true, evaluation of ruby code in process
51
+ # definition strings will be allowed as well as the ruby version of
52
+ # certain expression attributes like :
53
+ #
54
+ # <participant name="${ruby:LDAP::lookup(customer_id)" />
55
+ # or
56
+ # <if rtest="var % 2 == 0"> ...
57
+ #
58
+
59
+ #application_context[:dynamic_eval_allowed] = true
60
+ #
61
+ # by default, :dynamic_eval_allowed is not set to true, it means
62
+ # that the "eval" expression cannot be used.
63
+ #
64
+ # don't set that unless you're sure you'll need this 'eval' expression.
65
+
66
+ #application_context[:definition_in_launchitem_allowed] = true
67
+ #
68
+ # by default (since 0.9.18), it's not allowed to launch processes whose
69
+ # definitions is embedded in the launchitem. You have to explicitely
70
+ # set this parameter to true
71
+
72
+
73
+ #engine = OpenWFE::Engine.new
74
+ #engine = OpenWFE::Engine.new(application_context)
75
+ #
76
+ # an in-memory, totally transient engine
77
+ #
78
+ # might be ideal for an embedded workflow engine with short lived
79
+ # process definitions to run
80
+
81
+ #engine = OpenWFE::FilePersistedEngine.new
82
+ #engine = OpenWFE::FilePersistedEngine.new(application_context)
83
+ #
84
+ # a file persisted engine, slow, used only within unit tests
85
+ # do not use
86
+
87
+ engine = OpenWFE::CachedFilePersistedEngine.new
88
+ #engine = OpenWFE::CachedFilePersistedEngine.new(application_context)
89
+ #
90
+ # a file persisted engine, with an in-memory cache.
91
+ # use that
92
+ #
93
+ # persistence is done by default under ./work/
94
+
95
+ at_exit do
96
+ #
97
+ # making sure that the engine gets properly stopped when
98
+ # Ruby exits.
99
+ #
100
+ engine.stop
101
+ end
102
+
103
+ # -- a console
104
+
105
+ #engine.enable_irb_console
106
+ #
107
+ # by enabling the IRB console, you can jump into the engine object
108
+ # with a CTRL-C hit on the terminal that runs hit.
109
+ #
110
+ # Hit CTRL-D to get out of the IRB console.
111
+
112
+ # -- process history
113
+
114
+ #require 'openwfe/expool/history'
115
+
116
+ #engine.init_service("history", InMemoryHistory)
117
+ #
118
+ # keeps all process history in an array in memory
119
+ # use only for test purposes !
120
+
121
+ #engine.init_service("history", FileHistory)
122
+ #
123
+ # dumps all the process history in a file name "history.log"
124
+ # in the work directory
125
+
126
+ # -- process journaling
127
+
128
+ #require 'openwfe/expool/journal'
129
+ #engine.init_service("journal", Journal)
130
+ #
131
+ # activates 'journaling',
132
+ #
133
+ # see http://openwferu.rubyforge.org/journal.html
134
+ #
135
+ # Journaling has a cost in terms of performace.
136
+ # Journaling should be used only in case you might want to migrate
137
+ # [segments of] running processes.
138
+ #
139
+ #engine.application_context[:keep_journals] = true
140
+ #
141
+ # if set to true, the journal of terminated processes will be kept
142
+ # (but moved by default to ./work/journal/done/)
143
+
144
+
145
+ #
146
+ # === some LISTENERS
147
+ #
148
+ # listeners 'receive' incoming workitems (InFlowWorkItem coming back from
149
+ # participants or LaunchItem requesting the launch of a particular flow)
150
+ #
151
+
152
+ #require 'openwfe/listeners/listeners'
153
+
154
+ #sl = OpenWFE::SocketListener.new(
155
+ # "socket_listener", @engine.application_context, 7008)
156
+ #engine.add_workitem_listener(sl)
157
+ #
158
+ # adding a simple SocketListener on port 7008
159
+
160
+ #require 'openwfe/listeners/socketlisteners'
161
+ #
162
+ #engine.add_workitem_listener(OpenWFE::SocketListener)
163
+ #
164
+ # adding a SocketListener on the default port 7007
165
+
166
+ #engine.add_workitem_listener(OpenWFE::FileListener, "500")
167
+ #
168
+ # listening for workitems (coming as within YAML files dropped in the
169
+ # default ./work/in directory)
170
+ #
171
+ # check for new files every 500 ms
172
+
173
+ #require 'openwfe/listeners/sqslisteners'
174
+ #
175
+ #engine.add_workitem_listener(
176
+ # OpenWFE::SqsListener.new(:wiqueue, engine.application_context),
177
+ # "2s")
178
+ #
179
+ # adds a listener polling an Amazon Simple Queue Service (SQS)
180
+ # named 'wiqueue' every 2 seconds
181
+ #
182
+ # http://jmettraux.wordpress.com/2007/03/13/openwferu-over-amazon-sqs/
183
+ # http://aws.amazon.com/sqs
184
+
185
+
186
+ #
187
+ # === the PARTICIPANTS
188
+ #
189
+ # to learn more about participants :
190
+ # http://openwferu.rubyforge.org/participants.html
191
+ #
192
+
193
+ # you can use indifferently symbols or strings for participant names
194
+
195
+ # It's perhaps better to separate the participant registration and put
196
+ # it in its own .rb file, but anyway, here are some participant registration
197
+ # examples :
198
+
199
+ engine.register_participant(:toto) do |workitem|
200
+ puts "toto received a workitem..."
201
+ puts "lots of work..." if workitem.attributes.size > 3
202
+ sleep 4
203
+ puts "done."
204
+ end
205
+ #
206
+ # an example of a "block participant", binding Ruby code to a
207
+ # participant in a business process
208
+
209
+ #require 'openwfe/participants/sqsparticipants'
210
+ #
211
+ #engine.register_participant(:sqs, OpenWFE::SqsParticipant.new(:wiqueue2))
212
+ #
213
+ # registers a participant named 'sqs', workitems for it will get placed
214
+ # on the SQS queue named "wiqueue2"
215
+
216
+ #require 'openwfe/participants/socketparticipants'
217
+ #
218
+ #engine.register_participant(
219
+ # "away", OpenWFE::SocketParticipant.new("target.host.co.jp", 7009))
220
+ #
221
+ # the participant "away" listens for workitems on port 7009 of
222
+ # host 'target.host.co.jp', our SocketParticipant will dispatch
223
+ # the workitem to it over TCP
224
+
225
+
226
+ engine.reschedule
227
+ #
228
+ # this method has to be called after all the participants have been
229
+ # added, it looks for temporal expressions (sleep, cron, ...) to
230
+ # reschedule.
231
+
232
+
233
+ #
234
+ # === joining the engine's scheduler thread
235
+ #
236
+ # (preventing the Ruby interpreting from prematurely (immediately) exiting)
237
+ #
238
+
239
+ engine.join
240
+ #
241
+ # you don't need to 'join' if the engine uses a listener, the thread of
242
+ # the listener will prevent the Ruby interpreter from exiting.
243
+ #
244
+ # hit CTRL-C to quit (or maybe engine.enable_irb_console has been called,
245
+ # in which case CTRL-C will bring you into a IRB console within the
246
+ # engine itself).
247
+