openwferu 0.9.13 → 0.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/examples/bigflow.rb +19 -0
  2. data/examples/csv_weather.rb +23 -0
  3. data/examples/engine_template.rb +7 -0
  4. data/lib/openwfe/contextual.rb +0 -2
  5. data/lib/openwfe/engine/engine.rb +137 -34
  6. data/lib/openwfe/engine/file_persisted_engine.rb +0 -5
  7. data/lib/openwfe/exceptions.rb +0 -2
  8. data/lib/openwfe/expool/errorjournal.rb +83 -7
  9. data/lib/openwfe/expool/expressionpool.rb +279 -60
  10. data/lib/openwfe/expool/expstorage.rb +7 -6
  11. data/lib/openwfe/expool/yamlexpstorage.rb +17 -14
  12. data/lib/openwfe/expressions/condition.rb +10 -7
  13. data/lib/openwfe/expressions/environment.rb +11 -1
  14. data/lib/openwfe/expressions/fe_command.rb +14 -1
  15. data/lib/openwfe/expressions/fe_cron.rb +29 -14
  16. data/lib/openwfe/expressions/fe_define.rb +26 -1
  17. data/lib/openwfe/expressions/fe_iterator.rb +2 -0
  18. data/lib/openwfe/expressions/fe_losfor.rb +20 -15
  19. data/lib/openwfe/expressions/fe_misc.rb +0 -2
  20. data/lib/openwfe/expressions/fe_participant.rb +78 -24
  21. data/lib/openwfe/expressions/fe_reserve.rb +0 -2
  22. data/lib/openwfe/expressions/fe_sleep.rb +0 -4
  23. data/lib/openwfe/expressions/fe_subprocess.rb +34 -0
  24. data/lib/openwfe/expressions/fe_value.rb +46 -4
  25. data/lib/openwfe/expressions/fe_wait.rb +0 -2
  26. data/lib/openwfe/expressions/flowexpression.rb +39 -9
  27. data/lib/openwfe/expressions/raw.rb +73 -48
  28. data/lib/openwfe/expressions/raw_prog.rb +45 -15
  29. data/lib/openwfe/expressions/simplerep.rb +54 -7
  30. data/lib/openwfe/expressions/time.rb +5 -2
  31. data/lib/openwfe/expressions/timeout.rb +0 -2
  32. data/lib/openwfe/flowexpressionid.rb +26 -2
  33. data/lib/openwfe/participants/enoparticipants.rb +6 -1
  34. data/lib/openwfe/participants/participant.rb +0 -2
  35. data/lib/openwfe/participants/participantmap.rb +21 -7
  36. data/lib/openwfe/participants/participants.rb +29 -0
  37. data/lib/openwfe/rest/exception.rb +0 -2
  38. data/lib/openwfe/storage/yamlfilestorage.rb +4 -1
  39. data/lib/openwfe/util/dollar.rb +0 -2
  40. data/lib/openwfe/util/lru.rb +0 -2
  41. data/lib/openwfe/util/observable.rb +1 -1
  42. data/lib/openwfe/util/scheduler.rb +4 -4
  43. data/lib/openwfe/util/schedulers.rb +0 -2
  44. data/lib/openwfe/util/workqueue.rb +34 -91
  45. data/lib/openwfe/utils.rb +35 -28
  46. data/lib/openwfe/version.rb +1 -1
  47. data/lib/openwfe/workitem.rb +1 -1
  48. data/test/clone_test.rb +51 -0
  49. data/test/concurrence_test.rb +78 -0
  50. data/test/cron_test_2.rb +50 -0
  51. data/test/flowtestbase.rb +40 -12
  52. data/test/ft_21_cron.rb +32 -6
  53. data/test/ft_26_load.rb +8 -2
  54. data/test/ft_26c_load.rb +19 -0
  55. data/test/ft_27_getflowpos.rb +4 -4
  56. data/test/ft_2_concurrence.rb +14 -9
  57. data/test/ft_32_journal.rb +1 -1
  58. data/test/ft_32c_journal.rb +3 -2
  59. data/test/ft_32d_journal.rb +2 -1
  60. data/test/ft_34_cancelwfid.rb +7 -3
  61. data/test/ft_35_localdefs.rb +13 -0
  62. data/test/ft_38_tag.rb +8 -6
  63. data/test/ft_49_condition.rb +7 -1
  64. data/test/ft_55_ptimeout.rb +13 -14
  65. data/test/ft_57_a.rb +17 -0
  66. data/test/ft_58_ejournal.rb +3 -3
  67. data/test/ft_59_ps.rb +6 -6
  68. data/test/ft_60_ecancel.rb +3 -5
  69. data/test/ft_61_elsub.rb +2 -4
  70. data/test/ft_63_pause.rb +122 -0
  71. data/test/ft_64_alias.rb +102 -0
  72. data/test/ft_64_clone.rb +69 -0
  73. data/test/ft_65_stringlaunch.rb +61 -0
  74. data/test/ft_66_subforget.rb +70 -0
  75. data/test/ft_67_schedlaunch.rb +102 -0
  76. data/test/ft_68_ifparticipant.rb +70 -0
  77. data/test/ft_69_cancelmissing.rb +49 -0
  78. data/test/ft_6_lambda.rb +23 -3
  79. data/test/ft_70_lookupvar.rb +55 -0
  80. data/test/ft_7_lose.rb +1 -1
  81. data/test/ft_tests.rb +10 -1
  82. data/test/hparticipant_test.rb +6 -6
  83. data/test/param_test.rb +1 -1
  84. data/test/{rake_test.rb → rake_ltest.rb} +9 -2
  85. data/test/rake_qtest.rb +3 -1
  86. data/test/raw_prog_test.rb +11 -3
  87. data/test/restart_sleep_test.rb +44 -6
  88. data/test/ruby_procdef_test.rb +129 -0
  89. data/test/rutest_utils.rb +1 -0
  90. data/test/sec_test.rb +3 -3
  91. metadata +19 -4
