openwferu 0.9.15 → 0.9.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/README.txt +4 -2
  2. data/lib/openwfe/engine/engine.rb +143 -25
  3. data/lib/openwfe/engine/file_persisted_engine.rb +3 -3
  4. data/lib/openwfe/expool/errorjournal.rb +48 -25
  5. data/lib/openwfe/expool/expressionpool.rb +77 -106
  6. data/lib/openwfe/expool/expstorage.rb +6 -5
  7. data/lib/openwfe/expool/threadedexpstorage.rb +190 -0
  8. data/lib/openwfe/expool/yamlexpstorage.rb +5 -150
  9. data/lib/openwfe/expressions/condition.rb +6 -6
  10. data/lib/openwfe/expressions/environment.rb +7 -2
  11. data/lib/openwfe/expressions/expressionmap.rb +14 -0
  12. data/lib/openwfe/expressions/fe_command.rb +2 -1
  13. data/lib/openwfe/expressions/fe_concurrence.rb +40 -18
  14. data/lib/openwfe/expressions/fe_cron.rb +14 -11
  15. data/lib/openwfe/expressions/fe_cursor.rb +2 -3
  16. data/lib/openwfe/expressions/fe_define.rb +34 -31
  17. data/lib/openwfe/expressions/fe_equals.rb +11 -21
  18. data/lib/openwfe/expressions/fe_filter_definition.rb +0 -2
  19. data/lib/openwfe/expressions/fe_fqv.rb +1 -3
  20. data/lib/openwfe/expressions/fe_if.rb +37 -12
  21. data/lib/openwfe/expressions/fe_iterator.rb +1 -1
  22. data/lib/openwfe/expressions/fe_listen.rb +147 -28
  23. data/lib/openwfe/expressions/fe_losfor.rb +13 -1
  24. data/lib/openwfe/expressions/fe_misc.rb +70 -11
  25. data/lib/openwfe/expressions/fe_participant.rb +3 -3
  26. data/lib/openwfe/expressions/fe_reserve.rb +1 -1
  27. data/lib/openwfe/expressions/fe_save.rb +11 -12
  28. data/lib/openwfe/expressions/fe_sequence.rb +22 -29
  29. data/lib/openwfe/expressions/fe_sleep.rb +11 -7
  30. data/lib/openwfe/expressions/fe_subprocess.rb +24 -10
  31. data/lib/openwfe/expressions/fe_value.rb +35 -15
  32. data/lib/openwfe/expressions/fe_when.rb +2 -4
  33. data/lib/openwfe/expressions/flowexpression.rb +73 -37
  34. data/lib/openwfe/expressions/merge.rb +2 -4
  35. data/lib/openwfe/expressions/raw.rb +40 -31
  36. data/lib/openwfe/expressions/raw_prog.rb +18 -9
  37. data/lib/openwfe/expressions/raw_xml.rb +1 -8
  38. data/lib/openwfe/expressions/simplerep.rb +27 -5
  39. data/lib/openwfe/expressions/time.rb +45 -15
  40. data/lib/openwfe/expressions/timeout.rb +2 -1
  41. data/lib/openwfe/expressions/wtemplate.rb +2 -2
  42. data/lib/openwfe/flowexpressionid.rb +62 -16
  43. data/lib/openwfe/listeners/listener.rb +28 -37
  44. data/lib/openwfe/listeners/listeners.rb +1 -1
  45. data/lib/openwfe/listeners/socketlisteners.rb +7 -15
  46. data/lib/openwfe/logging.rb +5 -4
  47. data/lib/openwfe/{rest → orest}/controlclient.rb +3 -5
  48. data/lib/openwfe/{rest → orest}/definitions.rb +0 -2
  49. data/lib/openwfe/{rest → orest}/exception.rb +0 -0
  50. data/lib/openwfe/{rest → orest}/oldrestservlet.rb +1 -1
  51. data/lib/openwfe/{rest → orest}/osocket.rb +1 -1
  52. data/lib/openwfe/{rest → orest}/restclient.rb +0 -2
  53. data/lib/openwfe/orest/workitem.rb +206 -0
  54. data/lib/openwfe/{rest → orest}/worklistclient.rb +15 -5
  55. data/lib/openwfe/{rest → orest}/xmlcodec.rb +4 -1
  56. data/lib/openwfe/participants/enoparticipants.rb +4 -14
  57. data/lib/openwfe/participants/participantmap.rb +16 -12
  58. data/lib/openwfe/participants/participants.rb +46 -1
  59. data/lib/openwfe/participants/socketparticipants.rb +1 -6
  60. data/lib/openwfe/service.rb +15 -6
  61. data/lib/openwfe/storage/yamlcustom.rb +3 -0
  62. data/lib/openwfe/storage/yamlfilestorage.rb +3 -1
  63. data/lib/openwfe/util/dollar.rb +21 -14
  64. data/lib/openwfe/util/lru.rb +29 -10
  65. data/lib/openwfe/util/observable.rb +4 -1
  66. data/lib/openwfe/util/otime.rb +3 -0
  67. data/lib/openwfe/util/scheduler.rb +346 -114
  68. data/lib/openwfe/utils.rb +67 -13
  69. data/lib/openwfe/version.rb +1 -1
  70. data/lib/openwfe/workitem.rb +22 -165
  71. data/lib/openwfe/worklist/oldrest.rb +2 -2
  72. data/test/bm/bm_1_xml_vs_prog.rb +56 -0
  73. data/test/{ft_26_load.rb → bm/ft_26_load.rb} +0 -0
  74. data/test/{ft_26b_load.rb → bm/ft_26b_load.rb} +0 -0
  75. data/test/{ft_26c_load.rb → bm/ft_26c_load.rb} +16 -4
  76. data/test/clone_test.rb +62 -0
  77. data/test/cron_test.rb +56 -1
  78. data/test/cronline_test.rb +17 -8
  79. data/test/description_test.rb +57 -0
  80. data/test/dollar_test.rb +17 -6
  81. data/test/eno_test.rb +22 -9
  82. data/test/fe_lookup_att_test.rb +50 -0
  83. data/test/fei_test.rb +18 -9
  84. data/test/flowtestbase.rb +24 -2
  85. data/test/ft_0.rb +10 -12
  86. data/test/ft_0e_multibody.rb +34 -0
  87. data/test/ft_10_loop.rb +4 -6
  88. data/test/ft_11_ppd.rb +5 -20
  89. data/test/ft_14b_subprocess.rb +2 -2
  90. data/test/ft_15_iterator.rb +56 -4
  91. data/test/ft_15b_iterator.rb +48 -0
  92. data/test/ft_16_fqv.rb +18 -3
  93. data/test/ft_23c_wait.rb +7 -5
  94. data/test/ft_25_cancel.rb +5 -3
  95. data/test/ft_27_getflowpos.rb +14 -11
  96. data/test/ft_28_fileparticipant.rb +3 -4
  97. data/test/ft_2_concurrence.rb +8 -12
  98. data/test/ft_2b_concurrence.rb +3 -2
  99. data/test/ft_30_socketlistener.rb +5 -6
  100. data/test/ft_32c_journal.rb +2 -2
  101. data/test/ft_32d_journal.rb +5 -6
  102. data/test/ft_33_description.rb +8 -3
  103. data/test/ft_34_cancelwfid.rb +3 -3
  104. data/test/ft_38_tag.rb +7 -10
  105. data/test/ft_39_reserve.rb +4 -2
  106. data/test/ft_3_equals.rb +18 -13
  107. data/test/ft_44b_restore.rb +2 -6
  108. data/test/ft_49_condition.rb +16 -12
  109. data/test/ft_4_misc.rb +51 -12
  110. data/test/ft_50_xml_attribute.rb +1 -1
  111. data/test/ft_54_listen.rb +96 -10
  112. data/test/ft_54b_listen.rb +68 -0
  113. data/test/ft_55_ptimeout.rb +1 -2
  114. data/test/ft_58_ejournal.rb +8 -33
  115. data/test/ft_59_ps.rb +2 -3
  116. data/test/ft_59b_ps_for_pat.rb +59 -0
  117. data/test/ft_5_time.rb +45 -4
  118. data/test/ft_60_ecancel.rb +7 -7
  119. data/test/ft_61_elsub.rb +1 -1
  120. data/test/ft_64_alias.rb +1 -1
  121. data/test/ft_67_schedlaunch.rb +29 -16
  122. data/test/ft_69_cancelmissing.rb +1 -1
  123. data/test/ft_6_lambda.rb +8 -6
  124. data/test/ft_70_lookupvar.rb +2 -2
  125. data/test/ft_71_log.rb +60 -0
  126. data/test/ft_72_lookup_processes.rb +79 -0
  127. data/test/ft_73_cancel_sub.rb +144 -0
  128. data/test/ft_74_block_and_workitem_dup.rb +63 -0
  129. data/test/ft_75_ruby_attributes.rb +87 -0
  130. data/test/ft_76_merge_isolate.rb +90 -0
  131. data/test/ft_7_lose.rb +2 -1
  132. data/test/ft_tests.rb +9 -0
  133. data/test/lookup_att_test.rb +90 -0
  134. data/test/misc_test.rb +33 -50
  135. data/test/orest_test.rb +1 -1
  136. data/test/participant_test.rb +32 -8
  137. data/test/pending.rb +6 -7
  138. data/test/rake_ltest.rb +3 -0
  139. data/test/rake_qtest.rb +4 -1
  140. data/test/raw_prog_test.rb +1 -1
  141. data/test/restart_cron_test.rb +6 -6
  142. data/test/restart_sleep_test.rb +8 -8
  143. data/test/ruby_procdef_test.rb +2 -2
  144. data/test/rutest_utils.rb +9 -3
  145. data/test/scheduler_1_test.rb +88 -0
  146. data/test/scheduler_test.rb +49 -4
  147. data/test/sec_test.rb +18 -11
  148. metadata +51 -34
  149. data/test/cron_test_2.rb +0 -50
