openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -80,13 +80,15 @@ module OpenWFE
80
80
  #
81
81
  # A small method for ensuring we have a workflow instance id.
82
82
  #
83
- def to_wfid (fei_or_wfid)
84
- wfid = fei_or_wfid
85
- wfid = wfid.parent_wfid if wfid.kind_of?(FlowExpressionId)
86
- wfid.to_s
87
- end
83
+ def extract_wfid (o, parent=false)
88
84
 
89
- alias :extract_wfid :to_wfid
85
+ case o
86
+ #when String then o
87
+ when FlowExpressionId then o.wfid(parent)
88
+ when FlowExpression then o.fei.wfid(parent)
89
+ else o.to_s
90
+ end
91
+ end
90
92
  end
91
93
 
92
94
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2005-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2005-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -32,7 +32,7 @@
32
32
  #
33
33
 
34
34
  #
35
- # "hecho en Costa Rica"
35
+ # "hecho en Costa Rica" (with just the PickAxe at hand)
36
36
  #
37
37
 
38
38
  require 'base64'
@@ -243,13 +243,13 @@ module OpenWFE
243
243
  #
244
244
  # atomic types
245
245
 
246
- return xmlElt.text \
246
+ return xmlElt.text.strip \
247
247
  if xmlElt.name == E_STRING
248
- return Integer(xmlElt.text) \
248
+ return Integer(xmlElt.text.strip) \
249
249
  if xmlElt.name == E_INTEGER
250
- return Integer(xmlElt.text) \
250
+ return Integer(xmlElt.text.strip) \
251
251
  if xmlElt.name == E_LONG
252
- return Float(xmlElt.text) \
252
+ return Float(xmlElt.text.strip) \
253
253
  if xmlElt.name == E_DOUBLE
254
254
  return parse_boolean(xmlElt.text) \
255
255
  if xmlElt.name == E_BOOLEAN
@@ -315,6 +315,9 @@ module OpenWFE
315
315
  #puts "decodeEntry() k >#{key}< v >#{val}<"
316
316
  #puts "decodeEntry() subject '#{val}'" if key == '__subject__'
317
317
 
318
+ key = key.strip if key.is_a?(String)
319
+ val = val.strip if val.is_a?(String)
320
+
318
321
  map[key] = val
319
322
  end
320
323
 
@@ -631,19 +634,20 @@ module OpenWFE
631
634
 
632
635
  #return xml if xml.is_a?(String)
633
636
 
634
- if decl and (not xml[0].is_a?(REXML::XMLDecl))
635
- xml << REXML::XMLDecl.new()
636
- end
637
+ xml << REXML::XMLDecl.new \
638
+ if decl and (not xml[0].is_a?(REXML::XMLDecl))
637
639
 
638
- s = ""
639
- xml.write(s, 0)
640
- return s
640
+ #s = ""
641
+ #xml.write(s, 0)
642
+ #return s
643
+ xml.to_s
641
644
  end
642
645
 
643
646
  #
644
647
  # An alias for OpenWFE::xmldoc_to_string()
645
648
  #
646
649
  def OpenWFE.xml_to_s (xml, decl=true)
650
+
647
651
  OpenWFE::xmldoc_to_string(xml, decl)
648
652
  end
649
653
 
@@ -0,0 +1,38 @@
1
+ #
2
+ #--
3
+ # Copyright (c) 2007, John Mettraux, OpenWFE.org
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are met:
8
+ #
9
+ # . Redistributions of source code must retain the above copyright notice, this
10
+ # list of conditions and the following disclaimer.
11
+ #
12
+ # . Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ #
16
+ # . Neither the name of the "OpenWFE" nor the names of its contributors may be
17
+ # used to endorse or promote products derived from this software without
18
+ # specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+ #++
32
+ #
33
+
34
+ # just for nicer looking examples
35
+
36
+ #require 'openwfe/participants/participants'
37
+ require 'openwfe/worklist/storeparticipant'
38
+
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ require 'openwfe/service'
42
42
  require 'openwfe/util/observable'
43
43
  require 'openwfe/participants/participants'
44
44
 
45
- include OpenWFE
45
+ #include OpenWFE
46
46
 
47
47
 
48
48
  module OpenWFE
@@ -53,8 +53,7 @@ module OpenWFE
53
53
  class ParticipantMap < Service
54
54
  include OwfeObservable
55
55
 
56
- attr_accessor \
57
- :participants
56
+ attr_accessor :participants
58
57
 