@@ -90,11 +90,12 @@ module OpenWFE
90
90
  class ExpressionPool
91
91
  include ServiceMixin
92
92
  include OwfeServiceLocator
93
- include Observable
93
+ include OwfeObservable
94
94
  include WorkqueueMixin
95
95
  include FeiMixin
96
96
  include MonitorMixin
97
97
 
98
+
98
99
  #
99
100
  # code loaded from a remote URI will get evaluated with
100
101
  # that security level
@@ -113,6 +114,9 @@ module OpenWFE
113
114
 
114
115
  @stopped = false
115
116
 
117
+ engine_environment_id
118
+ # makes sure it's called now
119
+
116
120
  start_workqueue
117
121
  end
118
122
 
@@ -137,7 +141,7 @@ module OpenWFE
137
141
  #
138
142
  def get_monitor (fei)
139
143
 
140
- return @monitors[fei]
144
+ @monitors[fei]
141
145
  end
142
146
 
143
147
  #
@@ -186,7 +190,10 @@ module OpenWFE
186
190
  # Returns the FlowExpressionId instance of the root expression of
187
191
  # the newly launched flow.
188
192
  #
189
- def launch (launchitem)
193
+ def launch (launchitem, options)
194
+
195
+ #
196
+ # prepare raw expression
190
197
 
191
198
  raw_expression = prepare_raw_expression launchitem
192
199
  #
@@ -199,10 +206,16 @@ module OpenWFE
199
206
  # it has to have an environment for all the variables of
200
207
  # the process instance
201
208
 
202
- wi = build_workitem launchitem
209
+ raw_expression = wrap_in_schedule(raw_expression, options) \
210
+ if options and options.size > 0
203
211
 
204
212
  fei = raw_expression.fei
205
213
 
214
+ #
215
+ # apply prepared raw expression
216
+
217
+ wi = build_workitem launchitem
218
+
206
219
  onotify :launch, fei, launchitem
207
220
 
208
221
  apply raw_expression, wi
@@ -220,15 +233,15 @@ module OpenWFE
220
233
  def prepare_from_template (
221
234
  requesting_expression, sub_id, template, params=nil)
222
235
 
223
- rawexp = if template.is_a? RawExpression
236
+ rawexp = if template.is_a?(RawExpression)
224
237
  template
225
- elsif template.is_a? FlowExpressionId
238
+ elsif template.is_a?(FlowExpressionId)
226
239
  fetch_expression(template)