@@ -57,6 +57,8 @@ module OpenWFE
57
57
 
58
58
  super(fei, parent_id, env_id, application_context, nil)
59
59
 
60
+ #linfo { "initialize() '#{fei.expression_name}'" }
61
+
60
62
  @raw_representation = raw_representation
61
63
 
62
64
  #new_environment() if not @environment_id
@@ -92,8 +94,6 @@ module OpenWFE
92
94
 
93
95
  expression.children = extract_children()
94
96
 
95
- expression.store_itself()
96
-
97
97
  expression
98
98
  end
99
99
 
@@ -108,11 +108,8 @@ module OpenWFE
108
108
  expression = instantiate_real_expression(
109
109
  workitem, exp_name, exp_class, attributes)
110
110
 
111
- #expression.apply_time = OpenWFE::now()
112
- #
113
- # This method is extremely costly, now avoiding it
114
-
115
111
  expression.apply_time = Time.now
112
+ expression.store_itself
116
113
 
117
114
  expression.apply workitem
118
115
  end
@@ -207,15 +204,17 @@ module OpenWFE
207
204
 
208
205
  if participant_name
209
206
  exp_name = participant_name
210
- exp_class = OpenWFE::ParticipantExpression
207
+ exp_class = ParticipantExpression
211
208
  attributes['ref'] = participant_name
