lib/openwfe/expressions/fe_concurrence.rb in openwferu-0.9.16 vs lib/openwfe/expressions/fe_concurrence.rb in openwferu-0.9.17
- old
+ new
@@ -1,8 +1,8 @@
#
#--
-# Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
+# Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
@@ -207,58 +207,69 @@
#
# This expression is a mix between a 'concurrence' and an 'iterator'.
# It understands the same attributes and behaves as an interator that
# forks its children concurrently.
#
- # (See ConcurrenceExpression and IteratorExpression).
+ # Some examples :
#
+ # <concurrent-iterator on-value="sales, logistics, lob2" to-field="p">
+ # <participant field-ref="p" />
+ # </concurrent-iterator>
+ #
+ # Within a Ruby process definition :
+ #
+ # sequence do
+ # set :field => f, :value => %w{ Alan, Bob, Clarence }
+ # #...
+ # concurrent_iterator :on_field => "f", :to_field => "p" do
+ # participant "${p}"
+ # end
+ # end
+ #
class ConcurrentIteratorExpression < ConcurrenceExpression
names :concurrent_iterator
attr_accessor :template
def apply (workitem)
- if @children.length < 1
- reply_to_parent workitem
- return
- end
+ return reply_to_parent(workitem) \
+ if @children.length < 1
@template = @children[0]
@children.clear
@workitems = []
iterator = Iterator.new(self, workitem)
- unless iterator.has_next?
- reply_to_parent workitem
- return
- end
+ return reply_to_parent(workitem) \
+ unless iterator.has_next?
while iterator.has_next?
wi = workitem.dup
@workitems << wi
vars = iterator.next wi
rawexp = get_expression_pool.prepare_from_template(
- self, iterator.index, template, vars)
+ self, nil, iterator.index, template, vars)
@children << rawexp.fei
end
super
end
def reply_to_parent (workitem)
get_expression_pool.remove(@template)
+
super
end
protected
@@ -319,11 +330,11 @@
:merge, workitem, :default => :first)
merge_type = synchable.lookup_sym_attribute(
:merge_type, workitem, :default => :mix)
- #synchable.ldebug { "new() merge_type is '#{merge_type}'" }
+ synchable.ldebug { "new() merge_type is '#{merge_type}'" }
@merge_array = MergeArray.new synchable.fei, merge, merge_type
@unready_queue = []
end
@@ -437,10 +448,10 @@
def reply_to_parent (synchable)
workitem = @merge_array.do_merge
- synchable.reply_to_parent(workitem)
+ synchable.reply_to_parent workitem
end
def treat_remaining_children (synchable)
expool = synchable.get_expression_pool