openwferu 0.9.13 → 0.9.14

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -29,6 +29,7 @@
29
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
+ #
32
33
 
33
34
  #
34
35
  # "made in Japan"
@@ -46,6 +47,12 @@ require 'openwfe/util/dollar'
46
47
 
47
48
  module OpenWFE
48
49
 
50
+ #
51
+ # When this variable is set to true (at the process root),
52
+ # it means the process is paused.
53
+ #
54
+ VAR_PAUSED = '/__paused__'
55
+
49
56
  #
50
57
  # FlowExpression
51
58
  #
@@ -76,6 +83,8 @@ module OpenWFE
76
83
  @application_context = app_context
77
84
  @attributes = attributes
78
85
 
86
+ @children = []
87
+
79
88
  @apply_time = nil
80
89
 
81
90
  #ldebug do
@@ -93,6 +102,7 @@ module OpenWFE
93
102
  # parent expression
94
103
  #
95
104
  def apply (workitem)
105
+
96
106
  get_parent().reply(workitem) if @parent_id
97
107
  end
98
108
 
@@ -101,6 +111,7 @@ module OpenWFE
101
111
  # parent expression
102
112
  #
103
113
  def reply (workitem)
114
+
104
115
  reply_to_parent(workitem)
105
116
  end
106
117
 
@@ -111,6 +122,7 @@ module OpenWFE
111
122
  # should resume without them.
112
123
  #
113
124
  def reply_to_parent (workitem)
125
+
114
126
  get_expression_pool.reply_to_parent(self, workitem)
115
127
  end
116
128
 
@@ -186,21 +198,23 @@ module OpenWFE
186
198
  # just before the engine environment in the hierarchy).
187
199
  #
188
200
  def get_root_environment
201
+
189
202
  fetch_environment.get_root_environment
190
203
  end
191
204
 
192
- #
205
+ #--
193
206
  # A shortcut for fetch_environment.get_process_environment
194
207
  #
195
208
  #def get_subprocess_environment
196
209
  # fetch_environment.get_subprocess_environment
197
210
  #end
211
+ #++
198
212
 
199
213
  #
200
214
  # Just fetches the environment for this expression.
201
215
  #
202
216
  def fetch_environment
203
- #return nil unless @environment_id
217
+
204
218
  get_expression_pool.fetch_expression @environment_id
205
219
  end
206
220
 
@@ -230,7 +244,15 @@ module OpenWFE
230
244
  # " env #{vi.to_debug_s}"
231
245
  #end
232
246
 
233
- return ei == vi
247
+ ei == vi
248
+ end
249
+
250
+ #
251
+ # Returns true if this expression belongs to a paused flow
252
+ #
253
+ def paused?
254
+
255
+ lookup_variable(VAR_PAUSED) == true
234
256
  end
235
257
 
236
258
  #
@@ -278,6 +300,8 @@ module OpenWFE
278
300
  env.delete var
279
301
  end
280
302
 
303
+ alias :unset_variable :delete_variable
304
+
281
305
  #
282
306
  # Looks up the value for an attribute of this expression.
283
307
  #
@@ -341,7 +365,8 @@ module OpenWFE
341
365
 
342
366
  value = lookup_attribute(attname, workitem)
343
367
  return default if not value
344
- return value.downcase == 'true'
368
+
369
+ (value.downcase == 'true')
345
370
  end
346
371
 
347
372
  #
@@ -399,7 +424,8 @@ module OpenWFE
399
424
  elt = elt.strip
400
425
  result << elt if elt.length > 0
401
426
  end
402
- return result
427
+
428
+ result
403
429
  end
404
430
 
405
431
  #
@@ -427,7 +453,7 @@ module OpenWFE
427
453
 
428
454
  ldebug { "new_environment() is #{env.fei.to_debug_s}" }
429
455
 
430
- return env.store_itself()
456
+ env.store_itself()
431
457
  end
432
458
 
433
459
  #
@@ -437,12 +463,14 @@ module OpenWFE
437
463
  # Returns the duplicated environment.
438
464
  #
439
465
  def dup_environment
466
+
440
467
  env = fetch_environment
441
468
  env = env.dup
442
469
  env.fei = @fei.dup
443
470
  env.fei.expression_name = EN_ENVIRONMENT