212
209
  end
213
210
 
214
- elsif var_value.is_a?(OpenWFE::FlowExpressionId)
211
+ elsif var_value.is_a?(FlowExpressionId) \
212
+ or var_value.is_a?(RawExpression)
215
213
 
216
- exp_class = OpenWFE::SubProcessRefExpression
214
+ exp_class = SubProcessRefExpression
217
215
  attributes['ref'] = exp_name
218
216
  end
217
+ # else, it's a standard expression
219
218
 
220
219
  [ exp_name, exp_class, attributes ]
221
220
  end
@@ -237,30 +236,32 @@ module OpenWFE
237
236
  else
238
237
  "description__#{k}"
239
238
  end
240
- set_variable vname, description
239
+ set_variable vname, description.to_s
241
240
  end
242
241
 
243
242
  return if ds.length < 1
244
243
 
245
- set_variable "description", ds[0][1] \
244
+ set_variable "description", ds[0][1].to_s \
246
245
  unless default
247
246
  end
248
247
 
249
- def extract_attributes ()
250
- raise NotImplementedError.new("'abstract method' sorry")
251
- end
252
- def extract_children ()
253
- raise NotImplementedError.new("'abstract method' sorry")
254
- end
255
- def extract_descriptions ()
256
- raise NotImplementedError.new("'abstract method' sorry")
257
- end
258
- def extract_parameters ()
259
- raise NotImplementedError.new("'abstract method' sorry")
260
- end
261
- def extract_text_children ()
262
- raise NotImplementedError.new("'abstract method' sorry")
263
- end
248
+ #--
249
+ #def extract_attributes ()
250
+ # raise NotImplementedError.new("'abstract method' sorry")
251
+ #end
252
+ #def extract_children ()
253
+ # raise NotImplementedError.new("'abstract method' sorry")
254
+ #end
255
+ #def extract_descriptions ()
256
+ # raise NotImplementedError.new("'abstract method' sorry")
257
+ #end
258
+ #def extract_parameters ()
259
+ # raise NotImplementedError.new("'abstract method' sorry")
260
+ #end
261
+ #def extract_text_children ()
262
+ # raise NotImplementedError.new("'abstract method' sorry")
263
+ #end
264
+ #++
264
265
 