227
240
  else
228
241
  build_raw_expression(nil, template)
229
242
  end
230
243
 
231
- #raise "did not find expression at #{template.to_s}" \
244
+ #raise "did not find subprocess in : #{template.to_s}" \
232
245
  # unless rawexp
233
246
 
234
247
  rawexp = rawexp.dup()
@@ -239,13 +252,13 @@ module OpenWFE
239
252
  rawexp.parent_id = nil
240
253
  rawexp.fei.workflow_instance_id = get_wfid_generator.generate
241
254
 
242
- elsif requesting_expression.kind_of? FlowExpressionId
255
+ elsif requesting_expression.kind_of?(FlowExpressionId)
243
256
 
244
257
  rawexp.parent_id = requesting_expression
245
258
  rawexp.fei.workflow_instance_id = \
246
259
  "#{requesting_expression.workflow_instance_id}.#{sub_id}"
247
260
 
248
- elsif requesting_expression.kind_of? String
261
+ elsif requesting_expression.kind_of?(String)
249
262
 
250
263
  rawexp.parent_id = nil
251
264
  rawexp.fei.workflow_instance_id = \
@@ -312,7 +325,6 @@ module OpenWFE
312
325
  #
313
326
  def apply (exp, workitem)
314
327
 
315
- #do_apply exp, workitem
316
328
  queue_work :do_apply, exp, workitem
317
329
  end
318
330
 
@@ -321,7 +333,6 @@ module OpenWFE
321
333
  #
322
334
  def reply (exp, workitem)
323
335
 
324
- #do_reply exp, workitem
325
336
  queue_work :do_reply, exp, workitem
326
337
  end
327
338
 
@@ -407,6 +418,58 @@ module OpenWFE
407
418
  ldebug { "forget() forgot #{fei}" }
408
419
  end
409
420
 
421
+ #
422
+ # Pauses a process (sets its '/__paused__' variable to true).
423
+ #
424
+ def pause_process (wfid)
425
+
426
+ wfid = extract_wfid(wfid)
427
+
428
+ root_expression = fetch_root(wfid)
429
+
430
+ root_expression.set_variable(VAR_PAUSED, true)
431
+ end
432
+
433
+ #
434
+ # Restarts a process : removes its 'paused' flag (variable) and makes
435
+ # sure to 'replay' events (replies) that came for it while it was
436
+ # in pause.
437
+ #
438
+ def resume_process (wfid)
439
+
440
+ wfid = extract_wfid(wfid)
441
+
442
+ root_expression = fetch_root(wfid)
443
+
444
+ #
445
+ # remove 'paused' flag
446
+
447
+ root_expression.unset_variable(VAR_PAUSED)
448
+
449
+ #
450
+ # replay
451
+
452
+ journal = get_error_journal
453
+
454
+ # select PausedError instances in separate list
455
+
456
+ errors = journal.get_error_log(wfid)
457
+ error_class = PausedError.name
458
+ paused_errors = errors.select { |e| e.error_class == error_class }
459
+
460
+ return if paused_errors.size < 1
461
+
462
+ # remove them from current error journal
463
+
464
+ journal.remove_errors wfid, paused_errors
465
+
466
+ # replay select PausedError instances
467
+
468
+ paused_errors.each do |e|
469
+ journal.replay_at_error e
470
+ end
471
+ end
472
+
410
473
  #
411
474
  # Replies to the parent of the given expression.
412
475
  #
@@ -552,6 +615,8 @@ module OpenWFE
552
615
  #
553
616
  def fetch_engine_environment ()
554
617
  synchronize do
618
+ #
619
+ # synchronize to ensure that there's 1! engine env
555
620
 
556
621
  eei = engine_environment_id
557
622
  ee, fei = fetch(eei)
@@ -575,7 +640,7 @@ module OpenWFE
575
640
  exp, _fei = fetch(exp) \
576
641
  if exp.kind_of?(FlowExpressionId)
577
642
 
578
- return if not exp
643
+ return unless exp
579
644
 
580
645
  ldebug { "remove() fe #{exp.fei.to_debug_s}" }
581
646
 
@@ -603,18 +668,19 @@ module OpenWFE
603
668
 