444
471
  @environment_id = env.fei
445
- return env.store_itself
472
+
473
+ env.store_itself
446
474
  end
447
475
 
448
476
  #
@@ -476,7 +504,7 @@ module OpenWFE
476
504
  #
477
505
  def get_binding
478
506
 
479
- return binding()
507
+ binding()
480
508
  end
481
509
 
482
510
  #
@@ -528,7 +556,9 @@ module OpenWFE
528
556
  #
529
557
  def lookup_value (workitem, prefix='')
530
558
 
531
- lookup_vf_attribute(workitem, 'value', prefix)
559
+ v = lookup_vf_attribute(workitem, 'value', prefix)
560
+ v = lookup_vf_attribute(workitem, 'val', prefix) unless v
561
+ v
532
562
  end
533
563
 
534
564
  #
@@ -37,10 +37,9 @@
37
37
  # John Mettraux at openwfe.org
38
38
  #
39
39
 
40
- #require 'rexml/document'
41
-
42
- require 'openwfe/rudefinitions'
40
+ require 'openwfe/exceptions'
43
41
  require 'openwfe/expressions/flowexpression'
42
+ require 'openwfe/rudefinitions'
44
43
 
45
44
 
46
45
  module OpenWFE
@@ -53,8 +52,8 @@ module OpenWFE
53
52
  #
54
53
  class RawExpression < FlowExpression
55
54
 
56
- def initialize \
57
- (fei, parent_id, env_id, application_context, raw_representation)
55
+ def initialize (
56
+ fei, parent_id, env_id, application_context, raw_representation)
58
57
 
59
58
  super(fei, parent_id, env_id, application_context, nil)
60
59
 
@@ -65,12 +64,13 @@ module OpenWFE
65
64
  # now done in the launch methods of the expression pool
66
65
  end
67
66
 
68
- def instantiate_real_expression \
69
- (workitem, exp_class=nil, attributes=nil)
67
+ def instantiate_real_expression (
68
+ workitem, exp_name=nil, exp_class=nil, attributes=nil)
70
69
 
70
+ exp_name = expression_name() unless exp_name
71
71
  exp_class = expression_class() unless exp_class
72
72
 
73
- raise "unknown expression '#{expression_name}'" \
73
+ raise "unknown expression '#{exp_name}'" \
74
74
  unless exp_class
75
75
 
76
76
  #ldebug do
@@ -97,50 +97,16 @@ module OpenWFE
97
97
  expression
98
98
  end
99
99
 
100
+ #
101
+ # When a raw expression is applied, it gets turned into the
102
+ # real expression which then gets applied.
103
+ #
100
104
  def apply (workitem)
101
105
 
102
- exp_name = expression_name()
103
-
104
- exp_class = expression_class()
105
- attributes = nil
106
-
107
- template = lookup_variable(exp_name)
108
- #
109
- # is it a subprocess ?
110
-
111
- if ((not template) and (not exp_class))
112
-
113
- template = get_participant_map.lookup_participant(exp_name)
114
-
115
- unless template
116
- exp_name = OpenWFE::to_underscore(exp_name)
117
- template = get_participant_map.lookup_participant(exp_name)
118
- end
119
- end
120
- #
121
- # is it a directly a participant ?
122
-
123
- if template
124
-
125
- if template.kind_of? OpenWFE::FlowExpressionId
126
-
127
- exp_class = OpenWFE::SubProcessRefExpression
128
- attributes = extract_attributes()
129
- attributes["ref"] = exp_name
130
-
131
- elsif template.kind_of? OpenWFE::Participant
132
-
133
- exp_class = OpenWFE::ParticipantExpression
134
- attributes = extract_attributes()
135
- attributes["ref"] = exp_name
136
- end
137
- end
138
-
139
- #
140
- # the classical case...
106
+ exp_name, exp_class, attributes = determine_real_expression
141
107
 
142
108
  expression = instantiate_real_expression(
143
- workitem, exp_class, attributes)
109
+ workitem, exp_name, exp_class, attributes)
144
110
 
145
111
  #expression.apply_time = OpenWFE::now()
146
112
  #
@@ -195,6 +161,65 @@ module OpenWFE
195
161
 
196
162
  protected
197
163
 