265
266
  #
266
267
  # Expressions can get tagged. Tagged expressions can easily
@@ -268,7 +269,7 @@ module OpenWFE
268
269
  #
269
270
  def consider_tag (workitem, new_expression)
270
271
 
271
- tagname = new_expression.lookup_attribute(:tag, workitem)
272
+ tagname = new_expression.lookup_string_attribute :tag, workitem
272
273
 
273
274
  return unless tagname
274
275
 
@@ -313,10 +314,10 @@ module OpenWFE
313
314
 
314
315
  def initialize (field, match, default, type)
315
316
 
316
- @field = field
317
- @match = match
318
- @default = default
319
- @type = type
317
+ @field = to_s field
318
+ @match = to_s match
319
+ @default = to_s default
320
+ @type = to_s type
320
321
  end
321
322
 
322
323
  #
@@ -347,6 +348,14 @@ module OpenWFE
347
348
 
348
349
  protected
349
350
 
351
+ #
352
+ # Used in the constructor to flatten everything to strings.
353
+ #
354
+ def to_s (o)
355
+ return nil unless o
356
+ o.to_s
357
+ end
358
+
350
359
  #
351
360
  # Will raise an exception if it cannot coerce the type
352
361
  # of the value to the one desired.
@@ -107,10 +107,14 @@ module OpenWFE
107
107
 
108
108
  #puts " ... params.class is #{params.class}"
109
109
 
110
- if params.kind_of? Hash
110
+ if params.kind_of?(Hash)
111
111
  params.each do |k, v|
112
- #attributes[k.to_s] = v.to_s
113
- attributes[OpenWFE::symbol_to_name(k.to_s)] = v.to_s
112
+ if k == '0'
113
+ string_child = v.to_s
114
+ else
115
+ #attributes[OpenWFE::symbol_to_name(k.to_s)] = v.to_s
116
+ attributes[OpenWFE::symbol_to_name(k.to_s)] = v
117
+ end
114
118
  end
115
119
  elsif params
116
120
  string_child = params.to_s
@@ -223,9 +227,10 @@ module OpenWFE
223
227
  def ProcessDefinition.pack_args (args)
224
228
 
225
229
  return args[0] if args.length == 1
230
+
226
231
  a = {}