604
669
  t = OpenWFE::Timer.new
605
670
 
606
- ldebug { "reschedule() initiating..." }
671
+ linfo { "reschedule() initiating..." }
607
672
 
608
673
  get_expression_storage.each_of_kind(Schedulable) do |fe|
609
674
 
610
- ldebug { "reschedule() for #{fe.fei.to_debug_s}..." }
675
+ #linfo { "reschedule() for #{fe.fei.to_debug_s}..." }
676
+ linfo { "reschedule() for #{fe.fei.to_s}..." }
611
677
 
612
678
  onotify :reschedule, fe.fei
613
679
 
614
680
  fe.reschedule(get_scheduler)
615
681
  end
616
682
 
617
- ldebug { "reschedule() done. (took #{t.duration} ms)" }
683
+ linfo { "reschedule() done. (took #{t.duration} ms)" }
618
684
  end
619
685
  end
620
686
 
@@ -624,22 +690,22 @@ module OpenWFE
624
690
  # 'singleton' method.
625
691
  #
626
692
  def engine_environment_id ()
627
- synchronize do
628
-
629
- return @eei if @eei
630
-
631
- @eei = FlowExpressionId.new
632
- @eei.owfe_version = OPENWFERU_VERSION
633
- @eei.engine_id = get_engine.service_name
634
- @eei.initial_engine_id = @eei.engine_id
635
- @eei.workflow_definition_url = 'ee'
636
- @eei.workflow_definition_name = 'ee'
637
- @eei.workflow_definition_revision = '0'
638
- @eei.workflow_instance_id = '0'
639
- @eei.expression_name = EN_ENVIRONMENT
640
- @eei.expression_id = '0'
641
- @eei
642
- end
693
+ #synchronize do
694
+
695
+ return @eei if @eei
696
+
697
+ @eei = FlowExpressionId.new
698
+ @eei.owfe_version = OPENWFERU_VERSION
699
+ @eei.engine_id = get_engine.service_name
700
+ @eei.initial_engine_id = @eei.engine_id
701
+ @eei.workflow_definition_url = 'ee'
702
+ @eei.workflow_definition_name = 'ee'
703
+ @eei.workflow_definition_revision = '0'
704
+ @eei.workflow_instance_id = '0'
705
+ @eei.expression_name = EN_ENVIRONMENT
706
+ @eei.expression_id = '0'
707
+ @eei
708
+ #end
643
709
  end
644
710
 
645
711
  #
@@ -716,32 +782,67 @@ module OpenWFE
716
782
  list_processes(false, wfid)[0]
717
783
  end
718
784
 
785
+ #
786
+ # This method is called when apply() or reply() failed for
787
+ # an expression.
788
+ # There are currently only two 'users', the ParticipantExpression
789
+ # class and the do_process_workelement method of this ExpressionPool
790
+ # class.
791
+ #
792
+ def notify_error (error, fei, message, workitem)
793
+
794
+ fei = extract_fei fei
795
+ # densha requires that... :(
796
+
797
+ se = OpenWFE::exception_to_s(error)
798
+
799
+ onotify :error, fei, message, workitem, error.class.name, se
800
+
801
+ #fei = extract_fei fei
802
+
803
+ if error.is_a?(PausedError)
804
+ lwarn do
805
+ "#{self.service_name} " +
806
+ "operation :#{message.to_s} on #{fei.to_s} " +
807
+ "delayed because process '#{fei.wfid}' is in pause"
808
+ end
809
+ else
810
+ lwarn do
811
+ "#{self.service_name} " +
812
+ "operation :#{message.to_s} on #{fei.to_s} " +
813
+ "failed with\n" + se
814
+ end
815
+ end
816
+ end
817
+
719
818
  protected
720
819
 
820
+ #--
821
+ # Returns true if it's the fei of a participant
822
+ # (or of a subprocess ref)
823
+ #
824
+ #def is_participant? (fei)
825
+ # exp_name = fei.expression_name
826
+ # return true if exp_name == "participant"
827
+ # (get_expression_map.get_class(exp_name) == nil)
828
+ #end
829
+ #++
830
+
721
831
  #
722
832
  # This method is called by the workqueue when processing