164
+ #
165
+ # looks up a participant in the participant map, considers
166
+ # "my-participant" and "my_participant" as the same
167
+ # (by doing two lookups).
168
+ #
169
+ def lookup_participant (name)
170
+
171
+ p = get_participant_map.lookup_participant(name)
172
+
173
+ unless p
174
+ name = OpenWFE::to_underscore(name)
175
+ p = get_participant_map.lookup_participant(name)
176
+ end
177
+
178
+ if p
179
+ name
180
+ else
181
+ nil
182
+ end
183
+ end
184
+
185
+ #
186
+ # Determines if this raw expression points to a classical
187
+ # expression, a participant or a subprocess, or nothing at all...
188
+ #
189
+ def determine_real_expression ()
190
+
191
+ exp_name = expression_name()
192
+
193
+ exp_class = expression_class()
194
+ attributes = nil
195
+
196
+ var_value = lookup_variable(exp_name)
197
+
198
+ var_value = exp_name if (not exp_class and not var_value)
199
+
200
+ if var_value
201
+ attributes = extract_attributes()
202
+ end
203
+
204
+ if var_value.is_a?(String)
205
+
206
+ participant_name = lookup_participant(var_value)
207
+
208
+ if participant_name
209
+ exp_name = participant_name
210
+ exp_class = OpenWFE::ParticipantExpression
211
+ attributes['ref'] = participant_name
212
+ end
213
+
214
+ elsif var_value.is_a?(OpenWFE::FlowExpressionId)
215
+
216
+ exp_class = OpenWFE::SubProcessRefExpression
217
+ attributes['ref'] = exp_name
218
+ end
219
+
220
+ [ exp_name, exp_class, attributes ]
221
+ end
222
+
198
223
  #
199
224
  # Takes care of extracting the process definition descriptions
200
225
  # if any and to set the description variables accordingly.
@@ -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"
@@ -92,9 +90,8 @@ module OpenWFE
92
90
 
93
91
  def self.method_missing (m, *args, &block)
94
92
 
95
- #puts "__c_method_missing >>>#{m}<<<<"
96
-
97
- @ccontext = Context.new() unless @ccontext
93
+ @ccontext = Context.new() \
94
+ if (not @ccontext) or @ccontext.discarded?
98
95
 
99
96
  ProcessDefinition.make_expression(
100
97
  @ccontext,
@@ -103,14 +100,6 @@ module OpenWFE
103
100
  &block)
104
101
  end
105
102
 
106
- #
107
- # This method has to be overriden in order to define
108
- # a process definition.
109
- #
110
- def make
111
- raise "make() implementation is missing, please provide one"
112
- end
113
-
114
103
  def self.make_expression (context, exp_name, params, &block)
115
104
 
116
105
  string_child = nil
@@ -169,6 +158,8 @@ module OpenWFE
169
158
  def ProcessDefinition.do_make (instance=nil)
170
159
 
171
160
  context = if @ccontext
161
+ @ccontext.discard
162
+ # preventing further additions in case of reevaluation
172
163
  @ccontext
173
164
  elsif instance
174
165
  instance.make
@@ -196,9 +187,41 @@ module OpenWFE
196
187
  top_expression
197
188
  end
198
189
 
190
+ #
191
+ # Parses the string to find the class name of the process definition
192
+ # and returns that class (instance).
193
+ #
194
+ def self.extract_class (ruby_proc_def_string)
195
+
196
+ ruby_proc_def_string.each_line do |l|
197
+
198
+ m = l.match " *class *([a-zA-Z0-9]*) *< .*ProcessDefinition"
199
+ return eval(m[1]) if m
200
+ end
201
+
202
+ nil
203
+ end
204
+
205
+ #
206
+ # Turns a String containing a ProcessDefinition ...
207
+ #
208
+ def self.eval_ruby_process_definition (code, safety_level=2)
209
+
210
+ o = OpenWFE::eval_safely(code, safety_level)
211
+
212
+ o = extract_class(code) \
213
+ if (o == nil) or o.is_a?(SimpleExpRepresentation)
214
+
215
+ return o.do_make \
216
+ if o.is_a?(ProcessDefinition) or o.is_a?(Class)
217
+
218
+ o
219
+ end
220
+
199
221
  protected
200
222
 
201
223
  def ProcessDefinition.pack_args (args)