59
58
  def initialize (service_name, application_context)
60
59
 
@@ -77,9 +76,18 @@ module OpenWFE
77
76
  # This method is called by the engine's own register_participant()
78
77
  # method.
79
78
  #
80
- # The participant instance is returned by this method call
79
+ # The participant instance is returned by this method call.
81
80
  #
82
- def register_participant (regex, participant=nil, &block)
81
+ # The know params are :participant (a participant instance or
82
+ # class) and :position (which can be null or :first).
83
+ #
84
+ # By default (if :position is not set to :first), the participant
85
+ # will appear at the bottom of the participant list.
86
+ #
87
+ def register_participant (regex, params, &block)
88
+
89
+ participant = params[:participant]
90
+ position = params[:position]
83
91
 
84
92
  if not participant
85
93
 
@@ -94,7 +102,7 @@ module OpenWFE
94
102
  "participant class is #{participant.class}"
95
103
  end
96
104
 
97
- if participant.kind_of?(Class)
105
+ if participant.is_a?(Class)
98
106
 
99
107
  ldebug { "register_participant() class #{participant}" }
100
108
 
@@ -132,9 +140,15 @@ module OpenWFE
132
140
  regex.instance_variable_set '@original_string', original_string
133
141
 
134
142
  participant.application_context = @application_context \
135
- if participant.respond_to? :application_context=
143
+ if participant.respond_to?(:application_context=)
144
+
145
+ # now add the participant to the list
146
+
147
+ entry = [ regex, participant ]
148
+
149
+ index = (position == :first) ? 0 : -1
136
150
 
137
- @participants << [ regex, participant ]
151
+ @participants.insert index, entry
138
152
 
139
153
  participant
140
154
  end
@@ -196,7 +210,7 @@ module OpenWFE
196
210
 
197
211
  workitem.dispatch_time = Time.now
198
212
 
199
- participant.consume(workitem)
213
+ participant.consume workitem
200
214
 
201
215
  onotify :dispatch, :after_consume, workitem
202
216
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -175,7 +175,7 @@ module OpenWFE
175
175
 
176
176
  reply_to_engine(workitem) \
177
177
  if workitem.kind_of? InFlowWorkItem
178
- # else it's a cancel item
178
+ # else it's a cancel ite
179
179
  end
180
180
  end
181
181
 
@@ -350,7 +350,8 @@ module OpenWFE
350
350
 
351
351
  get_expression_pool.launch_template(
352
352
  get_flow_expression(workitem),
353
- 0, #sub_id
353
+ nil, # new environment
354
+ 0, # sub_id
354
355
  @template,
355
356
  workitem)
356
357
  #params)
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -85,6 +85,9 @@ module OpenWFE
85
85
  def get_wfid_generator
86
86
  @application_context[S_WFID_GENERATOR]
87
87
  end
88
+ def get_expool
89
+ @application_context[S_EXPRESSION_POOL]
90
+ end
88
91
  def get_expression_pool
89
92
  @application_context[S_EXPRESSION_POOL]
90
93
  end
@@ -111,12 +114,11 @@ module OpenWFE
111
114
  # (there is usually a cache and a persisted exp storage).
112
115
  #
113
116
  def get_expression_storages
114
- result = []
115
- @application_context.each do |k, v|
116
- result << v \
117
- if OpenWFE::starts_with(k.to_s, S_EXPRESSION_STORAGE)
117
+
118
+ @application_context.inject([]) do |r, (k, v)|
119
+ r << v if OpenWFE::starts_with(k.to_s, S_EXPRESSION_STORAGE)
120
+ r
118
121
  end
119
- result
120
122
  end
121
123
  end
122
124
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -101,16 +101,16 @@ module OpenWFE
101
101
  end
102
102
  end
103
103
 
104
- #
104
+ #--
105
105
  # opening for tuning yaml persistence
106
106
  #
107
- class XmlRawExpression
108
-
109
- def to_yaml_properties
110
- l = super()
111
- l.delete("@raw_representation")
112
- l
113
- end
114
- end
107
+ #class XmlRawExpression
108
+ # def to_yaml_properties
109
+ # l = super()
110
+ # l.delete("@raw_representation")
111
+ # l
112
+ # end
113
+ #end
114
+ #++
115
115
  end
116
116
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, Nicolas Modryzk and John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, Nicolas Modryzk and John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -47,7 +47,7 @@ require 'openwfe/utils'
47
47
  require 'openwfe/service'
48
48
 
49
49
  require 'openwfe/expressions/flowexpression'