227
232
  args.each_with_index do |arg, index|
228
- if arg.is_a? Hash
233
+ if arg.is_a?(Hash)
229
234
  a = a.merge(arg)
230
235
  break
231
236
  end
@@ -254,6 +259,7 @@ module OpenWFE
254
259
  end
255
260
 
256
261
  def ProcessDefinition.as_revision (s)
262
+
257
263
  s.gsub("_", ".")
258
264
  end
259
265
 
@@ -330,6 +336,7 @@ module OpenWFE
330
336
  protected
331
337
 
332
338
  def extract_attributes ()
339
+
333
340
  raw_representation.attributes
334
341
  end
335
342
 
@@ -356,7 +363,7 @@ module OpenWFE
356
363
  result = []
357
364
  raw_representation.children.each do |child|
358
365
 
359
- if child.kind_of? SimpleExpRepresentation
366
+ if child.kind_of?(SimpleExpRepresentation)
360
367
 
361
368
  cname = child.name.intern
362
369
 
@@ -373,7 +380,7 @@ module OpenWFE
373
380
  rawexp = ProgRawExpression\
374
381
  .new(cfei, @fei, efei, @application_context, child)
375
382
 
376
- get_expression_pool.update(rawexp)
383
+ get_expression_pool.update rawexp
377
384
 
378
385
  i = i + 1
379
386
 
@@ -387,8 +394,9 @@ module OpenWFE
387
394
  end
388
395
 
389
396
  def extract_text_children ()
397
+
390
398
  raw_representation.children.collect do |child|
391
- next if child.is_a? SimpleExpRepresentation
399
+ next if child.is_a?(SimpleExpRepresentation)
392
400
  child.to_s
393
401
  end
394
402
  end
@@ -398,9 +406,9 @@ module OpenWFE
398
406
  r = []
399
407
  raw_representation.children.each do |child|
400
408
 
401
- next unless child.is_a? SimpleExpRepresentation
409
+ next unless child.is_a?(SimpleExpRepresentation)
402
410
 
403
- name = child.name.intern
411
+ name = child.name.to_sym
404
412
  next unless (name == :parameter or name == :param)
405
413
 