723
833
  # the atomic work operations.
724
834
  #
725
835
  def do_process_workelement elt
726
836
 
837
+ message, fei, workitem = elt
838
+
727
839
  begin
728
840
 
729
- message, fei, workitem = elt
730
841
  send message, fei, workitem
731
842
 
732
843
  rescue Exception => e
733
844
 
734
- se = OpenWFE::exception_to_s(e)
735
-
736
- onotify :error, fei, message, workitem, se
737
-
738
- fei = extract_fei fei
739
-
740
- lwarn do
741
- "#{self.service_name} " +
742
- "operation :#{message.to_s} on #{fei.to_s} " +
743
- "failed with\n" + se
744
- end
845
+ notify_error(e, fei, message, workitem)
745
846
  end
746
847
  end
747
848
 
@@ -750,13 +851,18 @@ module OpenWFE
750
851
  #
751
852
  def do_apply (exp, workitem)
752
853
 
753
- exp, fei = fetch(exp) if exp.kind_of? FlowExpressionId
854
+ exp, fei = fetch(exp) if exp.kind_of?(FlowExpressionId)
855
+
856
+ check_if_paused exp
754
857
 
755
858
  #ldebug { "apply() '#{fei}' (#{fei.class})" }
756
859
 
757
860
  if not exp
861
+
758
862
  lwarn { "apply() cannot apply missing #{fei.to_debug_s}" }
759
863
  return
864
+
865
+ #raise "apply() cannot apply missing #{fei.to_debug_s}"
760
866
  end
761
867
 
762
868
  #ldebug { "apply() #{fei.to_debug_s}" }
@@ -782,6 +888,8 @@ module OpenWFE
782
888
  ldebug { "reply() to #{fei.to_debug_s}" }
783
889
  ldebug { "reply() from #{workitem.last_expression_id.to_debug_s}" }
784
890
 
891
+ check_if_paused exp
892
+
785
893
  if not exp
786
894
  #raise "cannot reply to missing #{fei.to_debug_s}"
787
895
  lwarn { "reply() cannot reply to missing #{fei.to_debug_s}" }
@@ -793,6 +901,91 @@ module OpenWFE
793
901
  exp.reply(workitem)
794
902
  end
795
903
 
904
+ #
905
+ # Will raise an exception if the expression belongs to a paused
906
+ # process.
907
+ #
908
+ def check_if_paused (expression)
909
+
910
+ return unless expression
911
+
912
+ raise PausedError.new(expression.fei.wfid) \
913
+ if expression.paused?
914
+ end
915
+
916
+ #
917
+ # if the launch method is called with a schedule option
918
+ # (like :at, :in, :cron and :every), this method takes care of
919
+ # wrapping the process with a sleep or a cron.
920
+ #
921
+ def wrap_in_schedule (raw_expression, options)
922
+
923
+ oat = options[:at]
924
+ oin = options[:in]
925
+ ocron = options[:cron]
926
+ oevery = options[:every]
927
+
928
+ fei = new_fei(nil, "schedlaunch", "0", "sequence")
929
+
930
+ # not very happy with this code, it builds custom
931
+ # wrapping processes manually, maybe there is
932
+ # a more elegant way, but for now, it's ok.
933
+
934
+ if oat or oin
935
+
936
+ seq = get_expression_map.get_class(:sequence)
937
+ seq = seq.new(fei, nil, nil, application_context, nil)
938
+
939
+ att = if oat
940
+ { "until" => oat }
941
+ else #oin
942
+ { "for" => oin }
943
+ end
944
+
945
+ sle = get_expression_map.get_class(:sleep)
946
+ sle = sle.new(fei.dup, fei, nil, application_context, att)
947
+ sle.fei.expression_id = "0.1"
948
+ sle.fei.expression_name = "sleep"
949
+ seq.children << sle.fei
950
+ seq.children << raw_expression.fei
951
+
952
+ seq.new_environment
953
+ sle.environment_id = seq.environment_id
954
+
955
+ sle.store_itself
956
+ seq.store_itself
957
+
958
+ raw_expression.store_itself
959
+ raw_expression = seq
960
+
961
+ elsif ocron or oevery
962
+
963
+ fei.expression_name = "cron"
964
+
965
+ att = if ocron
966
+ { "tab" => ocron }
967
+ else #oevery
968
+ { "every" => oevery }
969
+ end
970
+ att["name"] = "//cron_launch__#{fei.wfid}"
971
+
972
+ cro = get_expression_map.get_class(:cron)
973
+ cro = cro.new(fei, nil, nil, application_context, att)
974
+
975
+ cro.children << raw_expression.fei
976
+
977
+ cro.new_environment
978
+
979
+ cro.store_itself
980
+
981
+ raw_expression.store_itself
982
+ raw_expression = cro
983
+ end
984
+ # else, don't schedule at all
985
+
986
+ raw_expression
987
+ end
988
+
796
989
  #