224
+
202
225
  return args[0] if args.length == 1
203
226
  a = {}
204
227
  args.each_with_index do |arg, index|
@@ -236,8 +259,8 @@ module OpenWFE
236
259
 
237
260
  class Context
238
261
 
239
- attr_accessor :parent_expression
240
- attr_reader :top_expressions, :previous_parent_expressions
262
+ attr_accessor :parent_expression, :top_expressions
263
+ attr_reader :previous_parent_expressions
241
264
 
242
265
  def initialize
243
266
  @parent_expression = nil
@@ -245,6 +268,13 @@ module OpenWFE
245
268
  @previous_parent_expressions = []
246
269
  end
247
270
 
271
+ def discard
272
+ @discarded = true
273
+ end
274
+ def discarded?
275
+ (@discarded == true)
276
+ end
277
+
248
278
  #
249
279
  # puts the current parent expression on top of the 'previous
250
280
  # parent expressions' stack, the current parent expression
@@ -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"
@@ -60,6 +58,7 @@ module OpenWFE
60
58
  :children
61
59
 
62
60
  def initialize (name, attributes)
61
+
63
62
  super()
64
63
  @name = name
65
64
  @attributes = attributes
@@ -77,7 +76,8 @@ module OpenWFE
77
76
  # Always return the ProgRawExpression class.
78
77
  #
79
78
  def raw_expression_class
80
- return ProgRawExpression
79
+
80
+ ProgRawExpression
81
81
  end
82
82
 
83
83
  #
@@ -85,11 +85,13 @@ module OpenWFE
85
85
  # in the classical OpenWFE process definition language.
86
86
  #
87
87
  def to_s
88
+
88
89
  doc = REXML::Document.new()
89
90
  doc << to_xml
90
91
  s = ""
91
92
  doc.write(s, 0)
92
- return s
93
+
94
+ s
93
95
  end
94
96
 
95
97
  #
@@ -112,7 +114,7 @@ module OpenWFE
112
114
  end
113
115
  end
114
116
 
115
- return elt
117
+ elt
116
118
  end
117
119
 
118
120
  #
@@ -154,6 +156,31 @@ module OpenWFE
154
156
  rep
155
157
  end
156
158
 
159
+ #
160
+ # Evals the given code (string) into a SimpleExpRepresentation.
161
+ #
162
+ def self.from_code (code)
163
+
164
+ ProcessDefinition.eval_ruby_process_definition code
165
+ end
166
+
167
+ #
168
+ # Evals the given string a return its SimpleExpRepresentation
169
+ # equivalent, ready for evaluation or rendering (fluo).
170
+ #
171
+ def self.from_s (s)
172
+
173
+ s = s.strip
174
+
175
+ if s[0, 1] == "<"
176
+
177
+ from_xml s
178
+ else
179
+
180
+ from_code s
181
+ end
182
+ end
183
+
157
184
  #
158
185
  # Returns a string containing the ruby code that generated this
159
186
  # raw representation tree.
@@ -176,7 +203,7 @@ module OpenWFE
176
203
  if @children.length > 0
177
204
  s << " do\n"
178
205
  @children.each do |child|
179
- if child.respond_to? :to_code_s
206
+ if child.respond_to?(:to_code_s)
180
207
  s << child.to_code_s(indentation + 1)
181
208
  else
182
209
  s << ind
@@ -189,7 +216,27 @@ module OpenWFE
189
216
  s << "end"
190
217
  end
191
218
 
192
- return s
219
+ s
220
+ end
221
+
222
+ #
223
+ # Turns this simple representation into an array
224
+ # (something suitable for to_json()).
225
+ #
226
+ def to_a
227
+
228
+ cs = @children.collect do |child|
229
+
230
+ if child.respond_to?(:to_a)
231
+
232
+ child.to_a
233
+ else
234
+
235
+ child.to_s
236
+ end
237
+ end
238
+
239
+ [ @name, @attributes, cs ]
193
240
  end
194
241
  end
195
242
 
@@ -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"
@@ -76,6 +74,10 @@ module OpenWFE
76
74
  end
77
75
  end
78
76
 
77
+ #
78
+ # If the expression has been scheduled, a call to this method
79
+ # will make sure it's unscheduled (removed from the scheduler).
80
+ #
79
81
  def unschedule ()
