Class: OpenWFE::ConcurrentIteratorExpression

Inherits:
ConcurrenceExpression show all
Defined in:
lib/openwfe/expressions/fe_concurrence.rb

Overview

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.

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

Instance Attribute Summary collapse

Attributes inherited from ConcurrenceExpression

#sync_expression

Attributes inherited from FlowExpression

#apply_time, #attributes, #children, #environment_id, #fei, #parent_id, #raw_representation

Attributes included from Contextual

#application_context

Instance Method Summary collapse

Methods inherited from ConcurrenceExpression

#reply

Methods included from ConditionMixin

#determine_condition_attribute, #eval_condition

Methods inherited from SequenceExpression

#reply

Methods inherited from FlowExpression

#cancel, #clean_children, #delete_variable, #dup_environment, #fetch_environment, #fetch_text_content, #get_binding, #get_environment, #get_parent, #get_root_environment, #has_attribute, #initialize, is_definition, is_definition?, #lookup_attribute, #lookup_attributes, #lookup_boolean_attribute, #lookup_comma_list_attribute, #lookup_downcase_attribute, #lookup_ref, #lookup_string_attribute, #lookup_sym_attribute, #lookup_value, #lookup_variable, #lookup_vf_attribute, names, #new_environment, new_exp, #owns_its_environment?, #paused?, #remove_child, #reply, #set_variable, #store_itself, #synchronize, #to_s, #to_yaml_properties

Methods included from Contextual

#get_work_directory, #init_service, #lookup

Methods included from Logging

#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn

Methods included from OwfeServiceLocator

#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator

Methods inherited from ObjectWithMeta

#class_def, meta_def, meta_eval, metaclass

Constructor Details

This class inherits a constructor from OpenWFE::FlowExpression

Instance Attribute Details

#templateObject

Returns the value of attribute template.



232
233
234
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 232

def template
  @template
end

Instance Method Details

#apply(workitem) ⇒ Object



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 234

def apply (workitem)

    return reply_to_parent(workitem) \
        if @children.length < 1

    @template = @children[0]

    @children.clear

    @workitems = []

    iterator = Iterator.new(self, workitem)

    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, nil, iterator.index, template, vars)

        @children << rawexp.fei
    end

    super
end

#reply_to_parent(workitem) ⇒ Object



267
268
269
270
271
272
# File 'lib/openwfe/expressions/fe_concurrence.rb', line 267

def reply_to_parent (workitem)

    get_expression_pool.remove(@template)

    super
end