@startuml
autonumber

title SD_getAnunciosSeriaveisAutomaticos

participant "ra:Registo\nAnuncios" as RA
participant "lstAnunColab\n:List<Anuncio> " as LISTANU
participant "anuncio\n:Anuncio" as ANU
participant "tipoReg:TipoRegimento" as TREG <<interface>>
participant "listaCand\n:ListaCandidaturas" as LCAND

[o-> RA : getAnunciosSeriaveisNaoAutomaticos(lstAnunColab)

activate RA
loop até i < lstAnunColab.size()

RA -> LISTANU : anuncio = get(i)
activate LISTANU
deactivate LISTANU

RA -> ANU : tipoReg = getTipoRegimento()
activate ANU
deactivate ANU

RA -> TREG : criteriosObjetivos = areCriteriosObjetivos()
activate TREG
deactivate TREG

opt criteriosObjetivos = true
RA -> LISTANU : remove(i)
activate LISTANU
deactivate LISTANU

end
end
loop até i < lstAnunColab.size()

RA -> LISTANU : anuncio = get(i)
activate LISTANU
deactivate LISTANU

RA -> ANU : foiSeriado = temProcessoSeriacao()
activate ANU
deactivate ANU

opt foiSeriado = true
RA -> LISTANU : remove(i)
activate LISTANU
deactivate LISTANU
end
end

loop até i < lstAnunColab.size()

RA -> LISTANU : anuncio = get(i)
activate LISTANU
deactivate LISTANU

RA -> ANU : listaCand = getListaCandidaturas()
activate ANU
deactivate ANU

RA -> LCAND : temCandidaturas = temCandidaturasEfetuadas()
activate LCAND
deactivate LCAND

opt temCandidaturas = false
RA -> LISTANU : remove(i)
activate LISTANU
deactivate LISTANU
end

end

loop até i < lstAnunColab.size()

RA -> LISTANU : anuncio = get(i)
activate LISTANU
deactivate LISTANU

RA -> ANU : durantePeriodoSeriacao = estaNoPeriodoSeriacao()
activate ANU
deactivate ANU

opt durantePeriodoSeriacao = false
RA -> LISTANU : remove(i)
activate LISTANU
deactivate LISTANU
deactivate RA
end
end


@enduml
