lib/openwfe/expressions/fe_concurrence.rb in openwferu-0.9.15 vs lib/openwfe/expressions/fe_concurrence.rb in openwferu-0.9.16

- old
+ new

@@ -137,19 +137,21 @@ names :concurrence attr_accessor \ :sync_expression + def apply (workitem) - sync = lookup_attribute(:sync, workitem, :generic) + sync = lookup_sym_attribute( + :sync, workitem, :default => :generic) @sync_expression = get_expression_map.get_sync_class(sync).new(self, workitem) @children.each do |child| - @sync_expression.add_child(child) + @sync_expression.add_child child end store_itself() concurrence = self @@ -270,11 +272,11 @@ # A base for sync expressions, currently empty. # That may change. # class SyncExpression < ObjectWithMeta - def initialize() + def initialize super end def self.names (*exp_names) @@ -311,16 +313,19 @@ @reply_count = 0 @count = determine_count(synchable, workitem) @cancel_remaining = cancel_remaining?(synchable, workitem) - merge = synchable.lookup_attribute(:merge, workitem, :first) - merge_type = synchable.lookup_attribute(:merge_type, workitem, :mix) + merge = synchable.lookup_sym_attribute( + :merge, workitem, :default => :first) + merge_type = synchable.lookup_sym_attribute( + :merge_type, workitem, :default => :mix) + #synchable.ldebug { "new() merge_type is '#{merge_type}'" } - @merge_array = MergeArray.new(merge, merge_type) + @merge_array = MergeArray.new synchable.fei, merge, merge_type @unready_queue = [] end # @@ -457,21 +462,21 @@ end end def cancel_remaining? (synchable_expression, workitem) - s = synchable_expression.lookup_attribute( - :remaining, workitem, :cancel) + s = synchable_expression.lookup_sym_attribute( + :remaining, workitem, :default => :cancel) - return s == :cancel.to_s + (s == :cancel) end def determine_count (synchable_expression, workitem) - s = synchable_expression.lookup_attribute(:count, workitem) - return -1 if not s - i = s.to_i + c = synchable_expression.lookup_attribute :count, workitem + return -1 if not c + i = c.to_i return -1 if i < 1 i end # @@ -482,23 +487,26 @@ # class MergeArray include MergeMixin attr_accessor \ + :synchable_fei, :workitem, :workitems_by_arrival, :workitems_by_altitude, :merge, :merge_type - def initialize (merge, merge_type) + def initialize (synchable_fei, merge, merge_type) - @merge = merge.strip.downcase.intern - @merge_type = merge_type.strip.downcase.intern + @synchable_fei = synchable_fei - ensure_merge_settings() + @merge = merge + @merge_type = merge_type + ensure_merge_settings + @workitem = nil if highest? or lowest? @workitems_by_arrival = [] @workitems_by_altitude = [] @@ -537,20 +545,22 @@ att = @workitem.attributes @workitem.attributes = {} end #key = synchable.children.index wi.last_expression_id - key = wi.last_expression_id.child_id + #key = wi.last_expression_id.child_id + key = get_child_id wi @workitem.attributes[key.to_s] = OpenWFE::fulldup(wi.attributes) end def push_by_arrival (wi) #index = synchable.children.index wi.last_expression_id - index = Integer(wi.last_expression_id.child_id) + #index = Integer(wi.last_expression_id.child_id) + index = Integer(get_child_id(wi)) @workitems_by_arrival << wi @workitems_by_altitude[index] = wi end @@ -606,9 +616,21 @@ def override? @merge_type == :override end def isolate? @merge_type == :isolate + end + + # + # Returns the child id of the expression that just + # replied with the given workitem. + # + def get_child_id (workitem) + + return workitem.fei.child_id \ + if workitem.fei.wfid == @synchable_fei.wfid + + workitem.fei.last_sub_instance_id end # # Making sure @merge and @merge_type are set to # appropriate values.