@startuml
skinparam monochrome true
skinparam packageStyle rectangle
skinparam shadowing false

autonumber

'hide footbox
actor "Human Recourses Manager" as ADM
participant ":RegisterCollaboratorUI" as UI
participant ":RegisterCollaboratorController" as CTRL
participant "Repositories" as RepositorySingleton
participant "repositories\n:Repositories" as PLAT
participant "JobRepository:\nJobRepository" as JOBREP
participant "Job" as job
participant "CollaboratorRepository" as COREP
participant "collaborator\n:Collaborator" as COLLABORATOR

activate ADM

        ADM -> UI : asks to register a new collaborator

activate UI



    UI --> ADM : requests data


    ADM -> UI : types requested data (name, adress IdentityNumber, identytyDocType,\n email, phoneNumber, birthDate, hiringDate)





            UI -> CTRL : getJobName()
            activate CTRL

                CTRL -> RepositorySingleton : getInstance()
                activate RepositorySingleton

                    RepositorySingleton --> CTRL: repositories
                deactivate RepositorySingleton

                CTRL -> PLAT : getJobRepository()
                activate PLAT

                    PLAT --> CTRL: jobRepository
                deactivate PLAT

                CTRL -> JOBREP : getJobNames()
                activate JOBREP


                    JOBREP --> CTRL : jobNameList
                deactivate JOBREP

                CTRL --> UI : jobNameList
            deactivate CTRL

            UI --> ADM : shows name of jobs list\n and asks to select one


    ADM -> UI : selects a job




        UI -> CTRL : createCollaborator(name, adresss, IdentityDocType,IdentityNumber, email,\nphoneNumber,birthDate,hiringDate, jobName)
        activate CTRL

            CTRL -> CTRL : getJobByName(jobName)

                CTRL -> RepositorySingleton : getInstance()
                activate RepositorySingleton

                    RepositorySingleton --> CTRL: repositories
                deactivate RepositorySingleton

                CTRL -> PLAT : getJobRepository()
                activate PLAT

                    PLAT -> CTRL : jobRepository
                deactivate PLAT



                CTRL -> JOBREP : getJobByName(jobName)
                activate JOBREP

                JOBREP -> job : isJobRegistered(jobName)
                activate job

                    job -> JOBREP : true/false
                deactivate job


                    JOBREP --> CTRL : jobName
                deactivate JOBREP
                CTRL -> PLAT : getCollaboratorRepository
                activate PLAT

                PLAT -> CTRL : CollaboratorRepository

                deactivate PLAT

                    CTRL --> CTRL : jobName


            CTRL -> COREP: registerCollaborator(name, adresss, IdentityDocType,IdentityNumber, email,\nphoneNumber,birthDate,hiringDate, jobName)
            activate COREP

                COREP -> COLLABORATOR**: registerCollaborator(name, adresss, IdentityDocType,IdentityNumber, email,\nphoneNumber,birthDate,hiringDate, jobName)
                COREP -> COREP: addCollaborator (collaborator)


                    COREP -> COREP: validateCollaborator(collaborator)


                COREP --> CTRL : collaborator

            deactivate COREP

            CTRL --> UI: collaborator
            deactivate CTRL
            UI --> ADM: displays operation success
    deactivate UI

deactivate ADM

@enduml