406
414
  r << Parameter.new(
@@ -425,6 +433,7 @@ module OpenWFE
425
433
  #
426
434
  KEYWORDS = [
427
435
  :if, :do, :redo, :undo, :print, :sleep, :loop, :break, :when
436
+ #:until, :while
428
437
  ]
429
438
 
430
439
  #
@@ -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"
@@ -55,12 +53,7 @@ module OpenWFE
55
53
  def initialize \
56
54
  (fei, parent_id, env_id, application_context, raw_representation)
57
55
 
58
- super(
59
- fei,
60
- parent_id,
61
- env_id,
62
- application_context,
63
- raw_representation)
56
+ super
64
57
 
65
58
  @raw_representation_s = raw_representation.to_s
66
59
  end
@@ -48,6 +48,8 @@ module OpenWFE
48
48
  # A raw representation for a process definition, programmatic
49
49
  # process definitions are turned into trees of instances of this class.
50
50
  #
51
+ # It's just an s-expression somehow.
52
+ #
51
53
  class SimpleExpRepresentation
52
54
 
53
55
  attr_reader \
@@ -80,6 +82,24 @@ module OpenWFE
80
82
  ProgRawExpression
81
83
  end
82
84
 
85
+ #
86
+ # Finds the first child named 'description' and returns its
87
+ # first child as a String.
88
+ #
89
+ # TODO : manage languages, as specified in OpenWFE.
90
+ #
91
+ def get_description
92
+
93
+ return @children.first.to_s if @name == 'description'
94
+
95
+ @children.each do |child|
96
+ d = child.get_description
97
+ return d if d
98
+ end
99
+
100
+ nil
101
+ end
102
+
83
103
  #
84
104
  # Returns an XML string, containing the equivalent process definition
85
105
  # in the classical OpenWFE process definition language.
@@ -125,14 +145,16 @@ module OpenWFE
125
145
  def self.from_xml (xml)
126
146
 
127
147
  xml = REXML::Document.new(xml) \
128
- if xml.is_a? String
148
+ if xml.is_a?(String)
129
149
 
130
150
  xml = xml.root \
131
- if xml.is_a? REXML::Document
151
+ if xml.is_a?(REXML::Document)
132
152
 
133
- if xml.is_a? REXML::Text
134
- s = xml.to_s
135
- return s if s.strip.length > 1
153
+ if xml.is_a?(REXML::Text)
154
+ #s = xml.to_s
155
+ #return s if s.strip.length > 1
156
+ s = xml.to_s.strip
157
+ return s if s.length > 0
136
158
  return nil
137
159
  end
138
160
 
@@ -53,15 +53,26 @@ module OpenWFE
53
53
  class TimeExpression < FlowExpression
54
54
  include Schedulable
55
55
 
56
- attr_accessor \
57
- :applied_workitem,
58
- :scheduler_job_id
56
+ #
57
+ # The workitem received at apply time
58
+ #
59
+ attr_accessor :applied_workitem
60
+
61
+ #
62
+ # The job_id in the scheduler for this expression
63
+ #
64
+ attr_accessor :scheduler_job_id
65
+
66
+ #
67
+ # The tags (if any) for the job in the scheduler
68
+ #
69
+ attr_accessor :scheduler_tags
59
70
 
60
71
  #
61
72
  # Makes sure to cancel any scheduler job associated with this
62
73
  # expression
63
74
  #
64
- def cancel ()
75
+ def cancel
65
76
  synchronize do
66
77
 
67
78
  ldebug { "cancel()..." }
@@ -78,13 +89,27 @@ module OpenWFE
78
89
  # If the expression has been scheduled, a call to this method
79
90
  # will make sure it's unscheduled (removed from the scheduler).
80
91
  #
81
- def unschedule ()
92
+ def unschedule
82
93
 
83
94
  ldebug { "unschedule() @scheduler_job_id is #{@scheduler_job_id}" }
84
95
 
85
96
  get_scheduler.unschedule(@scheduler_job_id) \
86
97
  if @scheduler_job_id
87
98
  end
99
+
100
+ protected
101
+
102
+ def determine_scheduler_tags
103
+
104
+ st = lookup_attribute :scheduler_tags, @applied_workitem
105
+
106
+ @scheduler_tags = if st
107
+ st.split(",").collect { |s| s.strip }
108
+ else
109
+ []
110
+ end
111
+ @scheduler_tags << self.class.name
112
+ end
88
113
  end
89
114
 
90
115
  #
@@ -94,7 +119,8 @@ module OpenWFE
94
119
  # concentrated here.
95
120
  #
96
121
  class WaitingExpression < TimeExpression
97
- include ConditionMixin, TimeoutMixin
122
+ include ConditionMixin
123
+ include TimeoutMixin
98
124
 
99
125
  attr_accessor :frequency
100
126
 
@@ -119,20 +145,21 @@ module OpenWFE
119
145
 
120
146
  def apply (workitem)
121
147
 
122
- remove_timedout_flag(workitem)
148
+ remove_timedout_flag workitem
123
149
 
124
150
  @applied_workitem = workitem.dup
125
151
 
126
- @frequency =
127
- lookup_attribute(:frequency, workitem, DEFAULT_FREQUENCY)
128
- @frequency =
129
- OpenWFE::parse_time_string(@frequency)
152
+ @frequency = lookup_attribute(
153
+ :frequency, workitem, :default => DEFAULT_FREQUENCY)
154
+ @frequency = OpenWFE::parse_time_string(
155
+ @frequency)
130
156
 
131
- determine_timeout()
157
+ determine_timeout
158
+ determine_scheduler_tags
132
159
 
133
- store_itself()
160
+ store_itself
134
161
 
135
- trigger()
162
+ trigger
136
163
  end
137
164
 
138
165
  def reply (workitem)
@@ -176,7 +203,10 @@ module OpenWFE
176
203
 
177
204
  scheduler.schedule_in(
178
205
  @frequency,
179
- { :schedulable => self, :job_id => @scheduler_job_id })
206
+ {
207
+ :schedulable => self,
208
+ :job_id => @scheduler_job_id,
209
+ :tags => @scheduler_tags })
180
210
 