50
- require 'openwfe/expressions/raw_xml'
50
+ #require 'openwfe/expressions/raw_xml'
51
51
  #--
52
52
  # making sure classes in those files are loaded
53
53
  # before their yaml persistence is tuned
@@ -125,9 +125,9 @@ module OpenWFE
125
125
 
126
126
  fei_path = compute_file_path(fei)
127
127
 
128
- #ldebug do
129
- # "delete()\n for #{fei.to_debug_s}\n at #{fei_path}"
130
- #end
128
+ ldebug do
129
+ "delete()\n for #{fei.to_debug_s}\n at #{fei_path}"
130
+ end
131
131
 
132
132
  File.delete(fei_path)
133
133
  end
@@ -195,19 +195,19 @@ module OpenWFE
195
195
  #
196
196
  # Passes each object path to the given block
197
197
  #
198
- def each_object_path (&block)
198
+ def each_object_path (path=@basepath, &block)
199
199
 
200
200
  #return unless block
201
201
 
202
202
  synchronize do
203
- Find.find(@basepath) do |path|
203
+ Find.find(path) do |p|
204
204
 
205
- next unless File.exist? path
206
- next if File.stat(path).directory?
207
- next unless OpenWFE::ends_with(path, ".yaml")
205
+ next unless File.exist?(p)
206
+ next if File.stat(p).directory?
207
+ next unless OpenWFE::ends_with(p, ".yaml")
208
208
 
209
- ldebug { "each_object_path() considering #{path}" }
210
- block.call path
209
+ ldebug { "each_object_path() considering #{p}" }
210
+ block.call p
211
211
  end
212
212
  end
213
213
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -42,15 +42,16 @@
42
42
  require 'openwfe/workitem'
43
43
  require 'openwfe/engine/engine'
44
44
 
45
- include OpenWFE
45
+ #include OpenWFE
46
46
 
47
47
 
48
48
  module OpenWFE
49
49
 
50
50
  def trace_flow (process_definition)
51
- li = LaunchItem.new(process_definition)
52
51
 
53
- engine = Engine.new()
52
+ li = LaunchItem.new process_definition
53
+
54
+ engine = Engine.new
54
55
 
55
56
  i = 0
56
57
 
@@ -73,7 +74,7 @@ module OpenWFE
73
74
  i = i + 1
74
75
  end
75
76
 
76
- engine.launch(li)
77
+ engine.launch li
77
78
  end
78
79
 
79
80
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -37,8 +37,11 @@
37
37
  # John Mettraux at openwfe.org
38
38
  #
39
39
 
40
+ #require 'rubygems'
41
+ require 'rufus/dollar' # gem 'rufus-dollar'
42
+ require 'rufus/eval' # gem 'rufus-eval'
43
+
40
44
  require 'openwfe/utils'
41
- require 'openwfe/util/safe'
42
45
 
43
46
  #
44
47
  # 'dollar notation' implementation in Ruby
@@ -46,99 +49,36 @@ require 'openwfe/util/safe'
46
49
 
47
50
  module OpenWFE
48
51
 
49
- DSUB_SAFETY_LEVEL = 3
52
+ DSUB_SAFETY_LEVEL = 4
50
53
  #
51
54
  # Ruby code ${ruby:...} will be evaluated with this
52
55
  # safety level.
53
56
  # (see http://www.rubycentral.com/book/taint.html )
54
57
 
55
- #
56
- # Performs 'dollar substitution' on a piece of text with a given
57
- # dictionary.
58
- #
59
- def OpenWFE.dsub (text, dict)
60
-
61
- text = text.to_s
62
-
63
- #puts "### text is >#{text}<"
64
- #puts "### dict is of class #{dict.class.name}"
65
-
66
- #return nil unless text
67
-
68
- j = text.index("}")
69
-
70
- return text if not j
71
-
72
- t = text[0, j]
73
-
74
- i = t.rindex("${")
75
- ii = t.rindex("\\${")
76
-
77
- #puts "i is #{i}"
78
- #puts "ii is #{ii}"
79
-
80
- return text if not i
81
-
82
- return unescape(text) if (i) and (i != 0) and (ii == i-1)
83
- #
84
- # found "\${"
85
-
86
- key = text[i+2..j-1]
87
-
88
- #puts "### key is '#{key}'"
89
-
90
- value = dict[key]
91
-
92
- #puts "### value 0 is '#{value}'"
93
-
94
- value = if value
95
- value.to_s
96
- else
97
- if dict.has_key?(key)
98
- "false"
99
- else
100
- ""
101
- end
102
- end
103
-
104
- #puts "### value 1 is '#{value}'"
105
-
106
- #puts "pre is >#{text[0..i-1]}<"
107
- #puts "post is >#{text[j+1..-1]}<"
108
-
109
- pre = if i > 0
110
- text[0..i-1]
111
- else
112
- ""
113
- end
114
-
115
- dsub("#{pre}#{value}#{text[j+1..-1]}", dict)
116
- end
117
-
118
- def OpenWFE.unescape (text)
119
- text.gsub("\\\\\\$\\{", "\\${")
120
- end
121
-
122
58
  #
