ruote 0.9.20 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGELOG.txt +8 -0
- data/CREDITS.txt +65 -0
- data/LICENSE.txt +21 -0
- data/README.rdoc +76 -0
- data/Rakefile +68 -0
- data/TODO.txt +287 -0
- data/examples/flickr_report.rb +108 -0
- data/examples/ruote_quickstart.rb +42 -0
- data/examples/web_first_page.rb +57 -0
- data/lib/ruote.rb +6 -0
- data/lib/ruote/context.rb +136 -0
- data/lib/ruote/engine.rb +339 -0
- data/lib/{openwfe/expressions/merge.rb → ruote/engine/process_error.rb} +35 -24
- data/lib/ruote/engine/process_status.rb +236 -0
- data/lib/ruote/evt/tracker.rb +110 -0
- data/lib/ruote/exp/command.rb +88 -0
- data/lib/ruote/exp/commanded.rb +69 -0
- data/lib/ruote/exp/condition.rb +120 -0
- data/lib/ruote/exp/expression_map.rb +103 -0
- data/lib/ruote/exp/fe_add_branches.rb +138 -0
- data/lib/ruote/exp/fe_apply.rb +85 -0
- data/lib/ruote/exp/fe_cancel_process.rb +74 -0
- data/lib/ruote/exp/fe_command.rb +163 -0
- data/lib/ruote/exp/fe_concurrence.rb +273 -0
- data/lib/ruote/exp/fe_concurrent_iterator.rb +204 -0
- data/lib/ruote/exp/fe_cron.rb +141 -0
- data/lib/ruote/exp/fe_cursor.rb +270 -0
- data/lib/ruote/exp/fe_define.rb +112 -0
- data/lib/{openwfe/engine/fs_engine.rb → ruote/exp/fe_echo.rb} +24 -18
- data/lib/ruote/exp/fe_equals.rb +115 -0
- data/lib/ruote/exp/fe_error.rb +90 -0
- data/lib/ruote/exp/fe_forget.rb +81 -0
- data/lib/ruote/exp/fe_if.rb +124 -0
- data/lib/ruote/exp/fe_inc.rb +205 -0
- data/lib/ruote/exp/fe_iterator.rb +193 -0
- data/lib/ruote/exp/fe_listen.rb +197 -0
- data/lib/{openwfe/engine.rb → ruote/exp/fe_noop.rb} +20 -3
- data/lib/ruote/exp/fe_participant.rb +202 -0
- data/lib/ruote/exp/fe_redo.rb +83 -0
- data/lib/ruote/exp/fe_reserve.rb +126 -0
- data/lib/ruote/exp/fe_restore.rb +102 -0
- data/lib/ruote/exp/fe_save.rb +79 -0
- data/lib/ruote/exp/fe_sequence.rb +60 -0
- data/lib/ruote/exp/fe_set.rb +160 -0
- data/lib/ruote/exp/fe_subprocess.rb +203 -0
- data/lib/{openwfe/expool/errors.rb → ruote/exp/fe_undo.rb} +28 -30
- data/lib/ruote/exp/fe_wait.rb +92 -0
- data/lib/ruote/exp/fe_when.rb +214 -0
- data/lib/ruote/exp/flowexpression.rb +624 -0
- data/lib/{openwfe/omixins.rb → ruote/exp/iterator.rb} +41 -23
- data/lib/ruote/exp/merge.rb +66 -0
- data/lib/{openwfe/util/ometa.rb → ruote/exp/raw.rb} +16 -16
- data/lib/ruote/exp/ro_attributes.rb +203 -0
- data/lib/ruote/exp/ro_persist.rb +139 -0
- data/lib/ruote/exp/ro_variables.rb +192 -0
- data/lib/ruote/fei.rb +131 -0
- data/lib/{openwfe/version.rb → ruote/id/mnemo_wfid_generator.rb} +17 -3
- data/lib/{openwfe/extras/engine/dm_engine.rb → ruote/id/wfid_generator.rb} +34 -22
- data/lib/ruote/log/fs_history.rb +181 -0
- data/lib/ruote/log/test_logger.rb +254 -0
- data/lib/ruote/log/wait_logger.rb +67 -0
- data/lib/ruote/parser.rb +205 -0
- data/lib/ruote/parser/ruby_dsl.rb +85 -0
- data/lib/ruote/parser/xml.rb +92 -0
- data/lib/ruote/part/block_participant.rb +101 -0
- data/lib/ruote/part/dispatch_pool.rb +84 -0
- data/lib/ruote/part/hash_participant.rb +91 -0
- data/lib/ruote/part/local_participant.rb +52 -0
- data/lib/{openwfe/engine/tc_engine.rb → ruote/part/no_op_participant.rb} +19 -14
- data/lib/{openwfe/engine/tt_engine.rb → ruote/part/null_participant.rb} +17 -18
- data/lib/ruote/part/participant_list.rb +201 -0
- data/lib/ruote/part/smtp_participant.rb +135 -0
- data/lib/ruote/part/storage_participant.rb +140 -0
- data/lib/{openwfe/util/irb.rb → ruote/part/template.rb} +23 -31
- data/lib/ruote/participant.rb +6 -0
- data/lib/ruote/receiver/base.rb +73 -0
- data/lib/ruote/storage/base.rb +210 -0
- data/lib/ruote/storage/fs_storage.rb +89 -0
- data/lib/ruote/storage/hash_storage.rb +171 -0
- data/lib/ruote/tree_dot.rb +85 -0
- data/lib/{openwfe → ruote}/util/dollar.rb +47 -63
- data/lib/{openwfe/extras/singlecon.rb → ruote/util/hashdot.rb} +40 -19
- data/lib/ruote/util/look.rb +129 -0
- data/lib/ruote/util/lookup.rb +92 -0
- data/lib/ruote/util/misc.rb +119 -0
- data/lib/ruote/util/ometa.rb +55 -0
- data/lib/ruote/util/serializer.rb +103 -0
- data/lib/ruote/util/time.rb +90 -0
- data/lib/ruote/util/tree.rb +58 -0
- data/lib/{openwfe → ruote}/util/treechecker.rb +10 -16
- data/lib/ruote/worker.rb +375 -0
- data/lib/ruote/workitem.rb +176 -0
- data/phil.txt +14 -0
- data/ruote.gemspec +278 -0
- data/test/README.rdoc +15 -0
- data/test/bm/ci.rb +55 -0
- data/test/bm/ici.rb +71 -0
- data/test/bm/juuman.rb +54 -0
- data/test/bm/load_26c.rb +25 -7
- data/test/bm/mega.rb +64 -0
- data/test/bm/seq_thousand.rb +31 -0
- data/test/bm/t.rb +35 -0
- data/test/functional/base.rb +88 -99
- data/test/functional/concurrent_base.rb +91 -0
- data/test/functional/crunner.rb +26 -0
- data/test/functional/ct_0_concurrence.rb +68 -0
- data/test/functional/ct_1_iterator.rb +61 -0
- data/test/functional/ct_2_cancel.rb +69 -0
- data/test/functional/eft_0_process_definition.rb +46 -15
- data/test/functional/eft_10_cancel_process.rb +46 -0
- data/test/functional/eft_11_wait.rb +97 -0
- data/test/functional/eft_12_listen.rb +271 -0
- data/test/functional/eft_13_iterator.rb +267 -0
- data/test/functional/eft_14_cursor.rb +278 -0
- data/test/functional/eft_15_loop.rb +67 -0
- data/test/functional/eft_16_if.rb +171 -0
- data/test/functional/eft_17_equals.rb +55 -0
- data/test/functional/eft_18_concurrent_iterator.rb +361 -0
- data/test/functional/eft_19_reserve.rb +136 -0
- data/test/functional/eft_1_echo.rb +59 -0
- data/test/functional/eft_20_save.rb +76 -0
- data/test/functional/eft_21_restore.rb +61 -0
- data/test/functional/eft_22_noop.rb +28 -0
- data/test/functional/eft_23_apply.rb +145 -0
- data/test/functional/eft_24_add_branches.rb +86 -0
- data/test/functional/eft_25_command.rb +28 -0
- data/test/functional/eft_26_error.rb +77 -0
- data/test/functional/eft_27_inc.rb +279 -0
- data/test/functional/eft_28_when.rb +109 -0
- data/test/functional/eft_29_cron.rb +64 -0
- data/test/functional/eft_2_sequence.rb +38 -27
- data/test/functional/eft_3_participant.rb +122 -0
- data/test/functional/eft_4_set.rb +230 -0
- data/test/functional/eft_5_subprocess.rb +164 -0
- data/test/functional/eft_6_concurrence.rb +279 -0
- data/test/functional/eft_7_forget.rb +61 -0
- data/test/functional/eft_8_undo.rb +78 -0
- data/test/functional/eft_9_redo.rb +46 -0
- data/test/functional/ft_0_worker.rb +46 -0
- data/test/functional/ft_10_dollar.rb +90 -0
- data/test/functional/ft_11_recursion.rb +111 -0
- data/test/functional/ft_12_launchitem.rb +37 -0
- data/test/functional/ft_13_variables.rb +131 -0
- data/test/functional/ft_14_re_apply.rb +133 -0
- data/test/functional/ft_15_timeout.rb +205 -0
- data/test/functional/ft_16_participant_params.rb +47 -0
- data/test/functional/ft_17_conditional.rb +76 -0
- data/test/functional/ft_18_kill.rb +85 -0
- data/test/functional/ft_19_alias.rb +33 -0
- data/test/functional/ft_1_process_status.rb +410 -20
- data/test/functional/ft_20_storage_participant.rb +46 -0
- data/test/functional/ft_21_forget.rb +42 -0
- data/test/functional/ft_22_process_definitions.rb +80 -0
- data/test/functional/ft_23_load_defs.rb +55 -0
- data/test/functional/ft_24_block_participants.rb +59 -0
- data/test/functional/ft_25_receiver.rb +87 -0
- data/test/functional/ft_26_participant_timeout.rb +49 -0
- data/test/functional/ft_27_var_indirection.rb +93 -0
- data/test/functional/ft_28_null_noop_participants.rb +51 -0
- data/test/functional/ft_29_part_template.rb +78 -0
- data/test/functional/ft_2_errors.rb +320 -0
- data/test/functional/ft_30_smtp_participant.rb +69 -0
- data/test/functional/ft_31_part_blocking.rb +70 -0
- data/test/functional/ft_32_history.rb +184 -0
- data/test/functional/ft_33_participant_subprocess_priority.rb +32 -0
- data/test/functional/ft_34_cursor_rewind.rb +98 -0
- data/test/functional/ft_35_add_service.rb +48 -0
- data/test/functional/ft_3_participant_registration.rb +107 -0
- data/test/functional/ft_4_cancel.rb +72 -0
- data/test/functional/ft_5_on_error.rb +155 -0
- data/test/functional/ft_6_on_cancel.rb +165 -0
- data/test/functional/ft_7_tags.rb +88 -0
- data/test/functional/ft_8_participant_consumption.rb +75 -0
- data/test/functional/ft_9_subprocesses.rb +145 -0
- data/test/functional/restart_base.rb +17 -26
- data/test/functional/rt_0_wait.rb +55 -0
- data/test/functional/rt_1_listen.rb +56 -0
- data/test/functional/rt_2_errors.rb +56 -0
- data/test/functional/rt_3_when.rb +70 -0
- data/test/functional/rt_4_cron.rb +63 -0
- data/test/functional/rt_5_timeout.rb +60 -0
- data/test/functional/rtest.rb +8 -0
- data/test/functional/storage_helper.rb +79 -0
- data/test/functional/test.rb +23 -11
- data/test/mpc_test.rb +29 -0
- data/test/path_helper.rb +4 -2
- data/test/pdef.xml +7 -0
- data/test/test_helper.rb +2 -30
- data/test/unit/storages.rb +13 -0
- data/test/unit/test.rb +2 -11
- data/test/unit/ut_0_ruby_parser.rb +120 -0
- data/test/unit/ut_11_lookup.rb +51 -0
- data/test/unit/ut_13_serializer.rb +65 -0
- data/test/unit/ut_14_is_uri.rb +28 -0
- data/test/unit/ut_15_util.rb +34 -0
- data/test/unit/ut_16_parser.rb +100 -0
- data/test/unit/ut_17_storage.rb +122 -0
- data/test/unit/ut_1_fei.rb +20 -0
- data/test/unit/ut_2_wfidgen.rb +21 -0
- data/test/unit/ut_3_wait_logger.rb +41 -0
- data/test/unit/ut_4_expmap.rb +20 -0
- data/test/unit/ut_5_tree.rb +54 -0
- data/test/unit/ut_6_condition.rb +138 -0
- data/test/unit/ut_7_workitem.rb +21 -0
- data/test/unit/ut_8_tree_to_dot.rb +72 -0
- data/test/unit/ut_9_xml_parser.rb +61 -0
- metadata +246 -253
- data/README.txt +0 -36
- data/bin/validate-workflow.rb +0 -89
- data/examples/about_state.rb +0 -81
- data/examples/bigflow.rb +0 -19
- data/examples/csv_weather.rb +0 -23
- data/examples/engine_template.rb +0 -222
- data/examples/flowtracing.rb +0 -24
- data/examples/homeworkreview.rb +0 -68
- data/examples/kotoba.rb +0 -22
- data/examples/mano_tracker.rb +0 -172
- data/examples/openwferu.rb +0 -60
- data/examples/quickstart.rb +0 -87
- data/examples/quotereporter.rb +0 -150
- data/examples/simple.rb +0 -56
- data/lib/openwfe.rb +0 -27
- data/lib/openwfe/contextual.rb +0 -120
- data/lib/openwfe/def.rb +0 -37
- data/lib/openwfe/engine/engine.rb +0 -455
- data/lib/openwfe/engine/expool_methods.rb +0 -113
- data/lib/openwfe/engine/file_persisted_engine.rb +0 -84
- data/lib/openwfe/engine/launch_methods.rb +0 -245
- data/lib/openwfe/engine/listener_methods.rb +0 -128
- data/lib/openwfe/engine/lookup_methods.rb +0 -156
- data/lib/openwfe/engine/participant_methods.rb +0 -141
- data/lib/openwfe/engine/status_methods.rb +0 -382
- data/lib/openwfe/engine/update_exp_methods.rb +0 -119
- data/lib/openwfe/expool/def_parser.rb +0 -196
- data/lib/openwfe/expool/errorjournal.rb +0 -294
- data/lib/openwfe/expool/expool_pause_methods.rb +0 -87
- data/lib/openwfe/expool/expressionpool.rb +0 -941
- data/lib/openwfe/expool/expstorage.rb +0 -370
- data/lib/openwfe/expool/fs_expstorage.rb +0 -302
- data/lib/openwfe/expool/history.rb +0 -278
- data/lib/openwfe/expool/journal.rb +0 -210
- data/lib/openwfe/expool/journal_replay.rb +0 -305
- data/lib/openwfe/expool/representation.rb +0 -105
- data/lib/openwfe/expool/tc_expstorage.rb +0 -239
- data/lib/openwfe/expool/threaded_expstorage.rb +0 -163
- data/lib/openwfe/expool/tt_expstorage.rb +0 -55
- data/lib/openwfe/expool/wfidgen.rb +0 -370
- data/lib/openwfe/expool/yaml_errorjournal.rb +0 -187
- data/lib/openwfe/expressions/condition.rb +0 -226
- data/lib/openwfe/expressions/environment.rb +0 -232
- data/lib/openwfe/expressions/expression_map.rb +0 -248
- data/lib/openwfe/expressions/expression_tree.rb +0 -265
- data/lib/openwfe/expressions/fe_cancel.rb +0 -89
- data/lib/openwfe/expressions/fe_command.rb +0 -237
- data/lib/openwfe/expressions/fe_concurrence.rb +0 -599
- data/lib/openwfe/expressions/fe_cron.rb +0 -197
- data/lib/openwfe/expressions/fe_cursor.rb +0 -200
- data/lib/openwfe/expressions/fe_define.rb +0 -146
- data/lib/openwfe/expressions/fe_do.rb +0 -181
- data/lib/openwfe/expressions/fe_equals.rb +0 -273
- data/lib/openwfe/expressions/fe_error.rb +0 -103
- data/lib/openwfe/expressions/fe_filter.rb +0 -112
- data/lib/openwfe/expressions/fe_filter_definition.rb +0 -151
- data/lib/openwfe/expressions/fe_fqv.rb +0 -231
- data/lib/openwfe/expressions/fe_http.rb +0 -198
- data/lib/openwfe/expressions/fe_if.rb +0 -287
- data/lib/openwfe/expressions/fe_iterator.rb +0 -128
- data/lib/openwfe/expressions/fe_listen.rb +0 -327
- data/lib/openwfe/expressions/fe_losfor.rb +0 -102
- data/lib/openwfe/expressions/fe_misc.rb +0 -374
- data/lib/openwfe/expressions/fe_participant.rb +0 -231
- data/lib/openwfe/expressions/fe_reserve.rb +0 -192
- data/lib/openwfe/expressions/fe_save.rb +0 -255
- data/lib/openwfe/expressions/fe_sequence.rb +0 -102
- data/lib/openwfe/expressions/fe_set.rb +0 -121
- data/lib/openwfe/expressions/fe_step.rb +0 -146
- data/lib/openwfe/expressions/fe_subprocess.rb +0 -150
- data/lib/openwfe/expressions/fe_timeout.rb +0 -107
- data/lib/openwfe/expressions/fe_wait.rb +0 -183
- data/lib/openwfe/expressions/fe_when.rb +0 -118
- data/lib/openwfe/expressions/filter.rb +0 -85
- data/lib/openwfe/expressions/flowexpression.rb +0 -872
- data/lib/openwfe/expressions/iterator.rb +0 -206
- data/lib/openwfe/expressions/raw.rb +0 -330
- data/lib/openwfe/expressions/rprocdef.rb +0 -373
- data/lib/openwfe/expressions/time.rb +0 -314
- data/lib/openwfe/expressions/timeout.rb +0 -184
- data/lib/openwfe/expressions/value.rb +0 -100
- data/lib/openwfe/extras/engine/ar_engine.rb +0 -58
- data/lib/openwfe/extras/engine/db_persisted_engine.rb +0 -74
- data/lib/openwfe/extras/expool/ar_expstorage.rb +0 -337
- data/lib/openwfe/extras/expool/db_errorjournal.rb +0 -165
- data/lib/openwfe/extras/expool/db_expstorage.rb +0 -73
- data/lib/openwfe/extras/expool/db_history.rb +0 -163
- data/lib/openwfe/extras/expool/dm_expstorage.rb +0 -327
- data/lib/openwfe/extras/listeners/jabber_listeners.rb +0 -102
- data/lib/openwfe/extras/listeners/jabberlisteners.rb +0 -26
- data/lib/openwfe/extras/listeners/sqs_listeners.rb +0 -128
- data/lib/openwfe/extras/misc/activityfeed.rb +0 -249
- data/lib/openwfe/extras/misc/basecamp.rb +0 -485
- data/lib/openwfe/extras/misc/jabber_common.rb +0 -122
- data/lib/openwfe/extras/participants/active_participants.rb +0 -724
- data/lib/openwfe/extras/participants/active_resource_participants.rb +0 -213
- data/lib/openwfe/extras/participants/activeparticipants.rb +0 -3
- data/lib/openwfe/extras/participants/ar_participants.rb +0 -285
- data/lib/openwfe/extras/participants/atomfeed_participants.rb +0 -158
- data/lib/openwfe/extras/participants/atompub_participants.rb +0 -252
- data/lib/openwfe/extras/participants/basecamp_participants.rb +0 -73
- data/lib/openwfe/extras/participants/decision_participants.rb +0 -113
- data/lib/openwfe/extras/participants/jabber_participants.rb +0 -147
- data/lib/openwfe/extras/participants/jabberparticipants.rb +0 -3
- data/lib/openwfe/extras/participants/sqs_participants.rb +0 -108
- data/lib/openwfe/extras/participants/twitter_participants.rb +0 -162
- data/lib/openwfe/filterdef.rb +0 -277
- data/lib/openwfe/flowexpressionid.rb +0 -396
- data/lib/openwfe/listeners/listener.rb +0 -86
- data/lib/openwfe/listeners/listeners.rb +0 -135
- data/lib/openwfe/logging.rb +0 -108
- data/lib/openwfe/participants.rb +0 -5
- data/lib/openwfe/participants/mail_participants.rb +0 -216
- data/lib/openwfe/participants/participant.rb +0 -142
- data/lib/openwfe/participants/participant_map.rb +0 -245
- data/lib/openwfe/participants/participants.rb +0 -381
- data/lib/openwfe/participants/soap_participants.rb +0 -121
- data/lib/openwfe/participants/store_participants.rb +0 -249
- data/lib/openwfe/participants/yaml_filestorage.rb +0 -216
- data/lib/openwfe/representations.rb +0 -770
- data/lib/openwfe/rexml.rb +0 -44
- data/lib/openwfe/rudefinitions.rb +0 -114
- data/lib/openwfe/service.rb +0 -92
- data/lib/openwfe/tools/flowtracer.rb +0 -63
- data/lib/openwfe/util/json.rb +0 -55
- data/lib/openwfe/util/observable.rb +0 -119
- data/lib/openwfe/util/workqueue.rb +0 -125
- data/lib/openwfe/util/xml.rb +0 -270
- data/lib/openwfe/utils.rb +0 -484
- data/lib/openwfe/workitem.rb +0 -541
- data/lib/openwfe/worklist/storelocks.rb +0 -277
- data/lib/openwfe/worklist/storeparticipant.rb +0 -6
- data/lib/openwfe/worklist/worklist.rb +0 -283
- data/lib/pooltool.ru +0 -311
- data/test/ar_test_connection.rb +0 -63
- data/test/bm/fatxml.rb +0 -70
- data/test/dm_test_connection.rb +0 -11
- data/test/extras/base.rb +0 -3
- data/test/extras/et_0_sqs.rb +0 -37
- data/test/extras/et_jabber_test.rb +0 -226
- data/test/extras/test.rb +0 -16
- data/test/functional/db_ft_0_ar_participants.rb +0 -136
- data/test/functional/eft_10_unset.rb +0 -60
- data/test/functional/eft_11_sleep.rb +0 -95
- data/test/functional/eft_12_wait.rb +0 -57
- data/test/functional/eft_13_cursor.rb +0 -139
- data/test/functional/eft_14_loop.rb +0 -36
- data/test/functional/eft_15_undo.rb +0 -77
- data/test/functional/eft_16_redo.rb +0 -88
- data/test/functional/eft_1_print.rb +0 -57
- data/test/functional/eft_3_equals.rb +0 -98
- data/test/functional/eft_4_if.rb +0 -96
- data/test/functional/eft_5_eval.rb +0 -89
- data/test/functional/eft_6_reval.rb +0 -101
- data/test/functional/eft_7_exp.rb +0 -47
- data/test/functional/eft_8_log.rb +0 -50
- data/test/functional/eft_9_set.rb +0 -132
- data/test/functional/engine_helper.rb +0 -122
- data/test/functional/ft_0_vars_at_launch.rb +0 -27
- data/test/functional/ft_2_file_listener.rb +0 -45
- data/test/functional/ft_3_on_cancel.rb +0 -171
- data/test/functional/ft_4_on_error.rb +0 -220
- data/test/functional/ft_5_process_uri.rb +0 -82
- data/test/functional/ft_6_process_status.rb +0 -62
- data/test/functional/ft_7_parameters.rb +0 -103
- data/test/functional/ft_8_dollar.rb +0 -53
- data/test/functional/ft_9_register_participants.rb +0 -119
- data/test/functional/rft_0_sleep.rb +0 -76
- data/test/unit/ut_0_fei.rb +0 -166
- data/test/unit/ut_10_lookup_attribute.rb +0 -86
- data/test/unit/ut_11_filter.rb +0 -124
- data/test/unit/ut_12_conditional.rb +0 -162
- data/test/unit/ut_13_xmlutil.rb +0 -57
- data/test/unit/ut_14_var_field_lookup.rb +0 -85
- data/test/unit/ut_15_fe_att_lookup.rb +0 -55
- data/test/unit/ut_16_expstorage_findexp.rb +0 -38
- data/test/unit/ut_17_representations.rb +0 -330
- data/test/unit/ut_17b_representations_hash.rb +0 -97
- data/test/unit/ut_18_store_lock.rb +0 -77
- data/test/unit/ut_1_wfid.rb +0 -104
- data/test/unit/ut_2_utils.rb +0 -53
- data/test/unit/ut_3_expmap.rb +0 -65
- data/test/unit/ut_4_fulldup.rb +0 -163
- data/test/unit/ut_5_observable.rb +0 -132
- data/test/unit/ut_6_treechecker.rb +0 -101
- data/test/unit/ut_7_parser_ruby.rb +0 -344
- data/test/unit/ut_7b_parser_ruby.rb +0 -56
- data/test/unit/ut_8_parser_description.rb +0 -77
- data/test/unit/ut_9_workitem.rb +0 -72
@@ -1,122 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2008-2009, Kenneth Kalmer, opensourcery.co.za
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Africa. Kenneth Kalmer of opensourcery.co.za
|
23
|
-
#++
|
24
|
-
|
25
|
-
|
26
|
-
require 'activesupport'
|
27
|
-
require 'xmpp4r-simple'
|
28
|
-
|
29
|
-
|
30
|
-
module OpenWFE
|
31
|
-
module Extras
|
32
|
-
|
33
|
-
# Common functionality shared by the JabberListener and
|
34
|
-
# JabberParticipant implementations in ruote.
|
35
|
-
module JabberCommon
|
36
|
-
|
37
|
-
def self.included( base )
|
38
|
-
|
39
|
-
base.instance_eval do
|
40
|
-
# JabberID to use
|
41
|
-
@@jabber_id = nil
|
42
|
-
cattr_accessor :jabber_id
|
43
|
-
|
44
|
-
# Jabber password
|
45
|
-
@@password = nil
|
46
|
-
cattr_accessor :password
|
47
|
-
|
48
|
-
# Jabber resource
|
49
|
-
@@resource = nil
|
50
|
-
cattr_accessor :resource
|
51
|
-
|
52
|
-
# Contacts that are always included in the participants roster
|
53
|
-
@@contacts = []
|
54
|
-
cattr_accessor :contacts
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
# Configures this class from the provided options hash. Looking
|
60
|
-
# for (and removes) the following keys from the hash:
|
61
|
-
#
|
62
|
-
# * :connection => Already configured xmpp4r-simple instance
|
63
|
-
# * :jabber_id => Jabber ID to use
|
64
|
-
# * :password => Password for the JID
|
65
|
-
# * :resource => (Optional) Name of the resource
|
66
|
-
# * :contacts => (Array) List of contacts to use
|
67
|
-
#
|
68
|
-
# If a connection is provided, the :jabber_id, :password,
|
69
|
-
# :resource and :contact keys are ignored
|
70
|
-
def configure_jabber!( options )
|
71
|
-
unless @connection = options.delete(:connection)
|
72
|
-
self.class.jabber_id = options.delete(:jabber_id)
|
73
|
-
self.class.password = options.delete(:password)
|
74
|
-
self.class.resource = options.delete(:resource) || 'ruote'
|
75
|
-
self.class.contacts = options.delete(:contacts) || []
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def connection
|
80
|
-
@connection.reconnect unless @connection.connected?
|
81
|
-
@connection
|
82
|
-
end
|
83
|
-
|
84
|
-
protected
|
85
|
-
|
86
|
-
def connect!
|
87
|
-
if @connection.nil?
|
88
|
-
jid = self.class.jabber_id + '/' + self.class.resource
|
89
|
-
@connection = Jabber::Simple.new( jid, self.class.password )
|
90
|
-
@connection.status( :chat, "#{self.class} waiting for instructions" )
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# Clear all contacts from the roster, and build up the roster again
|
95
|
-
def setup_roster!
|
96
|
-
# Clean the roster
|
97
|
-
self.connection.roster.items.each_pair do |jid, roster_item|
|
98
|
-
jid = jid.strip.to_s
|
99
|
-
unless self.class.contacts.include?( jid )
|
100
|
-
self.connection.remove( jid )
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Add missing contacts
|
105
|
-
self.class.contacts.each do |contact|
|
106
|
-
unless self.connection.subscribed_to?( contact )
|
107
|
-
self.connection.add( contact )
|
108
|
-
self.connection.roster.accept_subscription( contact )
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# Change status to 'busy' while performing a command, and back to 'chat'
|
114
|
-
# afterwards
|
115
|
-
def busy( &block )
|
116
|
-
self.connection.status( :dnd, "Working..." )
|
117
|
-
yield
|
118
|
-
self.connection.status( :chat, "JabberListener waiting for instructions" )
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,724 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2007-2009, John Mettraux, Tomaso Tosolini OpenWFE.org
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Italy.
|
23
|
-
#++
|
24
|
-
|
25
|
-
|
26
|
-
#require_gem 'activerecord'
|
27
|
-
gem 'activerecord'; require 'active_record'
|
28
|
-
|
29
|
-
|
30
|
-
require 'openwfe/workitem'
|
31
|
-
require 'openwfe/flowexpressionid'
|
32
|
-
require 'openwfe/engine/engine'
|
33
|
-
require 'openwfe/participants/participant'
|
34
|
-
|
35
|
-
|
36
|
-
module OpenWFE
|
37
|
-
module Extras
|
38
|
-
|
39
|
-
#
|
40
|
-
# DEPRECATED !! use openwfe/extras/participants/ar_participants instead
|
41
|
-
#
|
42
|
-
# The migration for ActiveParticipant and associated classes.
|
43
|
-
#
|
44
|
-
# There are two tables 'workitems' and 'fields'. As its name implies,
|
45
|
-
# the latter table stores the fields (also called attributes in OpenWFE
|
46
|
-
# speak) of the workitems.
|
47
|
-
#
|
48
|
-
# See Workitem and Field for more details.
|
49
|
-
#
|
50
|
-
# For centralization purposes, the migration and the model are located
|
51
|
-
# in the same source file. It should be quite easy for the Rails hackers
|
52
|
-
# among you to sort that out for a Rails based usage.
|
53
|
-
#
|
54
|
-
class WorkitemTables < ActiveRecord::Migration
|
55
|
-
|
56
|
-
def self.up
|
57
|
-
|
58
|
-
create_table :workitems do |t|
|
59
|
-
t.column :fei, :string
|
60
|
-
t.column :wfid, :string
|
61
|
-
t.column :expid, :string
|
62
|
-
t.column :wf_name, :string
|
63
|
-
t.column :wf_revision, :string
|
64
|
-
t.column :participant_name, :string
|
65
|
-
t.column :store_name, :string
|
66
|
-
t.column :dispatch_time, :timestamp
|
67
|
-
t.column :last_modified, :timestamp
|
68
|
-
|
69
|
-
t.column :yattributes, :text
|
70
|
-
# when using compact_workitems, attributes are stored here
|
71
|
-
end
|
72
|
-
add_index :workitems, :fei, :unique => true
|
73
|
-
# with sqlite3, comment out this :unique => true on :fei :(
|
74
|
-
add_index :workitems, :wfid
|
75
|
-
add_index :workitems, :expid
|
76
|
-
add_index :workitems, :wf_name
|
77
|
-
add_index :workitems, :wf_revision
|
78
|
-
add_index :workitems, :participant_name
|
79
|
-
add_index :workitems, :store_name
|
80
|
-
|
81
|
-
create_table :fields do |t|
|
82
|
-
t.column :fkey, :string, :null => false
|
83
|
-
t.column :vclass, :string, :null => false
|
84
|
-
t.column :svalue, :string
|
85
|
-
t.column :yvalue, :text
|
86
|
-
t.column :workitem_id, :integer, :null => false
|
87
|
-
end
|
88
|
-
#add_index :fields, [ :workitem_id, :fkey ], :unique => true
|
89
|
-
#add_index :fields, :workitem_id
|
90
|
-
add_index :fields, :fkey
|
91
|
-
add_index :fields, :vclass
|
92
|
-
add_index :fields, :svalue
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.down
|
96
|
-
|
97
|
-
drop_table :workitems
|
98
|
-
drop_table :fields
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
#
|
103
|
-
# Reopening InFlowWorkItem to add a 'db_id' attribute.
|
104
|
-
#
|
105
|
-
class OpenWFE::InFlowWorkItem
|
106
|
-
|
107
|
-
attr_accessor :db_id
|
108
|
-
# deprecated !
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
# The ActiveRecord version of an OpenWFEru workitem (InFlowWorkItem).
|
113
|
-
#
|
114
|
-
# One can very easily build a worklist based on a participant name via :
|
115
|
-
#
|
116
|
-
# wl = OpenWFE::Extras::Workitem.find_all_by_participant_name("toto")
|
117
|
-
# puts "found #{wl.size} workitems for participant 'toto'"
|
118
|
-
#
|
119
|
-
# These workitems are not OpenWFEru workitems directly. But the conversion
|
120
|
-
# is pretty easy.
|
121
|
-
# Note that you probaly won't need to do the conversion by yourself,
|
122
|
-
# except for certain advanced scenarii.
|
123
|
-
#
|
124
|
-
# awi = OpenWFE::Extras::Workitem.find_by_participant_name("toto")
|
125
|
-
# #
|
126
|
-
# # returns the first workitem in the database whose participant
|
127
|
-
# # name is 'toto'.
|
128
|
-
#
|
129
|
-
# owi = awi.as_owfe_workitem
|
130
|
-
# #owi = awi.to_owfe_workitem
|
131
|
-
# #
|
132
|
-
# # Now we have a copy of the reference as a OpenWFEru
|
133
|
-
# # InFlowWorkItem instance.
|
134
|
-
#
|
135
|
-
# awi = OpenWFE::Extras::Workitem.from_owfe_workitem(owi)
|
136
|
-
# #
|
137
|
-
# # turns an OpenWFEru InFlowWorkItem instance into an
|
138
|
-
# # 'active workitem'.
|
139
|
-
#
|
140
|
-
class Workitem < ActiveRecord::Base
|
141
|
-
|
142
|
-
def connection
|
143
|
-
ActiveRecord::Base.verify_active_connections!
|
144
|
-
super
|
145
|
-
end
|
146
|
-
|
147
|
-
has_many(
|
148
|
-
:fields,
|
149
|
-
:dependent => :delete_all,
|
150
|
-
:class_name => 'OpenWFE::Extras::Field')
|
151
|
-
|
152
|
-
serialize :yattributes
|
153
|
-
|
154
|
-
#
|
155
|
-
# Returns the flow expression id of this work (its unique OpenWFEru (Ruote)
|
156
|
-
# identifier) as a FlowExpressionId instance.
|
157
|
-
# (within the Workitem it's just stored as a String).
|
158
|
-
#
|
159
|
-
def full_fei
|
160
|
-
|
161
|
-
@full_fei ||= OpenWFE::FlowExpressionId.from_s(fei)
|
162
|
-
end
|
163
|
-
|
164
|
-
#
|
165
|
-
# Making sure last_modified is set to Time.now before each save.
|
166
|
-
#
|
167
|
-
def before_save
|
168
|
-
|
169
|
-
touch
|
170
|
-
end
|
171
|
-
|
172
|
-
#
|
173
|
-
# Generates a (new) Workitem from an OpenWFEru InFlowWorkItem instance.
|
174
|
-
#
|
175
|
-
# This is a 'static' method :
|
176
|
-
#
|
177
|
-
# awi = OpenWFE::Extras::Workitem.from_owfe_workitem(wi)
|
178
|
-
#
|
179
|
-
# (This method saves the 'ActiveWorkitem').
|
180
|
-
#
|
181
|
-
def Workitem.from_owfe_workitem (wi, store_name=nil)
|
182
|
-
|
183
|
-
i = Workitem.new
|
184
|
-
i.fei = wi.fei.to_s
|
185
|
-
i.wfid = wi.fei.wfid
|
186
|
-
i.expid = wi.fei.expid
|
187
|
-
i.wf_name = wi.fei.workflow_definition_name
|
188
|
-
i.wf_revision = wi.fei.workflow_definition_revision
|
189
|
-
i.participant_name = wi.participant_name
|
190
|
-
i.dispatch_time = wi.dispatch_time
|
191
|
-
i.last_modified = nil
|
192
|
-
|
193
|
-
i.store_name = store_name
|
194
|
-
|
195
|
-
if wi.attributes['compact_workitems']
|
196
|
-
|
197
|
-
wi.attributes.delete('compact_workitems')
|
198
|
-
i.yattributes = wi.attributes
|
199
|
-
|
200
|
-
else
|
201
|
-
|
202
|
-
i.yattributes = nil
|
203
|
-
wi.attributes.each { |k, v| i.fields << Field.new_field(k, v) }
|
204
|
-
end
|
205
|
-
|
206
|
-
i.save!
|
207
|
-
# making sure to throw an exception in case of trouble
|
208
|
-
|
209
|
-
i
|
210
|
-
end
|
211
|
-
|
212
|
-
#
|
213
|
-
# Turns the 'active' Workitem into a ruote InFlowWorkItem.
|
214
|
-
#
|
215
|
-
def to_owfe_workitem (options={})
|
216
|
-
|
217
|
-
wi = OpenWFE::InFlowWorkItem.new
|
218
|
-
|
219
|
-
wi.fei = full_fei
|
220
|
-
wi.participant_name = participant_name
|
221
|
-
wi.attributes = fields_hash
|
222
|
-
|
223
|
-
wi.dispatch_time = dispatch_time
|
224
|
-
wi.last_modified = last_modified
|
225
|
-
|
226
|
-
wi.db_id = self.id
|
227
|
-
|
228
|
-
wi
|
229
|
-
end
|
230
|
-
|
231
|
-
alias :as_owfe_workitem :to_owfe_workitem
|
232
|
-
|
233
|
-
#
|
234
|
-
# Returns a hash version of the 'fields' of this workitem.
|
235
|
-
#
|
236
|
-
# (Each time this method is called, it returns a new hash).
|
237
|
-
#
|
238
|
-
def field_hash
|
239
|
-
|
240
|
-
self.yattributes || fields.inject({}) { |r, f| r[f.fkey] = f.value; r }
|
241
|
-
end
|
242
|
-
|
243
|
-
alias :fields_hash :field_hash
|
244
|
-
|
245
|
-
#
|
246
|
-
# Replaces the current fields of this workitem with the given hash.
|
247
|
-
#
|
248
|
-
# This method modifies the content of the db.
|
249
|
-
#
|
250
|
-
def replace_fields (fhash)
|
251
|
-
|
252
|
-
if self.yattributes
|
253
|
-
|
254
|
-
#self.yattributes = fhash
|
255
|
-
|
256
|
-
else
|
257
|
-
|
258
|
-
fields.delete_all
|
259
|
-
fhash.each { |k, v| fields << Field.new_field(k, v) }
|
260
|
-
end
|
261
|
-
|
262
|
-
#f = Field.new_field("___map_type", "smap")
|
263
|
-
#
|
264
|
-
# an old trick for backward compatibility with OpenWFEja
|
265
|
-
|
266
|
-
save!
|
267
|
-
# making sure to throw an exception in case of trouble
|
268
|
-
end
|
269
|
-
|
270
|
-
#
|
271
|
-
# Returns the Field instance with the given key. This method accept
|
272
|
-
# symbols as well as strings as its parameter.
|
273
|
-
#
|
274
|
-
# wi.field("customer_name")
|
275
|
-
# wi.field :customer_name
|
276
|
-
#
|
277
|
-
def field (key)
|
278
|
-
|
279
|
-
return self.yattributes[key.to_s] if self.yattributes
|
280
|
-
|
281
|
-
fields.find_by_fkey(key.to_s)
|
282
|
-
end
|
283
|
-
|
284
|
-
#
|
285
|
-
# A shortcut method, replies to the workflow engine and removes self
|
286
|
-
# from the database.
|
287
|
-
# Handy for people who don't want to play with an ActiveParticipant
|
288
|
-
# instance when just consuming workitems (that an active participant
|
289
|
-
# pushed in the database).
|
290
|
-
#
|
291
|
-
def reply (engine)
|
292
|
-
|
293
|
-
engine.reply(self.as_owfe_workitem)
|
294
|
-
self.destroy
|
295
|
-
end
|
296
|
-
|
297
|
-
alias :forward :reply
|
298
|
-
alias :proceed :reply
|
299
|
-
|
300
|
-
#
|
301
|
-
# Simply sets the 'last_modified' field to now.
|
302
|
-
# (Doesn't save the workitem though).
|
303
|
-
#
|
304
|
-
def touch
|
305
|
-
|
306
|
-
self.last_modified = Time.now
|
307
|
-
end
|
308
|
-
|
309
|
-
#
|
310
|
-
# Opening engine to update its reply method to accept these
|
311
|
-
# active record workitems.
|
312
|
-
#
|
313
|
-
class OpenWFE::Engine
|
314
|
-
|
315
|
-
alias :oldreply :reply
|
316
|
-
|
317
|
-
def reply (workitem)
|
318
|
-
|
319
|
-
if workitem.is_a?(Workitem)
|
320
|
-
|
321
|
-
workitem.destroy
|
322
|
-
oldreply(workitem.as_owfe_workitem)
|
323
|
-
else
|
324
|
-
|
325
|
-
oldreply(workitem)
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
alias :forward :reply
|
330
|
-
alias :proceed :reply
|
331
|
-
end
|
332
|
-
|
333
|
-
#
|
334
|
-
# Returns all the workitems belonging to the stores listed
|
335
|
-
# in the parameter storename_list.
|
336
|
-
# The result is a Hash whose keys are the store names and whose
|
337
|
-
# values are list of workitems.
|
338
|
-
#
|
339
|
-
def self.find_in_stores (storename_list)
|
340
|
-
|
341
|
-
workitems = find_all_by_store_name(storename_list)
|
342
|
-
|
343
|
-
result = {}
|
344
|
-
|
345
|
-
workitems.each do |wi|
|
346
|
-
(result[wi.store_name] ||= []) << wi
|
347
|
-
end
|
348
|
-
|
349
|
-
result
|
350
|
-
end
|
351
|
-
|
352
|
-
#
|
353
|
-
# Some kind of 'google search' among workitems
|
354
|
-
#
|
355
|
-
# == Note
|
356
|
-
#
|
357
|
-
# when this is used on compact_workitems, it will not be able to search
|
358
|
-
# info within the fields, because they aren't used by this kind of
|
359
|
-
# workitems. In this case the search will be limited to participant_name
|
360
|
-
#
|
361
|
-
def self.search (search_string, storename_list=nil)
|
362
|
-
|
363
|
-
#t = OpenWFE::Timer.new
|
364
|
-
|
365
|
-
storename_list = Array(storename_list) if storename_list
|
366
|
-
|
367
|
-
# participant_name
|
368
|
-
|
369
|
-
result = find(
|
370
|
-
:all,
|
371
|
-
:conditions => conditions(
|
372
|
-
'participant_name', search_string, storename_list),
|
373
|
-
:order => 'participant_name')
|
374
|
-
# :limit => 10)
|
375
|
-
|
376
|
-
ids = result.collect { |wi| wi.id }
|
377
|
-
|
378
|
-
# search in fields
|
379
|
-
|
380
|
-
fields = Field.search(search_string, storename_list)
|
381
|
-
merge_search_results(ids, result, fields)
|
382
|
-
|
383
|
-
#puts "... took #{t.duration} ms"
|
384
|
-
|
385
|
-
# over.
|
386
|
-
|
387
|
-
result
|
388
|
-
end
|
389
|
-
|
390
|
-
#
|
391
|
-
# Not really about 'just launched', but rather about finding the first
|
392
|
-
# workitem for a given process instance (wfid) and a participant.
|
393
|
-
# It deserves its own method because the workitem could be in a
|
394
|
-
# subprocess, thus escaping the vanilla find_by_wfid_and_participant()
|
395
|
-
#
|
396
|
-
def self.find_just_launched (wfid, participant_name)
|
397
|
-
|
398
|
-
find(
|
399
|
-
:first,
|
400
|
-
:conditions => [
|
401
|
-
"wfid LIKE ? AND participant_name = ?",
|
402
|
-
"#{wfid}%",
|
403
|
-
participant_name ])
|
404
|
-
end
|
405
|
-
|
406
|
-
protected
|
407
|
-
|
408
|
-
#
|
409
|
-
# builds the condition (the WHERE clause) for the
|
410
|
-
# search.
|
411
|
-
#
|
412
|
-
def self.conditions (keyname, search_string, storename_list)
|
413
|
-
|
414
|
-
cs = [ "#{keyname} LIKE ?", search_string ]
|
415
|
-
|
416
|
-
if storename_list
|
417
|
-
|
418
|
-
cs[0] = "#{cs[0]} AND workitems.store_name IN (?)"
|
419
|
-
cs << storename_list
|
420
|
-
end
|
421
|
-
|
422
|
-
cs
|
423
|
-
end
|
424
|
-
|
425
|
-
def self.merge_search_results (ids, wis, new_wis)
|
426
|
-
|
427
|
-
return if new_wis.size < 1
|
428
|
-
|
429
|
-
new_wis.each do |wi|
|
430
|
-
wi = wi.workitem if wi.kind_of?(Field)
|
431
|
-
next if ids.include? wi.id
|
432
|
-
ids << wi.id
|
433
|
-
wis << wi
|
434
|
-
end
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
#
|
439
|
-
# A workaround is in place for some classes when then have to get
|
440
|
-
# serialized. The names of thoses classes are listed in this array.
|
441
|
-
#
|
442
|
-
SPECIAL_FIELD_CLASSES = %w{ Time Date DateTime TrueClass FalseClass }
|
443
|
-
|
444
|
-
#
|
445
|
-
# A Field (Attribute) of a Workitem.
|
446
|
-
#
|
447
|
-
class Field < ActiveRecord::Base
|
448
|
-
|
449
|
-
def connection
|
450
|
-
ActiveRecord::Base.verify_active_connections!
|
451
|
-
super
|
452
|
-
end
|
453
|
-
|
454
|
-
belongs_to :workitem, :class_name => 'OpenWFE::Extras::Workitem'
|
455
|
-
|
456
|
-
serialize :yvalue
|
457
|
-
|
458
|
-
#
|
459
|
-
# A quick method for doing
|
460
|
-
#
|
461
|
-
# f = Field.new
|
462
|
-
# f.key = key
|
463
|
-
# f.value = value
|
464
|
-
#
|
465
|
-
# One can then quickly add fields to an [active] workitem via :
|
466
|
-
#
|
467
|
-
# wi.fields << Field.new_field("toto", "b")
|
468
|
-
#
|
469
|
-
# This method does not save the new Field.
|
470
|
-
#
|
471
|
-
def self.new_field (key, value)
|
472
|
-
|
473
|
-
Field.new(:fkey => key, :vclass => value.class.to_s, :value => value)
|
474
|
-
end
|
475
|
-
|
476
|
-
def value= (v)
|
477
|
-
|
478
|
-
limit = connection.native_database_types[:string][:limit]
|
479
|
-
|
480
|
-
if v.is_a?(String) and v.length <= limit
|
481
|
-
|
482
|
-
self.svalue = v
|
483
|
-
|
484
|
-
elsif SPECIAL_FIELD_CLASSES.include?(v.class.to_s)
|
485
|
-
|
486
|
-
self.svalue = v.to_yaml
|
487
|
-
|
488
|
-
else
|
489
|
-
|
490
|
-
self.yvalue = v
|
491
|
-
end
|
492
|
-
end
|
493
|
-
|
494
|
-
def value
|
495
|
-
|
496
|
-
return YAML.load(self.svalue) \
|
497
|
-
if SPECIAL_FIELD_CLASSES.include?(self.vclass)
|
498
|
-
|
499
|
-
self.svalue || self.yvalue
|
500
|
-
end
|
501
|
-
|
502
|
-
#
|
503
|
-
# Will return all the fields that contain the given text.
|
504
|
-
#
|
505
|
-
# Looks in svalue and fkey. Looks as well in yvalue if it contains
|
506
|
-
# a string.
|
507
|
-
#
|
508
|
-
# This method is used by Workitem.search()
|
509
|
-
#
|
510
|
-
def self.search (text, storename_list=nil)
|
511
|
-
|
512
|
-
cs = build_search_conditions(text)
|
513
|
-
|
514
|
-
if storename_list
|
515
|
-
|
516
|
-
cs[0] = "(#{cs[0]}) AND workitems.store_name IN (?)"
|
517
|
-
cs << storename_list
|
518
|
-
end
|
519
|
-
|
520
|
-
find(:all, :conditions => cs, :include => :workitem)
|
521
|
-
end
|
522
|
-
|
523
|
-
protected
|
524
|
-
|
525
|
-
#
|
526
|
-
# The search operates on the content of these columns
|
527
|
-
#
|
528
|
-
FIELDS_TO_SEARCH = %w{ svalue fkey yvalue }
|
529
|
-
|
530
|
-
#
|
531
|
-
# Builds the condition array for a pseudo text search
|
532
|
-
#
|
533
|
-
def self.build_search_conditions (text)
|
534
|
-
|
535
|
-
has_percent = (text.index('%') != nil)
|
536
|
-
|
537
|
-
conds = []
|
538
|
-
|
539
|
-
conds << FIELDS_TO_SEARCH.collect { |key|
|
540
|
-
|
541
|
-
count = has_percent ? 1 : 4
|
542
|
-
|
543
|
-
s = ([ "#{key} LIKE ?" ] * count).join(" OR ")
|
544
|
-
|
545
|
-
s = "(vclass = ? AND (#{s}))" if key == 'yvalue'
|
546
|
-
|
547
|
-
s
|
548
|
-
}.join(' OR ')
|
549
|
-
|
550
|
-
FIELDS_TO_SEARCH.each do |key|
|
551
|
-
|
552
|
-
conds << 'String' if key == 'yvalue'
|
553
|
-
|
554
|
-
conds << text
|
555
|
-
|
556
|
-
unless has_percent
|
557
|
-
conds << "% #{text} %"
|
558
|
-
conds << "% #{text}"
|
559
|
-
conds << "#{text} %"
|
560
|
-
end
|
561
|
-
end
|
562
|
-
|
563
|
-
conds
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
|
568
|
-
#
|
569
|
-
# A basic 'ActiveParticipant'.
|
570
|
-
# A store participant whose store is a set of ActiveRecord tables.
|
571
|
-
#
|
572
|
-
# Sample usage :
|
573
|
-
#
|
574
|
-
# class MyDefinition < OpenWFE::ProcessDefinition
|
575
|
-
# sequence do
|
576
|
-
# active0
|
577
|
-
# active1
|
578
|
-
# end
|
579
|
-
# end
|
580
|
-
#
|
581
|
-
# def play_with_the_engine
|
582
|
-
#
|
583
|
-
# engine = OpenWFE::Engine.new
|
584
|
-
#
|
585
|
-
# engine.register_participant(
|
586
|
-
# :active0, OpenWFE::Extras::ActiveParticipant)
|
587
|
-
# engine.register_participant(
|
588
|
-
# :active1, OpenWFE::Extras::ActiveParticipant)
|
589
|
-
#
|
590
|
-
# li = OpenWFE::LaunchItem.new(MyDefinition)
|
591
|
-
# li.customer_name = 'toto'
|
592
|
-
# engine.launch li
|
593
|
-
#
|
594
|
-
# sleep 0.500
|
595
|
-
# # give some slack to the engine, it's asynchronous after all
|
596
|
-
#
|
597
|
-
# wi = OpenWFE::Extras::Workitem.find_by_participant_name("active0")
|
598
|
-
#
|
599
|
-
# # ...
|
600
|
-
# end
|
601
|
-
#
|
602
|
-
# == Compact workitems
|
603
|
-
#
|
604
|
-
# It is possible to save all the workitem data into a single table,
|
605
|
-
# the workitems table, without
|
606
|
-
# splitting info between workitems and fields tables.
|
607
|
-
#
|
608
|
-
# You can configure the "compact_workitems" behavior by adding to the
|
609
|
-
# previous lines:
|
610
|
-
#
|
611
|
-
# active0 = engine.register_participant(
|
612
|
-
# :active0, OpenWFE::Extras::ActiveParticipant)
|
613
|
-
#
|
614
|
-
# active0.compact_workitems = true
|
615
|
-
#
|
616
|
-
# This behaviour is determined participant per participant, it's ok to
|
617
|
-
# have a participant instance that compacts will there is another that
|
618
|
-
# doesn't compact.
|
619
|
-
#
|
620
|
-
class ActiveParticipant
|
621
|
-
include OpenWFE::LocalParticipant
|
622
|
-
|
623
|
-
#
|
624
|
-
# when compact_workitems is set to true, the attributes of a workitem
|
625
|
-
# are stored in the yattributes column (they are not expanded into
|
626
|
-
# the Fields table).
|
627
|
-
# By default, workitem attributes are expanded.
|
628
|
-
#
|
629
|
-
attr :compact_workitems, true
|
630
|
-
|
631
|
-
#
|
632
|
-
# Forces ruote to not spawn a thread when dispatching to this participant.
|
633
|
-
#
|
634
|
-
def do_not_thread
|
635
|
-
true
|
636
|
-
end
|
637
|
-
|
638
|
-
#
|
639
|
-
# This is the method called by the OpenWFEru engine to hand a
|
640
|
-
# workitem to this participant.
|
641
|
-
#
|
642
|
-
def consume (workitem)
|
643
|
-
|
644
|
-
workitem.attributes['compact_workitems'] = true if compact_workitems
|
645
|
-
|
646
|
-
Workitem.from_owfe_workitem workitem
|
647
|
-
# does the 'saving to db'
|
648
|
-
end
|
649
|
-
|
650
|
-
#
|
651
|
-
# Called by the engine when the whole process instance (or just the
|
652
|
-
# segment of it that sports this participant) is cancelled.
|
653
|
-
# Will removed the workitem with the same fei as the cancelitem
|
654
|
-
# from the database.
|
655
|
-
#
|
656
|
-
# No expression will be raised if there is no corresponding workitem.
|
657
|
-
#
|
658
|
-
def cancel (cancelitem)
|
659
|
-
|
660
|
-
Workitem.destroy_all([ 'fei = ?', cancelitem.fei.to_s ])
|
661
|
-
# note that delete_all was not removing workitem fields
|
662
|
-
# probably my fault (bad :has_many setting)
|
663
|
-
end
|
664
|
-
|
665
|
-
#
|
666
|
-
# When the activity/work/operation whatever is over and the flow
|
667
|
-
# should resume, this is the method to use to hand back the [modified]
|
668
|
-
# workitem to the [local] engine.
|
669
|
-
#
|
670
|
-
def reply_to_engine (workitem)
|
671
|
-
|
672
|
-
super(workitem.as_owfe_workitem)
|
673
|
-
#
|
674
|
-
# replies to the workflow engine
|
675
|
-
|
676
|
-
workitem.destroy
|
677
|
-
#
|
678
|
-
# removes the workitem from the database
|
679
|
-
end
|
680
|
-
end
|
681
|
-
|
682
|
-
#
|
683
|
-
# An extension of ActiveParticipant. It has a 'store_name' and it
|
684
|
-
# makes sure to flag every workitem it 'consumes' with that name
|
685
|
-
# (in its 'store_name' column/field).
|
686
|
-
#
|
687
|
-
# This is the participant used mainly in 'densha' for human users.
|
688
|
-
#
|
689
|
-
class ActiveStoreParticipant < ActiveParticipant
|
690
|
-
include Enumerable
|
691
|
-
|
692
|
-
def initialize (store_name)
|
693
|
-
|
694
|
-
super()
|
695
|
-
@store_name = store_name
|
696
|
-
end
|
697
|
-
|
698
|
-
#
|
699
|
-
# This is the method called by the OpenWFEru engine to hand a
|
700
|
-
# workitem to this participant.
|
701
|
-
#
|
702
|
-
def consume (workitem)
|
703
|
-
|
704
|
-
workitem.attributes['compact_workitems'] = true if compact_workitems
|
705
|
-
|
706
|
-
Workitem.from_owfe_workitem(workitem, @store_name)
|
707
|
-
end
|
708
|
-
|
709
|
-
#
|
710
|
-
# Iterates over the workitems currently in this store.
|
711
|
-
#
|
712
|
-
def each (&block)
|
713
|
-
|
714
|
-
return unless block
|
715
|
-
|
716
|
-
wis = Workitem.find_by_store_name(@store_name)
|
717
|
-
|
718
|
-
wis.each { |wi| block.call(wi) }
|
719
|
-
end
|
720
|
-
end
|
721
|
-
|
722
|
-
end
|
723
|
-
end
|
724
|
-
|