@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":CalgoParser" as CalgoParser LOGIC_COLOR
participant ":ReportCommandParser" as ReportCommandParser LOGIC_COLOR
participant "r:ReportCommand" as ReportCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant "model:Model" as Model MODEL_COLOR
participant ":ReportGenerator" as ReportGenerator MODEL_COLOR
end box

[-> LogicManager : execute("report d/2020-03-27")
activate LogicManager

LogicManager -> CalgoParser : parseCommand("report d/2020-03-27")
activate CalgoParser

create ReportCommandParser
CalgoParser -> ReportCommandParser : new ReportCommandParser()
activate ReportCommandParser

ReportCommandParser --> CalgoParser
deactivate ReportCommandParser

CalgoParser -> ReportCommandParser : parse("d/2020-03-27")
activate ReportCommandParser

create ReportCommand
ReportCommandParser -> ReportCommand
activate ReportCommand

ReportCommand --> ReportCommandParser : r
deactivate ReportCommand

ReportCommandParser --> CalgoParser : r
deactivate ReportCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
ReportCommandParser -[hidden]-> CalgoParser
destroy ReportCommandParser

CalgoParser --> LogicManager : r
deactivate CalgoParser

LogicManager -> ReportCommand : execute(model)
activate ReportCommand

ReportCommand -> Model : getDailyGoal()
activate Model

Model --> ReportCommand
deactivate Model

ReportCommand -> Model : getLogByDate(queryDate)
activate Model

Model --> ReportCommand
deactivate Model

ReportCommand -> Model : getPastWeekLogs()
activate Model

Model --> ReportCommand
deactivate Model

create ReportGenerator
ReportCommand -> ReportGenerator : new ReportGenerator(queryDate, dailyGoal, dailyLog, pastWeekLogs)

activate ReportGenerator
ReportGenerator --> ReportCommand
deactivate ReportGenerator

ReportCommand -> ReportGenerator : generateReport()
activate ReportGenerator

ReportGenerator -> ReportGenerator : updateStatistics()
activate ReportGenerator
deactivate ReportGenerator

ReportGenerator -> ReportGenerator : printHeader()
activate ReportGenerator
deactivate ReportGenerator

ReportGenerator -> ReportGenerator : printBody()
activate ReportGenerator
deactivate ReportGenerator

ReportGenerator -> ReportGenerator : printFooter()
activate ReportGenerator
deactivate ReportGenerator

ReportGenerator --> ReportCommand
deactivate ReportGenerator
ReportGenerator -[hidden]-> CalgoParser
destroy ReportGenerator

create CommandResult
ReportCommand -> CommandResult
activate CommandResult

CommandResult --> ReportCommand
deactivate CommandResult

ReportCommand --> LogicManager : result
deactivate ReportCommand
ReportCommand -[hidden]-> CalgoParser
destroy ReportCommand

[<--LogicManager
deactivate LogicManager
@enduml