181
211
  ldebug { "reschedule() @scheduler_job_id is #{@scheduler_job_id}" }
182
212
 
@@ -139,7 +139,8 @@ module OpenWFE
139
139
  @timeout_at,
140
140
  { :schedulable => self,
141
141
  :job_id => @timeout_job_id,
142
- :do_timeout! => true })
142
+ :do_timeout! => true,
143
+ :tags => [ "timeout", self.class.name ] })
143
144
 
144
145
  ldebug do
145
146
  "to_reschedule() will timeout at " +
@@ -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"
@@ -56,9 +54,11 @@ module OpenWFE
56
54
  # (templates) before replying to its parent.
57
55
  #
58
56
  def reply_to_parent (workitem)
57
+
59
58
  @children.each do |child|
60
59
  get_expression_pool.remove(child)
61
60
  end
61
+
62
62
  super(workitem)
63
63
  end
64
64
  end
@@ -46,16 +46,17 @@ module OpenWFE
46
46
  # piece of a process instance).
47
47
  #
48
48
  # As workitems move through a workflow among the expressions and are emitted
49
- # outside of the business process engine via 'participant expressions', these
50
- # workitems are identified by the FlowExpressionId of the participant
51
- # expression that pushed them out (and is waiting for them to come back).
49
+ # outside of the business process engine via 'participant expressions',
50
+ # these workitems are identified by the FlowExpressionId of the participant
51
+ # expression that pushed them out (and is usually waiting for them
52
+ # to come back).
52
53
  #
53
54
  class FlowExpressionId
54
55
 