797
990
  # Removes an environment, especially takes care of unbinding
798
991
  # any special value it may contain.
@@ -803,6 +996,10 @@ module OpenWFE
803
996
 
804
997
  env, fei = fetch(environment_id)
805
998
 
999
+ return unless env
1000
+ #
1001
+ # env already unbound and removed
1002
+
806
1003
  env.unbind
807
1004
 
808
1005
  #get_expression_storage().delete(environment_id)
@@ -891,16 +1088,12 @@ module OpenWFE
891
1088
  #
892
1089
  # else it's some ruby code to eval
893
1090
 
894
- o = OpenWFE::eval_safely(param, SAFETY_LEVEL)
895
-
896
- return o.do_make \
897
- if o.is_a?(ProcessDefinition) or o.is_a?(Class)
898
-
899
- o
1091
+ ProcessDefinition::eval_ruby_process_definition(
1092
+ param, SAFETY_LEVEL)
900
1093
  end
901
1094
 
902
1095
  #
903
- # Builds a FlowExpressionId instance for process being
1096
+ # Builds a FlowExpressionId instance for a process being
904
1097
  # launched.
905
1098
  #
906
1099
  def new_fei (launchitem, flow_name, flow_revision, exp_name)
@@ -953,6 +1146,41 @@ module OpenWFE
953
1146
  end
954
1147
  end
955
1148
 
1149
+ #
1150
+ # This error is raised when an expression belonging to a paused
1151
+ # process is applied or replied to.
1152
+ #
1153
+ class PausedError < RuntimeError
1154
+
1155
+ attr_reader :wfid
1156
+
1157
+ def initialize (wfid)
1158
+
1159
+ super "process '#{wfid}' is paused"
1160
+ @wfid = wfid
1161
+ end
1162
+
1163
+ #
1164
+ # Returns a hash for this PausedError instance.
1165
+ # (simply returns the hash of the paused process' wfid).
1166
+ #
1167
+ def hash
1168
+
1169
+ @wfid.hash
1170
+ end
1171
+
1172
+ #
1173
+ # Returns true if the other is a PausedError issued for the
1174
+ # same process instance (wfid).
1175
+ #
1176
+ def == (other)
1177
+
1178
+ return false unless other.is_a?(PausedError)
1179
+
1180
+ (@wfid == other.wfid)
1181
+ end
1182
+ end
1183
+
956
1184
  #
957
1185
  # a small help class for storing monitors provided on demand
958
1186
  # to expressions that need them
@@ -972,15 +1200,6 @@ module OpenWFE
972
1200
  synchronize do
973
1201
 
974
1202
  (@monitors[key] ||= Monitor.new)
975
- #if not mon
976
- # #ldebug { "[] creating new Monitor for #{key}" }
977
- # mon = Monitor.new
978
- # @monitors[key] = mon
979
- #else
980
- # #ldebug { "[] already had Monitor for #{key}" }
981
- #end
982
- #
983
- #mon
984
1203
  end
985
1204
  end
986
1205
 
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -116,7 +114,7 @@ module OpenWFE
116
114
 
117
115
  @cache[fei.hash] = fe
118
116
 
119
- return fe
117
+ fe
120
118
  end
121
119
 
122
120
  def []= (fei, fe)
@@ -194,7 +192,7 @@ module OpenWFE
194
192
  @real_storage =
195
193
  @application_context[S_EXPRESSION_STORAGE + ".1"]
196
194
 
197
- return @real_storage
195
+ @real_storage
198
196
  end