80
82
 
81
83
  ldebug { "unschedule() @scheduler_job_id is #{@scheduler_job_id}" }
@@ -145,6 +147,7 @@ module OpenWFE
145
147
  end
146
148
 
147
149
  def cancel ()
150
+
148
151
  to_unschedule()
149
152
  super()
150
153
  end
@@ -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"
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: workitem.rb 3555 2006-11-13 00:47:53Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "hecho en Costa Rica"
@@ -77,6 +75,10 @@ module OpenWFE
77
75
  alias :expid :expression_id
78
76
  alias :expid= :expression_id=
79
77
 
78
+ alias :expname :expression_name
79
+ alias :wfname :workflow_definition_name
80
+ alias :wfrevision :workflow_definition_revision
81
+
80
82
  #
81
83
  # Overrides the classical to_s()
82
84
  #
@@ -88,6 +90,7 @@ module OpenWFE
88
90
  # Returns a hash version of this FlowExpressionId instance.
89
91
  #
90
92
  def to_h ()
93
+
91
94
  h = {}
92
95
  FIELDS.each { |f| h[f] = instance_eval("@#{f.to_s}") }
93
96
  h
@@ -97,6 +100,7 @@ module OpenWFE
97
100
  # Rebuilds a FlowExpressionId from its Hash representation.
98
101
  #
99
102
  def FlowExpressionId.from_h (h)
103
+
100
104
  fei = FlowExpressionId.new
101
105
  FIELDS.each { |f| fei.instance_variable_set("@#{f}", h[f]) }
102
106
  fei
@@ -107,6 +111,7 @@ module OpenWFE
107
111
  end
108
112
 
109
113
  def == (other)
114
+
110
115
  return false if not other.kind_of?(FlowExpressionId)
111
116
 
112
117
  #return self.to_s == other.to_s
@@ -147,7 +152,11 @@ module OpenWFE
147
152
  OpenWFE::starts_with other_fei.expression_id, @expression_id
148
153
  end
149
154
 
155
+ #
156
+ # Returns a deep copy of this FlowExpressionId instance.
157
+ #
150
158
  def dup
159
+
151
160
  OpenWFE::fulldup(self)
152
161
  end
153
162
 
@@ -157,10 +166,25 @@ module OpenWFE
157
166
  "(fei #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_id} #{@expression_name})"
158
167
  end
159
168
 
169
+ #
170
+ # Returns a very short string representation (fei wfid expid expname).
171
+ #
160
172
  def to_short_s
161
173
  "(fei #{@workflow_instance_id} #{@expression_id} #{@expression_name})"
162
174
  end
163
175
 
176
+ #
177
+ # Returns a URI escaped string with just the wfid and the expid, like
178
+ # '20070917-dupibodasa__0.0.1'
179
+ #
180
+ # Useful for unique identifier in URIs.
181
+ #
182
+ def to_web_s
183
+
184
+ eid = expid.gsub("\.", "_")
185
+ URI.escape("#{workflow_instance_id}__#{eid}")
186
+ end
187
+
164
188
  #
165
189
  # Yet another debugging method. Just returns the sub_instance_id and
166
190
  # the expression_id, in a string.
@@ -75,6 +75,9 @@ module OpenWFE
75
75
  # <tt>email_target</tt> field to "foo@nowhere.com" prior to feeding it
76
76
  # to the mail participant.
77
77
  #
78
+ # Likewise, you can also override the :from_address value by setting the
79
+ # workitems <tt>email_from</tt> field.
80
+ #
78
81
  # When passing the mail template as a block, you have
79
82
  # four possible arities :
80
83
  # { |workitem| ... }
@@ -127,13 +130,15 @@ module OpenWFE
127
130
  "(no template given)"
128
131
  end
129
132
 
133
+ from_address = workitem.email_from rescue @from_address
134
+
130
135
  puts "msg >>>\n#{msg}<<<"
131
136
 
132
137
  #
133
138
  # 2. Send message
134
139
 
135
140
  Net::SMTP.start(@smtp_server, @smtp_port) do |smtp|
136
- smtp.send_message(msg, @from_address, to_address)
141
+ smtp.send_message(msg, from_address, to_address)
137
142
  end
138
143
 
139
144
  #
@@ -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"