55
56
  FIELDS = [
56
57
  :owfe_version,
57
58
  :engine_id,
58
- :initial_engine_id,
59
+ #:initial_engine_id,
59
60
  :workflow_definition_url,
60
61
  :workflow_definition_name,
61
62
  :workflow_definition_revision,
@@ -79,17 +80,30 @@ module OpenWFE
79
80
  alias :wfname :workflow_definition_name
80
81
  alias :wfrevision :workflow_definition_revision
81
82
 
83
+ #
84
+ # the old 'initial_engine_id' is now deprecated, the methods
85
+ # are still around though.
86
+ #
87
+ def initial_engine_id= (s)
88
+
89
+ # silently discard
90
+ end
91
+ def initial_engine_id
92
+
93
+ @engine_id
94
+ end
95
+
82
96
  #
83
97
  # Overrides the classical to_s()
84
98
  #
85
- def to_s ()
86
- "(fei #{@owfe_version} #{@engine_id}/#{@initial_engine_id} #{@workflow_definition_url} #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_name} #{@expression_id})"
99
+ def to_s
100
+ "(fei #{@owfe_version} #{@engine_id} #{@workflow_definition_url} #{@workflow_definition_name} #{@workflow_definition_revision} #{@workflow_instance_id} #{@expression_name} #{@expression_id})"
87
101
  end
88
102
 
89
103
  #
90
104
  # Returns a hash version of this FlowExpressionId instance.
91
105
  #
92
- def to_h ()
106
+ def to_h
93
107
 
94
108
  h = {}
95
109
  FIELDS.each { |f| h[f] = instance_eval("@#{f.to_s}") }
@@ -107,6 +121,7 @@ module OpenWFE
107
121
  end
108
122
 
109
123
  def hash ()
124
+
110
125
  to_s().hash()
111
126
  end
112
127
 
@@ -124,10 +139,10 @@ module OpenWFE
124
139
  @workflow_definition_name == other.workflow_definition_name and
125
140
  @expression_name == other.expression_name and
126
141
  @owfe_version == other.owfe_version and
127
- @engine_id == other.engine_id and
128
- @initial_engine_id == other.initial_engine_id
142
+ @engine_id == other.engine_id
143
+ #@initial_engine_id == other.initial_engine_id
129
144
  #
130
- # Make sure to put on top of the 'and' the things that
145
+ # Made sure to put on top of the 'and' the things that
131
146
  # change the most...
132
147
  end
133
148
 
@@ -190,6 +205,7 @@ module OpenWFE
190
205
  # the expression_id, in a string.
191
206
  #
192
207
  def to_env_s
208
+
193
209
  "i#{sub_instance_id} #{@expression_id}"
194
210
  end
195
211
 
@@ -199,6 +215,7 @@ module OpenWFE
199
215
  # return "1234".
200
216
  #
201
217
  def parent_workflow_instance_id
218
+
202
219
  i = workflow_instance_id.index(".")
203
220
  return workflow_instance_id unless i
204
221
  workflow_instance_id[0..i-1]
@@ -213,11 +230,38 @@ module OpenWFE
213
230
  # (Only used in some unit tests for now)
214
231
  #
215
232
  def sub_instance_id
233
+
216
234
  i = workflow_instance_id.index(".")
217
235
  return "" unless i
218
236
  workflow_instance_id[i..-1]
219
237
  end
220
238
 
239
+ #
240
+ # If this flow expression id belongs to a sub instance, a call to
241
+ # this method will return the last number of the sub instanceid.
242
+ #
243
+ # For example, in the case of the instance "20071114-dukikomino.1", "1"
244
+ # will be returned. For "20071114-dukikomino.1.0", "0" will be returned.
245
+ #
246
+ # If the flow expression id doesn't belong to a sub instance, nil
247
+ # will be returned.
248
+ #
249
+ def last_sub_instance_id
250
+
251
+ i = workflow_instance_id.rindex(".")
252
+ return nil unless i
253
+ workflow_instance_id[i+1..-1]
254
+ end
255
+
256
+ #
257
+ # Returns true if this flow expression id belongs to a process
258
+ # which is not a subprocess.
259
+ #
260
+ def is_in_parent_process?
261
+
262
+ (sub_instance_id == "")
263
+ end
264
+
221
265
  #
222
266
  # Returns the last part of the expression_id. For example, if
223
267
  # the expression_id is "0.1.0.4", "4" will be returned.
@@ -226,6 +270,7 @@ module OpenWFE
226
270
  # backing from the children expressions.
227
271
  #
228
272
  def child_id
273
+
229
274
  i = @expression_id.rindex(".")
230
275
  return @expression_id unless i
231
276
  @expression_id[i+1..-1]
@@ -234,9 +279,9 @@ module OpenWFE
234
279
  #
235
280
  # This class method parses a string into a FlowExpressionId instance
236
281
  #
237
- def FlowExpressionId.to_fei (string)
282
+ def self.to_fei (string)
238
283
 
239
- fei = FlowExpressionId.new()
284
+ fei = FlowExpressionId.new
240
285
 
241
286
  ss = string.split(" ")
242
287
 
@@ -247,8 +292,8 @@ module OpenWFE
247
292
  fei.owfe_version = ss[1]
248
293
 
249
294
  ssRawEngineId = ss[2].split("/")
250
- fei.engine_id= ssRawEngineId[0]
251
- fei.initial_engine_id= ssRawEngineId[1]
295
+ fei.engine_id = ssRawEngineId[0]
296
+ #fei.initial_engine_id = ssRawEngineId[1]
252
297
 
253
298
  fei.workflow_definition_url = ss[3]
254
299
  fei.workflow_definition_name = ss[4]
@@ -266,8 +311,9 @@ module OpenWFE
266
311
  #
267
312
  # An alias for to_fei(string)
268
313
  #
269
- def FlowExpressionId.from_s (string)
270
- FlowExpressionId.to_fei(string)
314
+ def self.from_s (string)
315
+
316
+ to_fei string
271
317
  end
272
318
  end
273
319