@startuml images/02_activity.png
title Image 2: Audit Job
(*) -down->"Send Harvest Digest of All Objects Signal,\n(Serial Versions, Date and Deleted Report)"
-down-> if "Received all Pid Counts\nFrom All Nodes?" as PidCount then
          -down->[yes] if "All Pids Harvested?" as HarvestLoop then
                         -down->[yes] "Get Working Pid" as WorkingPid
                       else
                         -right->[no]"wait 2"
                         -up-> HarvestLoop
                       endif
        else
          -right->[no]"wait 1"
          -up-> PidCount
        endif

WorkingPid -down-> "Compare all Serial Versions,\nDates and Deleted Indicator" as Parity

Parity -down-> if "Are Serial Versions and Dates,\nand Deleted Indicator equivalent?" as CompareAllIndicators then
         -right->[yes] "Set Pid Complete" as PidComplete
         PidComplete -up-> if "Any Unprocessed\nPids Left?" then
	      -up->[yes] WorkingPid
	    else
	      -up->[no] (*)
	    endif
endif

CompareAllIndicators -down->[no] if "Are Any Delete Indicators Set?" as DeleteIndSet then

       -right->[yes] "Send Delete SystemMetadata Signal"
       -right-> if "Have All Nodes Responded?" as NodeReponse2 then
                      -up->[yes] PidComplete
                    else
                      -right->[no] "wait 4"
                      -up-> NodeReponse2
                    endif
endif

DeleteIndSet -down->[no] "Send Retrieve SystemMetadata Signal" as SendRetrieveSysMeta
SendRetrieveSysMeta-right-> if "Have All Nodes Responded?" as NodeReponse3 then
                     partition "Merge"
                      -up->[yes] "Merge SystemMetadata" as Merge
                     end partition
                    else
                      -down->[no] "wait 5"
                      -up-> NodeReponse3
                    endif
Merge -up-> "Send update SystemMetadata Request"
-up->if "Have All Nodes Responded?" as NodeReponse4 then
        -down->[yes]  "Send Commit Transaction" as CommitTransaction
     else
        -up->[no] "wait 6"
        -down-> NodeReponse4
endif
CommitTransaction -down-> if "Have All Nodes Committed?" as NodeReponse5 then
        -left->[yes]  PidComplete
     else
        -up->[no] "wait 7"
        -down-> NodeReponse5
endif

@enduml