Class OpenWFE::GenericSyncExpression::MergeArray
In: lib/openwfe/expressions/fe_concurrence.rb
Parent: Object

This inner class is used to gather workitems (via push()) before the final merge This final merge is triggered by calling the do_merge() method which will return the resulting, merged workitem.

Methods

Included Modules

MergeMixin

Attributes

merge  [RW] 
merge_type  [RW] 
synchable_fei  [RW] 
workitem  [RW] 
workitems_by_altitude  [RW] 
workitems_by_arrival  [RW] 

Public Class methods

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 510
510:                 def initialize (synchable_fei, merge, merge_type)
511: 
512:                     @synchable_fei = synchable_fei
513: 
514:                     @merge = merge
515:                     @merge_type = merge_type
516: 
517:                     ensure_merge_settings
518: 
519:                     @workitem = nil
520: 
521:                     if highest? or lowest?
522:                         @workitems_by_arrival = []
523:                         @workitems_by_altitude = []
524:                     end
525:                 end

Public Instance methods

merges the workitems stored here

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 581
581:                 def do_merge
582: 
583:                     return @workitem if @workitem
584: 
585:                     list = if first?
586:                         @workitems_by_arrival.reverse
587:                     elsif last?
588:                         @workitems_by_arrival
589:                     elsif highest?
590:                         @workitems_by_altitude.reverse
591:                     elsif lowest?
592:                         @workitems_by_altitude
593:                     end
594: 
595:                     result = nil
596: 
597:                     list.each do |wi|
598:                         next unless wi
599:                         result = merge_workitems result, wi, override?
600:                     end
601: 
602:                     #puts "___ result :"
603:                     #puts result.to_s
604:                     #puts
605: 
606:                     result
607:                 end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 527
527:                 def push (synchable, wi)
528: 
529:                     #synchable.ldebug do
530:                     #    "push() isolate? #{isolate?}"
531:                     #end
532: 
533:                     if isolate?
534:                         push_in_isolation wi
535:                     elsif last? or first?
536:                         push_by_position wi
537:                     else
538:                         push_by_arrival wi
539:                     end
540:                 end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 568
568:                 def push_by_arrival (wi)
569: 
570:                     #index = synchable.children.index wi.last_expression_id
571:                     #index = Integer(wi.last_expression_id.child_id)
572:                     index = Integer(get_child_id(wi))
573: 
574:                     @workitems_by_arrival << wi
575:                     @workitems_by_altitude[index] = wi
576:                 end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 542
542:                 def push_by_position (wi)
543: 
544:                     source, target = if first?
545:                         [ @workitem, wi ]
546:                     else
547:                         [ wi, @workitem ]
548:                     end
549:                     @workitem = merge_workitems target, source, override?
550:                 end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 552
552:                 def push_in_isolation (wi)
553: 
554:                     unless @workitem
555:                         @workitem = wi.dup
556:                         att = @workitem.attributes
557:                         @workitem.attributes = {}
558:                     end
559: 
560:                     #key = synchable.children.index wi.last_expression_id
561:                     #key = wi.last_expression_id.child_id
562:                     key = get_child_id wi
563: 
564:                     @workitem.attributes[key.to_s] = 
565:                         OpenWFE::fulldup(wi.attributes)
566:                 end

Protected Instance methods

Making sure @merge and @merge_type are set to appropriate values.

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 650
650:                     def ensure_merge_settings
651: 
652:                         @merge_type = :mix unless override? or isolate?
653:                         @merge = :first unless last? or highest? or lowest?
654:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 611
611:                     def first?
612:                         @merge == :first
613:                     end

Returns the child id of the expression that just replied with the given workitem.

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 638
638:                     def get_child_id (workitem)
639: 
640:                         return workitem.fei.child_id \
641:                             if workitem.fei.wfid == @synchable_fei.wfid
642: 
643:                         workitem.fei.last_sub_instance_id
644:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 617
617:                     def highest?
618:                         @merge == :highest
619:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 630
630:                     def isolate?
631:                         @merge_type == :isolate
632:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 614
614:                     def last?
615:                         @merge == :last
616:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 620
620:                     def lowest?
621:                         @merge == :lowest
622:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 624
624:                     def mix?
625:                         @merge_type == :mix
626:                     end

[Source]

     # File lib/openwfe/expressions/fe_concurrence.rb, line 627
627:                     def override?
628:                         @merge_type == :override
629:                     end

[Validate]