199
197
  end
200
198
 
@@ -271,6 +269,8 @@ module OpenWFE
271
269
  #
272
270
  # a small help method for expression storages...
273
271
  #
272
+ # TODO : put that in a module !
273
+ #
274
274
  def expstorage_to_s (expstorage)
275
275
 
276
276
  s = "\n\n==== #{expstorage.class} ===="
@@ -282,12 +282,13 @@ module OpenWFE
282
282
  else
283
283
  s << " "
284
284
  end
285
- s << v.to_s
285
+ #s << v.to_s
286
+ s << v.fei.to_s
286
287
  s << " key/value mismatch !" if k != v.fei
287
288
  end
288
289
  s << "\n==== . ====\n"
289
290
 
290
- return s
291
+ s
291
292
  end
292
293
 
293
294
  end
@@ -75,15 +75,17 @@ module OpenWFE
75
75
 
76
76
  return unless block
77
77
 
78
- exp_names = get_expression_map.get_expression_names(kind)
79
-
80
78
  each_object_path do |path|
81
79
 
82
80
  #ldebug { "each_of_kind() path is #{path}" }
83
81
 
84
- next unless matches(path, exp_names)
82
+ #next unless matches(path, kind)
83
+ # was not OK in case of <bob activity="clean office" />
85
84
 
86
85
  expression = load_object(path)
86
+
87
+ next unless expression.is_a?(kind)
88
+
87
89
  expression.application_context = @application_context
88
90
 
89
91
  block.call expression
@@ -179,19 +181,20 @@ module OpenWFE
179
181
  fei.expression_name + ".yaml"
180
182
  end
181
183
 
182
- #
184
+ #--
183
185
  # Returns true if the path points to a file containing an
184
- # expression whose name is in exp_names.
186
+ # expression whose name is in the list of expression names
187
+ # corresponding to the given kind (class) of expressions.
185
188
  #
186
- def matches (path, exp_names)
187
-
188
- exp_names.each do |exp_name|
189
- return true \
190
- if OpenWFE::ends_with(path, "_#{exp_name}.yaml")
191
- end
192
-
193
- false
194
- end
189
+ #def matches (path, kind)
190
+ # exp_names = get_expression_map.get_expression_names(kind)
191
+ # exp_names.each do |exp_name|
192
+ # return true \
193
+ # if OpenWFE::ends_with(path, "_#{exp_name}.yaml")
194
+ # end
195
+ # false
196
+ #end
197
+ #++
195
198
  end
196
199
 
197
200
  #
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -112,7 +110,7 @@ module OpenWFE
112
110
  conditional = lookup_attribute(attname, workitem)
113
111
  rconditional = lookup_attribute("r"+attname.to_s, workitem)
114
112
 
115
- return do_eval(rconditional) \
113
+ return do_eval(rconditional, workitem) \
116
114
  if rconditional and not conditional
117
115
 
118
116
  return nil \
@@ -125,7 +123,7 @@ module OpenWFE
125
123
  ldebug { "do_eval_condition() 1 for '#{conditional}'" }
126
124
 
127
125
  begin
128
- return to_boolean(do_eval(conditional))
126
+ return to_boolean(do_eval(conditional, workitem))
129
127
  rescue Exception => e
130
128
  # probably needs some quoting...
131
129
  end
@@ -134,7 +132,7 @@ module OpenWFE
134
132
 
135
133
  ldebug { "do_eval_condition() 2 for '#{conditional}'" }
136
134
 
137
- to_boolean(do_eval(conditional))
135
+ to_boolean(do_eval(conditional, workitem))
138
136
  end
139
137
 
140
138
  private
@@ -195,8 +193,13 @@ module OpenWFE
195
193
  # Runs the given given within an instance_eval() at a $SAFE
196
194
  # level of 3.
197
195
  #
198
- def do_eval (s)
199
- OpenWFE::instance_eval_safely(self, s, 3)
196
+ def do_eval (s, workitem)
197
+
198
+ #OpenWFE::instance_eval_safely(self, s, 3)
199
+
200
+ wi = workitem
201
+ fe = self
202
+ OpenWFE::eval_safely(s, 3, binding())
200
203
  end
201
204
  end
202
205