123
59
  # Performs 'dollar substitution' on a piece of text with as input
124
60
  # a flow expression and a workitem (fields and variables).
125
61
  #
126
62
  def OpenWFE.dosub (text, flow_expression, workitem)
127
- dsub(text, FlowDict.new(flow_expression, workitem))
63
+
64
+ Rufus::dsub(text, FlowDict.new(flow_expression, workitem))
128
65
  end
129
66
 
130
67
  #
131
68
  # Wrapping a process expression and the current workitem as a
132
69
  # Hash object ready for lookup at substitution time.
133
70
  #
134
- class FlowDict < Hash
71
+ class FlowDict
72
+
73
+ def initialize (flow_expression, workitem, default_prefix='v')
135
74
 
136
- def initialize (flow_expression, workitem)
137
75
  @flow_expression = flow_expression
138
76
  @workitem = workitem
77
+ @default_prefix = default_prefix
139
78
  end
140
79
 
141
80
  def [] (key)
81
+
142
82
  p, k = extract_prefix(key)
143
83
 
144
84
  #puts "### p, k is '#{p}', '#{k}'"
@@ -149,17 +89,31 @@ module OpenWFE
149
89
 
150
90
  if p == 'v'
151
91
  return '' unless @flow_expression
152
- return @flow_expression.lookup_variable(k)
92
+ return @flow_expression.lookup_variable(k)
153
93
  end
154
94
 
155
- return call_function(k) if p == 'c'
95
+ #return call_function(k) if p == 'c'
156
96
  return call_ruby(k) if p == 'r'
157
- # TODO : implement constant lookup
158
97
 
159
- @workitem.lookup_attribute(key)
98
+ @workitem.lookup_attribute key
99
+ end
100
+
101
+ def []= (key, value)
102
+
103
+ pr, k = extract_prefix(key)
104
+
105
+ if pr == 'f'
106
+
107
+ @workitem.set_attribute k, value
108
+
109
+ elsif @flow_expression
110
+
111
+ @flow_expression.set_variable k, value
112
+ end
160
113
  end
161
114
 
162
115
  def has_key? (key)
116
+
163
117
  p, k = extract_prefix(key)
164
118
 
165
119
  return false if k == ''
@@ -171,9 +125,8 @@ module OpenWFE
171
125
  return (@flow_expression.lookup_variable(k) != nil)
172
126
  end
173
127
 
174
- return true if p == 'c'
128
+ #return true if p == 'c'
175
129
  return true if p == 'r'
176
- # TODO : implement constant lookup
177
130
 
178
131
  @workitem.has_attribute?(key)
179
132
  end
@@ -182,14 +135,18 @@ module OpenWFE
182
135
 
183
136
  def extract_prefix (key)
184
137
  i = key.index(':')
185
- return 'v', key if not i
138
+ return @default_prefix, key if not i
186
139
  [ key[0..0], key[i+1..-1] ]
187
140
  end
188
141
 
189
- def call_function (function_name)
190
- #"function '#{function_name}' is not implemented"
191
- "functions are not yet implemented"
192
- end
142
+ #--
143
+ #def call_function (function_name)
144
+ # #"function '#{function_name}' is not implemented"
145
+ # "functions are not yet implemented"
146
+ # #
147
+ # # no need for them... we have Ruby :)
148
+ #end
149
+ #++
193
150
 
194
151
  def call_ruby (ruby_code)
195
152
 
@@ -221,7 +178,7 @@ module OpenWFE
221
178
  #eval(ruby_code, binding).to_s
222
179
  #eval(ruby_code).to_s
223
180
 
224
- OpenWFE::eval_safely(
181
+ Rufus::eval_safely(
225
182
  ruby_code, DSUB_SAFETY_LEVEL, binding()).to_s
226
183
  end
227
184
  end