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,872 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006-2009, John Mettraux, jmettraux@gmail.com
|
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 Japan.
|
23
|
-
#++
|
24
|
-
|
25
|
-
require 'openwfe/utils'
|
26
|
-
require 'openwfe/logging'
|
27
|
-
require 'openwfe/contextual'
|
28
|
-
require 'openwfe/rudefinitions'
|
29
|
-
require 'openwfe/util/ometa'
|
30
|
-
require 'openwfe/util/dollar'
|
31
|
-
require 'openwfe/expressions/expression_tree'
|
32
|
-
|
33
|
-
|
34
|
-
module OpenWFE
|
35
|
-
|
36
|
-
#
|
37
|
-
# When this variable is set to true (at the process root),
|
38
|
-
# it means the process is paused.
|
39
|
-
#
|
40
|
-
VAR_PAUSED = '/__paused__'
|
41
|
-
|
42
|
-
#
|
43
|
-
# FlowExpression
|
44
|
-
#
|
45
|
-
# The base class for all OpenWFE flow expression classes.
|
46
|
-
# It gathers all the methods for attributes and variable lookup.
|
47
|
-
#
|
48
|
-
class FlowExpression < ObjectWithMeta
|
49
|
-
|
50
|
-
include Contextual
|
51
|
-
include Logging
|
52
|
-
include OwfeServiceLocator
|
53
|
-
|
54
|
-
#
|
55
|
-
# The 'flow expression id' the unique identifier within a
|
56
|
-
# workflow instance for this expression instance.
|
57
|
-
#
|
58
|
-
attr_accessor :fei
|
59
|
-
|
60
|
-
#
|
61
|
-
# The 'flow expression id' of the parent expression.
|
62
|
-
# Will yield 'nil' if this expression is the root of its process
|
63
|
-
# instance.
|
64
|
-
#
|
65
|
-
attr_accessor :parent_id
|
66
|
-
|
67
|
-
#
|
68
|
-
# The 'flow expression id' of the environment this expression works
|
69
|
-
# with.
|
70
|
-
#
|
71
|
-
attr_accessor :environment_id
|
72
|
-
|
73
|
-
#
|
74
|
-
# The attributes of the expression, as found in the process definition.
|
75
|
-
#
|
76
|
-
# <participant ref='toto' timeout='1d10h' />
|
77
|
-
#
|
78
|
-
# The attributes will be ref => "toto" and timeout => "1d10h" (yes,
|
79
|
-
# 'attributes' contains a hash.
|
80
|
-
#
|
81
|
-
attr_accessor :attributes
|
82
|
-
|
83
|
-
#
|
84
|
-
# An array of 'flow expression id' instances. These are the ids of
|
85
|
-
# the expressions children to this one.
|
86
|
-
#
|
87
|
-
# <sequence>
|
88
|
-
# <participant ref="toto" />
|
89
|
-
# <participant ref="bert" />
|
90
|
-
# </sequence>
|
91
|
-
#
|
92
|
-
# The expression instance for 'sequence' will hold the feis of toto and
|
93
|
-
# bert in its children array.
|
94
|
-
#
|
95
|
-
attr_accessor :children
|
96
|
-
|
97
|
-
#
|
98
|
-
# When the FlowExpression instance is applied, this time stamp is set
|
99
|
-
# to the current date.
|
100
|
-
#
|
101
|
-
attr_accessor :apply_time
|
102
|
-
|
103
|
-
#
|
104
|
-
# Used by raw expressions to store the not yet interpreted branches
|
105
|
-
# of a process, used by other expressions to store their
|
106
|
-
# representation at 'eval time'.
|
107
|
-
#
|
108
|
-
attr_accessor :raw_representation
|
109
|
-
|
110
|
-
#
|
111
|
-
# Meant to contain a boolean value. If set to 'true' it means that
|
112
|
-
# this expression raw_representation has been modified after
|
113
|
-
# the expression instantiation.
|
114
|
-
#
|
115
|
-
# It's used to keep track effectively of in-flight modifications
|
116
|
-
# of process instances.
|
117
|
-
#
|
118
|
-
attr_accessor :raw_rep_updated
|
119
|
-
|
120
|
-
#
|
121
|
-
# When was this expression last updated ?
|
122
|
-
#
|
123
|
-
attr_accessor :updated_at
|
124
|
-
|
125
|
-
|
126
|
-
#
|
127
|
-
# Builds a new instance of an expression
|
128
|
-
#
|
129
|
-
def self.new_exp (fei, parent_id, env_id, app_context, attributes)
|
130
|
-
|
131
|
-
e = self.new
|
132
|
-
|
133
|
-
e.fei = fei
|
134
|
-
e.parent_id = parent_id
|
135
|
-
e.environment_id = env_id
|
136
|
-
e.application_context = app_context
|
137
|
-
e.attributes = attributes
|
138
|
-
|
139
|
-
e.children = []
|
140
|
-
e.apply_time = nil
|
141
|
-
|
142
|
-
e
|
143
|
-
end
|
144
|
-
|
145
|
-
#--
|
146
|
-
# the two most important methods for flow expressions
|
147
|
-
#++
|
148
|
-
|
149
|
-
#
|
150
|
-
# this default implementation immediately replies to the
|
151
|
-
# parent expression
|
152
|
-
#
|
153
|
-
def apply (workitem)
|
154
|
-
|
155
|
-
get_parent.reply(workitem) if @parent_id
|
156
|
-
end
|
157
|
-
|
158
|
-
#
|
159
|
-
# this default implementation immediately replies to the
|
160
|
-
# parent expression
|
161
|
-
#
|
162
|
-
def reply (workitem)
|
163
|
-
|
164
|
-
reply_to_parent(workitem)
|
165
|
-
end
|
166
|
-
|
167
|
-
#
|
168
|
-
# Triggers the reply to the parent expression (of course, via the
|
169
|
-
# expression pool).
|
170
|
-
# Expressions do call this method when their job is done and the flow
|
171
|
-
# should resume without them.
|
172
|
-
#
|
173
|
-
def reply_to_parent (workitem)
|
174
|
-
|
175
|
-
get_expression_pool.reply_to_parent(self, workitem)
|
176
|
-
end
|
177
|
-
|
178
|
-
#
|
179
|
-
# A default implementation for cancel :
|
180
|
-
# triggers any registered 'on_cancel' and then cancels all the children
|
181
|
-
#
|
182
|
-
# Attempts to return an InFlowWorkItem
|
183
|
-
#
|
184
|
-
def cancel
|
185
|
-
|
186
|
-
trigger_on_cancel
|
187
|
-
|
188
|
-
(@children || []).inject(nil) do |workitem, child|
|
189
|
-
|
190
|
-
#wi = child.is_a?(String) ? nil : get_expression_pool.cancel(child)
|
191
|
-
wi = get_expression_pool.cancel(child)
|
192
|
-
workitem ||= wi
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
#
|
197
|
-
# triggers the on_cancel attribute of the expression, if any, and forgets
|
198
|
-
# it...
|
199
|
-
#
|
200
|
-
# makes sure to pass a copy of the cancelled process's variables to the
|
201
|
-
# on_cancel process/participant if any
|
202
|
-
#
|
203
|
-
def trigger_on_cancel
|
204
|
-
|
205
|
-
on_cancel = (self.attributes || {})['on_cancel'] || return
|
206
|
-
|
207
|
-
on_cancel, workitem = on_cancel
|
208
|
-
|
209
|
-
template = lookup_variable(on_cancel) || [ on_cancel, {}, [] ]
|
210
|
-
|
211
|
-
get_expression_pool.launch_subprocess(
|
212
|
-
self,template, true, workitem, get_environment.lookup_all_variables)
|
213
|
-
end
|
214
|
-
|
215
|
-
#
|
216
|
-
# some convenience methods
|
217
|
-
|
218
|
-
#
|
219
|
-
# Returns the parent expression (not as a FlowExpressionId but directly
|
220
|
-
# as the FlowExpression instance it is).
|
221
|
-
#
|
222
|
-
def get_parent
|
223
|
-
|
224
|
-
get_expression_pool.fetch_expression(@parent_id)
|
225
|
-
end
|
226
|
-
|
227
|
-
#
|
228
|
-
# Stores itself in the expression pool.
|
229
|
-
# It's very important for expressions in persisted context to save
|
230
|
-
# themselves as soon as their state changed.
|
231
|
-
# Else this information would be lost at engine restart or
|
232
|
-
# simply if the expression got swapped out of memory and reloaded later.
|
233
|
-
#
|
234
|
-
def store_itself
|
235
|
-
|
236
|
-
#ldebug { "store_itself() for #{@fei.to_debug_s}" }
|
237
|
-
#ldebug { "store_itself() \n#{OpenWFE::caller_to_s(0, 6)}" }
|
238
|
-
|
239
|
-
get_expression_pool.update(self)
|
240
|
-
end
|
241
|
-
|
242
|
-
#
|
243
|
-
# Returns the environment instance this expression uses.
|
244
|
-
# An environment is a container (a scope) for variables in the process
|
245
|
-
# definition.
|
246
|
-
# Environments themselves are FlowExpression instances.
|
247
|
-
#
|
248
|
-
def get_environment
|
249
|
-
|
250
|
-
fetch_environment || get_expression_pool.fetch_engine_environment
|
251
|
-
end
|
252
|
-
|
253
|
-
#
|
254
|
-
# A shortcut for fetch_environment.get_root_environment
|
255
|
-
#
|
256
|
-
# Returns the environment of the top process (the environement
|
257
|
-
# just before the engine environment in the hierarchy).
|
258
|
-
#
|
259
|
-
def get_root_environment
|
260
|
-
|
261
|
-
fetch_environment.get_root_environment
|
262
|
-
end
|
263
|
-
|
264
|
-
#
|
265
|
-
# Just fetches the environment for this expression.
|
266
|
-
#
|
267
|
-
def fetch_environment
|
268
|
-
|
269
|
-
get_expression_pool.fetch_expression(@environment_id)
|
270
|
-
end
|
271
|
-
|
272
|
-
#
|
273
|
-
# Returns true if the expression's environment was generated
|
274
|
-
# for itself (usually DefineExpression do have such envs)
|
275
|
-
#
|
276
|
-
def owns_its_environment?
|
277
|
-
|
278
|
-
return false if not @environment_id
|
279
|
-
|
280
|
-
ei = @fei.dup
|
281
|
-
vi = @environment_id.dup
|
282
|
-
|
283
|
-
ei.expression_name = 'neutral'
|
284
|
-
vi.expression_name = 'neutral'
|
285
|
-
|
286
|
-
(ei == vi)
|
287
|
-
end
|
288
|
-
|
289
|
-
#
|
290
|
-
# Returns true if this expression belongs to a paused flow
|
291
|
-
#
|
292
|
-
def paused?
|
293
|
-
|
294
|
-
get_expression_pool.is_paused?(self)
|
295
|
-
end
|
296
|
-
|
297
|
-
#
|
298
|
-
# Sets a variable in the current environment. Is usually
|
299
|
-
# called by the 'set' expression.
|
300
|
-
#
|
301
|
-
# The variable name may be prefixed by / to indicate process level scope
|
302
|
-
# or by // to indicate engine level (global) scope.
|
303
|
-
#
|
304
|
-
def set_variable (varname, value)
|
305
|
-
|
306
|
-
env, var = lookup_environment(varname)
|
307
|
-
env[var] = value
|
308
|
-
end
|
309
|
-
|
310
|
-
alias :sv :set_variable
|
311
|
-
|
312
|
-
#
|
313
|
-
# Looks up the value of a variable in the current environment.
|
314
|
-
# If not found locally will lookup at the process level and even
|
315
|
-
# further in the engine scope.
|
316
|
-
#
|
317
|
-
# The variable name may be prefixed by / to indicate process level scope
|
318
|
-
# or by // to indicate engine level (global) scope.
|
319
|
-
#
|
320
|
-
def lookup_variable (varname)
|
321
|
-
|
322
|
-
env, var = lookup_environment(varname)
|
323
|
-
env[var]
|
324
|
-
end
|
325
|
-
|
326
|
-
alias :lv :lookup_variable
|
327
|
-
|
328
|
-
#
|
329
|
-
# Returns a stack of variable values, from here down to the engine
|
330
|
-
# environment.
|
331
|
-
#
|
332
|
-
# A stack is simply an array whose first value is the local value and
|
333
|
-
# the last value, the value registered in the engine env (if any is
|
334
|
-
# registered there).
|
335
|
-
#
|
336
|
-
def lookup_variable_stack (varname)
|
337
|
-
|
338
|
-
get_environment.lookup_variable_stack(varname)
|
339
|
-
end
|
340
|
-
|
341
|
-
#
|
342
|
-
# Unsets a variable in the current environment.
|
343
|
-
#
|
344
|
-
# The variable name may be prefixed by / to indicate process level scope
|
345
|
-
# or by // to indicate engine level (global) scope.
|
346
|
-
#
|
347
|
-
def delete_variable (varname)
|
348
|
-
|
349
|
-
env, var = lookup_environment(varname)
|
350
|
-
env.delete(var)
|
351
|
-
end
|
352
|
-
|
353
|
-
alias :unset_variable :delete_variable
|
354
|
-
|
355
|
-
#
|
356
|
-
# Looks up the value for an attribute of this expression.
|
357
|
-
#
|
358
|
-
# if the expression is
|
359
|
-
#
|
360
|
-
# <participant ref="toto" />
|
361
|
-
#
|
362
|
-
# then
|
363
|
-
#
|
364
|
-
# participant_expression.lookup_attribute("toto", wi)
|
365
|
-
#
|
366
|
-
# will yield "toto"
|
367
|
-
#
|
368
|
-
# The various methods for looking up attributes do perform dollar
|
369
|
-
# variable substitution.
|
370
|
-
# It's ok to pass a Symbol for the attribute name.
|
371
|
-
#
|
372
|
-
def lookup_attribute (attname, workitem, options={})
|
373
|
-
|
374
|
-
default = options[:default]
|
375
|
-
escape = options[:escape]
|
376
|
-
tostring = options[:to_s]
|
377
|
-
|
378
|
-
attname = OpenWFE.symbol_to_name(attname) if attname.kind_of?(Symbol)
|
379
|
-
|
380
|
-
text = @attributes[attname]
|
381
|
-
|
382
|
-
text = if text == nil
|
383
|
-
|
384
|
-
default
|
385
|
-
|
386
|
-
elsif escape == true
|
387
|
-
|
388
|
-
text
|
389
|
-
|
390
|
-
else
|
391
|
-
|
392
|
-
OpenWFE.dosub(text, self, workitem)
|
393
|
-
end
|
394
|
-
|
395
|
-
text = text.to_s if text and tostring
|
396
|
-
|
397
|
-
text
|
398
|
-
end
|
399
|
-
|
400
|
-
#
|
401
|
-
# Returns the attribute value as a String (or nil if it's not found).
|
402
|
-
#
|
403
|
-
def lookup_string_attribute (attname, workitem, options={})
|
404
|
-
|
405
|
-
result = lookup_attribute(attname, workitem, options)
|
406
|
-
result = result.to_s if result
|
407
|
-
result
|
408
|
-
end
|
409
|
-
|
410
|
-
#
|
411
|
-
# Like lookup_attribute() but returns the value downcased [
|
412
|
-
# (and stripped).
|
413
|
-
# Returns nil if no such attribute was found.
|
414
|
-
#
|
415
|
-
def lookup_downcase_attribute (attname, workitem, options={})
|
416
|
-
|
417
|
-
result = lookup_string_attribute(attname, workitem, options)
|
418
|
-
result = result.strip.downcase if result
|
419
|
-
result
|
420
|
-
end
|
421
|
-
|
422
|
-
#
|
423
|
-
# Returns the value of the attribute as a Symbol.
|
424
|
-
# Returns nil if there is no attribute under the given name.
|
425
|
-
#
|
426
|
-
def lookup_sym_attribute (attname, workitem, options={})
|
427
|
-
|
428
|
-
result = lookup_downcase_attribute(attname, workitem, options)
|
429
|
-
result = result.to_sym if result
|
430
|
-
result
|
431
|
-
end
|
432
|
-
|
433
|
-
#
|
434
|
-
# A convenience method for looking up a boolean value.
|
435
|
-
# It's ok to pass a Symbol for the attribute name.
|
436
|
-
#
|
437
|
-
def lookup_boolean_attribute (attname, workitem, default=false)
|
438
|
-
|
439
|
-
result = lookup_downcase_attribute(attname, workitem)
|
440
|
-
return default if result == nil
|
441
|
-
|
442
|
-
(result == 'true')
|
443
|
-
end
|
444
|
-
|
445
|
-
#
|
446
|
-
# looks up an attribute, if it's an array, returns it. Else
|
447
|
-
# (probably a string) will split it (comma) and return it
|
448
|
-
# (each element trimmed).
|
449
|
-
#
|
450
|
-
def lookup_array_attribute (attname, workitem, options={})
|
451
|
-
|
452
|
-
tostring = options.delete(:to_s)
|
453
|
-
|
454
|
-
v = lookup_attribute(attname, workitem, options)
|
455
|
-
|
456
|
-
return nil unless v
|
457
|
-
|
458
|
-
v = v.to_s.split(',').collect { |e| e.strip } \
|
459
|
-
unless v.is_a?(Array)
|
460
|
-
|
461
|
-
v = v.collect { |e| e.to_s } \
|
462
|
-
if tostring
|
463
|
-
|
464
|
-
v
|
465
|
-
end
|
466
|
-
|
467
|
-
#
|
468
|
-
# Returns true if the expression has the given attribute.
|
469
|
-
# The attname parameter can be a String or a Symbol.
|
470
|
-
#
|
471
|
-
def has_attribute (attname)
|
472
|
-
|
473
|
-
attname = OpenWFE::symbol_to_name(attname) if attname.is_a?(Symbol)
|
474
|
-
|
475
|
-
(@attributes[attname] != nil)
|
476
|
-
end
|
477
|
-
|
478
|
-
#
|
479
|
-
# Returns a hash of all the FlowExpression attributes with their
|
480
|
-
# values having undergone dollar variable substitution.
|
481
|
-
# If the _attributes parameter is set (to an Array instance) then
|
482
|
-
# only the attributes named in that list will be looked up.
|
483
|
-
#
|
484
|
-
# It's ok to pass an array of Symbol instances for the attributes
|
485
|
-
# parameter.
|
486
|
-
#
|
487
|
-
def lookup_attributes (workitem, _attributes=nil)
|
488
|
-
|
489
|
-
return {} unless @attributes
|
490
|
-
|
491
|
-
(_attributes || @attributes.keys).inject({}) do |r, k|
|
492
|
-
|
493
|
-
k = k.to_s
|
494
|
-
v = @attributes[k]
|
495
|
-
|
496
|
-
r[k] = OpenWFE::dosub v, self, workitem
|
497
|
-
|
498
|
-
r
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
#
|
503
|
-
# creates a new environment just for this expression
|
504
|
-
#
|
505
|
-
def new_environment (initial_vars=nil)
|
506
|
-
|
507
|
-
@environment_id = @fei.dup
|
508
|
-
@environment_id.expression_name = EN_ENVIRONMENT
|
509
|
-
|
510
|
-
parent_fei = nil
|
511
|
-
parent = nil
|
512
|
-
|
513
|
-
parent, _fei = get_expression_pool.fetch(@parent_id) \
|
514
|
-
if @parent_id
|
515
|
-
|
516
|
-
parent_fei = parent.environment_id if parent
|
517
|
-
|
518
|
-
env = Environment.new_env(
|
519
|
-
@environment_id, parent_fei, nil, @application_context, nil)
|
520
|
-
|
521
|
-
env.variables.merge!(initial_vars) if initial_vars
|
522
|
-
|
523
|
-
env[@fei.wfname] = self.raw_representation \
|
524
|
-
if (not @parent_id) and (self.is_a?(RawExpression))
|
525
|
-
#
|
526
|
-
# keeping track of the raw representation
|
527
|
-
# of the top expression (for top recursion)
|
528
|
-
|
529
|
-
env.store_itself
|
530
|
-
|
531
|
-
env
|
532
|
-
end
|
533
|
-
|
534
|
-
#
|
535
|
-
# This method is called in expressionpool.forget(). It duplicates
|
536
|
-
# the expression's current environment (deep copy) and attaches
|
537
|
-
# it as the expression own environment.
|
538
|
-
# Returns the duplicated environment.
|
539
|
-
#
|
540
|
-
def dup_environment
|
541
|
-
|
542
|
-
env = fetch_environment
|
543
|
-
env = env.dup
|
544
|
-
env.fei = @fei.dup
|
545
|
-
env.fei.expression_name = EN_ENVIRONMENT
|
546
|
-
@environment_id = env.fei
|
547
|
-
|
548
|
-
env.store_itself
|
549
|
-
end
|
550
|
-
|
551
|
-
#
|
552
|
-
# Takes care of removing all the children of this expression, if any.
|
553
|
-
#
|
554
|
-
def clean_children
|
555
|
-
|
556
|
-
return unless @children
|
557
|
-
|
558
|
-
@children.each do |child_fei|
|
559
|
-
#next unless child.is_a?(FlowExpressionId)
|
560
|
-
get_expression_pool.remove(child_fei)
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
564
|
-
#
|
565
|
-
# Removes a child from the expression children list.
|
566
|
-
#
|
567
|
-
def remove_child (child_fei)
|
568
|
-
|
569
|
-
i = @children.index(child_fei)
|
570
|
-
|
571
|
-
return unless i
|
572
|
-
|
573
|
-
@children.delete_at(i)
|
574
|
-
raw_children.delete_at(i)
|
575
|
-
@raw_rep_updated = true
|
576
|
-
|
577
|
-
store_itself
|
578
|
-
end
|
579
|
-
|
580
|
-
#
|
581
|
-
# Currently only used by dollar.rb and its ${r:some_ruby_code},
|
582
|
-
# returns the binding in this flow expression.
|
583
|
-
#
|
584
|
-
def get_binding
|
585
|
-
|
586
|
-
binding()
|
587
|
-
end
|
588
|
-
|
589
|
-
#
|
590
|
-
# Returns the text stored among the children
|
591
|
-
#
|
592
|
-
def fetch_text_content (workitem, escape=false)
|
593
|
-
|
594
|
-
text = (children || raw_children).inject('') do |r, child|
|
595
|
-
|
596
|
-
r << child.to_s
|
597
|
-
end
|
598
|
-
|
599
|
-
return nil if text == ''
|
600
|
-
|
601
|
-
escape ? text : OpenWFE::dosub(text, self, workitem)
|
602
|
-
end
|
603
|
-
|
604
|
-
#
|
605
|
-
# looks up for 'value', 'variable-value' and then for 'field-value'
|
606
|
-
# if necessary.
|
607
|
-
#
|
608
|
-
def lookup_value (workitem, options={})
|
609
|
-
|
610
|
-
lookup_vf_attribute(workitem, 'value', options) ||
|
611
|
-
lookup_vf_attribute(workitem, 'val', options)
|
612
|
-
end
|
613
|
-
|
614
|
-
#
|
615
|
-
# looks up for 'ref', 'variable-ref' and then for 'field-ref'
|
616
|
-
# if necessary.
|
617
|
-
#
|
618
|
-
def lookup_ref (workitem, prefix='')
|
619
|
-
|
620
|
-
ref = lookup_vf_attribute(workitem, 'ref', :prefix => prefix)
|
621
|
-
ref ? ref.to_s : nil
|
622
|
-
end
|
623
|
-
|
624
|
-
#
|
625
|
-
# Looks up for value attributes like 'field-ref' or 'variable-value'
|
626
|
-
#
|
627
|
-
def lookup_vf_attribute (workitem, att_name, options={})
|
628
|
-
|
629
|
-
att_name = att_name.to_s
|
630
|
-
|
631
|
-
prefix = options[:prefix] || ''
|
632
|
-
prefix = prefix.to_s
|
633
|
-
|
634
|
-
dash = (att_name.size > 0 and prefix.size > 0) ? '-' : ''
|
635
|
-
|
636
|
-
v = lookup_attribute("#{prefix}#{dash}#{att_name}", workitem, options)
|
637
|
-
|
638
|
-
att_name = "-#{att_name}" if att_name.size > 0
|
639
|
-
prefix = "#{prefix}-" if prefix.size > 0
|
640
|
-
|
641
|
-
return v if v
|
642
|
-
|
643
|
-
v = lookup_attribute(
|
644
|
-
"#{prefix}variable#{att_name}", workitem, options) ||
|
645
|
-
lookup_attribute(
|
646
|
-
"#{prefix}var#{att_name}", workitem, options) ||
|
647
|
-
lookup_attribute(
|
648
|
-
"#{prefix}v#{att_name}", workitem, options)
|
649
|
-
|
650
|
-
return lookup_variable(v) if v
|
651
|
-
|
652
|
-
f = lookup_attribute(
|
653
|
-
"#{prefix}field#{att_name}", workitem, options) ||
|
654
|
-
lookup_attribute(
|
655
|
-
"#{prefix}f#{att_name}", workitem, options)
|
656
|
-
|
657
|
-
f ? workitem.attributes[f.to_s] : nil
|
658
|
-
end
|
659
|
-
|
660
|
-
#
|
661
|
-
# Since OpenWFEru 0.9.17, each expression keeps his @raw_representation
|
662
|
-
# this is a shortcut for exp.raw_representation[2]
|
663
|
-
#
|
664
|
-
def raw_children
|
665
|
-
|
666
|
-
@raw_representation[2]
|
667
|
-
end
|
668
|
-
|
669
|
-
#
|
670
|
-
# Returns a list of children that are expressions (arrays)
|
671
|
-
#
|
672
|
-
def raw_expression_children
|
673
|
-
|
674
|
-
@raw_representation[2].select { |c| c.is_a?(Array) }
|
675
|
-
end
|
676
|
-
|
677
|
-
#
|
678
|
-
# Returns true if the current expression has no expression among its
|
679
|
-
# [raw] children.
|
680
|
-
#
|
681
|
-
def has_no_expression_child
|
682
|
-
|
683
|
-
(first_expression_child == nil)
|
684
|
-
end
|
685
|
-
|
686
|
-
#
|
687
|
-
# Returns the index of the first child that is an expression.
|
688
|
-
#
|
689
|
-
def first_expression_child
|
690
|
-
|
691
|
-
@raw_representation[2].find { |c| c.is_a?(Array) }
|
692
|
-
end
|
693
|
-
|
694
|
-
#
|
695
|
-
# Returns the next sub process id available (this counter
|
696
|
-
# is stored in the process environment under the key :next_sub_id)
|
697
|
-
#
|
698
|
-
def get_next_sub_id
|
699
|
-
|
700
|
-
env = get_root_environment
|
701
|
-
|
702
|
-
c = nil
|
703
|
-
|
704
|
-
c = env.variables[:next_sub_id]
|
705
|
-
n = if c
|
706
|
-
c + 1
|
707
|
-
else
|
708
|
-
c = 0
|
709
|
-
1
|
710
|
-
end
|
711
|
-
env.variables[:next_sub_id] = n
|
712
|
-
env.store_itself
|
713
|
-
|
714
|
-
c
|
715
|
-
end
|
716
|
-
|
717
|
-
#
|
718
|
-
# Given a child index (in the raw_children list/array), applies that
|
719
|
-
# child.
|
720
|
-
#
|
721
|
-
# Does the bulk work of preparing the children and applying it (also
|
722
|
-
# cares about registering the child in the @children array).
|
723
|
-
#
|
724
|
-
def apply_child (child_index, workitem)
|
725
|
-
|
726
|
-
child_index, child = if child_index.is_a?(Integer)
|
727
|
-
[ child_index, raw_children[child_index] ]
|
728
|
-
else
|
729
|
-
[ raw_children.index(child_index), child_index ]
|
730
|
-
end
|
731
|
-
|
732
|
-
get_expression_pool.tlaunch_child(
|
733
|
-
self, child, child_index, workitem, :register_child => true)
|
734
|
-
end
|
735
|
-
|
736
|
-
#
|
737
|
-
# Some eye candy
|
738
|
-
#
|
739
|
-
def to_s
|
740
|
-
|
741
|
-
s = "* #{@fei.to_debug_s} [#{self.class.name}]"
|
742
|
-
|
743
|
-
s << "\n `--p--> #{@parent_id.to_debug_s}" \
|
744
|
-
if @parent_id
|
745
|
-
|
746
|
-
s << "\n `--e--> #{@environment_id.to_debug_s}" \
|
747
|
-
if @environment_id
|
748
|
-
|
749
|
-
return s unless @children
|
750
|
-
|
751
|
-
@children.each do |c|
|
752
|
-
sc = if c.kind_of?(OpenWFE::FlowExpressionId)
|
753
|
-
c.to_debug_s
|
754
|
-
else
|
755
|
-
">#{c.to_s}<"
|
756
|
-
end
|
757
|
-
s << "\n `--c--> #{sc}"
|
758
|
-
end
|
759
|
-
|
760
|
-
s
|
761
|
-
end
|
762
|
-
|
763
|
-
#
|
764
|
-
# a nice 'names' tag/method for registering the names of the
|
765
|
-
# Expression classes.
|
766
|
-
#
|
767
|
-
def self.names (*exp_names)
|
768
|
-
|
769
|
-
exp_names = exp_names.collect do |n|
|
770
|
-
n.to_s
|
771
|
-
end
|
772
|
-
meta_def :expression_names do
|
773
|
-
exp_names
|
774
|
-
end
|
775
|
-
end
|
776
|
-
|
777
|
-
#
|
778
|
-
# Returns true if the expression class is a 'definition'.
|
779
|
-
#
|
780
|
-
def self.is_definition?
|
781
|
-
false
|
782
|
-
end
|
783
|
-
def self.is_definition
|
784
|
-
meta_def :is_definition? do
|
785
|
-
true
|
786
|
-
end
|
787
|
-
end
|
788
|
-
|
789
|
-
#
|
790
|
-
# Returns true if the expression with the given fei is an ancestor
|
791
|
-
# of this expression.
|
792
|
-
#
|
793
|
-
def descendant_of? (fei)
|
794
|
-
|
795
|
-
#p [ :d_of?, "#{@fei.wfid} #{@fei.expid}", "#{fei.wfid} #{fei.expid}" ]
|
796
|
-
|
797
|
-
return false if @parent_id == nil
|
798
|
-
return true if @parent_id == fei
|
799
|
-
return true if fei.ancestor_of?(@fei) # shortcut
|
800
|
-
|
801
|
-
get_expression_pool.fetch_expression(@parent_id).descendant_of?(fei)
|
802
|
-
end
|
803
|
-
|
804
|
-
def marshal_dump #:nodoc#
|
805
|
-
iv = instance_variables
|
806
|
-
iv.delete('@application_context')
|
807
|
-
iv.inject({}) { |h, vn| h[vn] = instance_variable_get(vn); h }
|
808
|
-
end
|
809
|
-
|
810
|
-
def marshal_load (s) #:nodoc#
|
811
|
-
s.each { |k, v| instance_variable_set(k, v) }
|
812
|
-
end
|
813
|
-
|
814
|
-
def to_yaml_properties #:nodoc#
|
815
|
-
l = super
|
816
|
-
l.delete('@application_context')
|
817
|
-
l
|
818
|
-
end
|
819
|
-
|
820
|
-
protected
|
821
|
-
|
822
|
-
#
|
823
|
-
# Initializes the @children member array.
|
824
|
-
#
|
825
|
-
# Used by 'concurrence' for example.
|
826
|
-
#
|
827
|
-
def extract_children
|
828
|
-
i = 0
|
829
|
-
@children = []
|
830
|
-
raw_representation.last.each do |child|
|
831
|
-
if OpenWFE::ExpressionTree.is_not_a_node?(child)
|
832
|
-
@children << child
|
833
|
-
else
|
834
|
-
cname = child.first.intern
|
835
|
-
next if cname == :param
|
836
|
-
next if cname == :parameter
|
837
|
-
#next if cname == :description
|
838
|
-
cfei = @fei.dup
|
839
|
-
cfei.expression_name = child.first
|
840
|
-
cfei.expression_id = "#{cfei.expression_id}.#{i}"
|
841
|
-
efei = @environment_id
|
842
|
-
rawexp = RawExpression.new_raw(
|
843
|
-
cfei, @fei, efei, @application_context, OpenWFE::fulldup(child))
|
844
|
-
get_expression_pool.update(rawexp)
|
845
|
-
i += 1
|
846
|
-
@children << rawexp.fei
|
847
|
-
end
|
848
|
-
end
|
849
|
-
end
|
850
|
-
|
851
|
-
#
|
852
|
-
# If the varname starts with '//' will return the engine
|
853
|
-
# environment and the truncated varname...
|
854
|
-
# If the varname starts with '/' will return the root environment
|
855
|
-
# for the current process instance and the truncated varname...
|
856
|
-
#
|
857
|
-
def lookup_environment (varname)
|
858
|
-
|
859
|
-
return [
|
860
|
-
get_expression_pool.fetch_engine_environment, varname[2..-1]
|
861
|
-
] if varname[0, 2] == '//'
|
862
|
-
|
863
|
-
return [
|
864
|
-
get_environment.get_root_environment, varname[1..-1]
|
865
|
-
] if varname[0, 1] == '/'
|
866
|
-
|
867
|
-
[ get_environment, varname ]
|
868
|
-
end
|
869
|
-
end
|
870
|
-
|
871
|
-
end
|
872
|
-
|