Skip to content

Commit

Permalink
Merge pull request #238 from laney0808/dg
Browse files Browse the repository at this point in the history
Update Architecture diagrams
  • Loading branch information
alex-setyawan authored Apr 15, 2024
2 parents 2777a34 + 067fd28 commit 54b20a3
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 34 deletions.
15 changes: 10 additions & 5 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ The sequence diagram below illustrates the interactions within the `Logic` compo
How the `Logic` component works:

1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates a parser that matches the command (e.g., `DeleteCommandParser`) and uses it to parse the command.
1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteCommand`) which is executed by the `LogicManager`.
1. The command can communicate with the `Model` when it is executed (e.g. to delete a person).<br>
2. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeleteCommand`) which is executed by the `LogicManager`.
3. The command can communicate with the `Model` when it is executed (e.g. to delete a person).<br>
Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the `Model`) to achieve.
1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.
4. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

Here are the other classes in `Logic` (omitted from the class diagram above) that are used for parsing a user command:

Expand Down Expand Up @@ -233,16 +233,21 @@ This `deleteinfo` command is facilitated by `DeleteInfoCommand` and `DeleteInfoC

* `DeleteInfoCommandParser#parse` is responsible for parsing the user input and creating a new `DeleteInfoCommand` instance.
* `DeleteInfoCommand#execute` is responsible for executing the command and removing the field of information from the patient.
* `Model#getFilteredPersonList()` is called to get the list of patients in the system.
* `Model#setField` where `Field` refers to whichever field specified to be deleted, is responsible for removing the field of information from the patient.
`DeleteInfoCommand` checks if the patient exists in the system before removing the field of information.
* `ModelManager#hasPerson(Person)` is called to check if the patient already exists in the system. It calls `ImmuniMate.hasPerson(Person)` which calls `UniquePersonList#contains(Person)` to check if the patient already exists in the internal list of patients.

Step 1. `DeleteInfoCommandParser` interprets the user's input for NRIC and the fields to be deleted, and creates a new `DeleteInfoCommand` instance.
Step 2. The `DeleteInfoCommand#execute` is called by the `LogicManager`. The `DeleteInfoCommand` checks if the patient exists in the system by calling `model.hasPerson(person)`.
Step 3. If the patient exists, the `DeleteInfoCommand` calls `model.getFilteredPersonList()` to get the list of patients in the system. It then find the person with the specific NRIC by calling `Observablelist<Persons>#filtered(Predicate)` and `Observablelist<Persons>#get(int)`.
Step 3. If the patient exists, the `DeleteInfoCommand` calls `model.setField` (where the field is the specified field to delete) to get the list of patients in the system.
Step 4. `DeleteInfoCommand#execute` check which fields are to be deleted, and remove the field of information using `Person#setField(null)`. Where `Field` is the field to be deleted.
Step 5: After the field of information is removed, the `DeleteInfoCommand` returns the appropriate `CommandResult` to indicate the success of the operation.

The following sequence diagram shows how a deleteinfo operation goes through the Logic component:
![DeleteInfoState1](images/DeleteInfoSequenceDiagram.png)
The sequence diagram for how the deleteinfo operation goes through the Model Component is as the following:
![DeleteInfoState1](images/DeleteInfoModelDiagram.png)

### Read a patient's information
#### Proposed Implementation
The `read` feature allows users to read a patient profile by providing NRIC through a command. This patient data is then displayed.
Expand Down
6 changes: 3 additions & 3 deletions docs/diagrams/ArchitectureSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Participant ":Logic" as logic LOGIC_COLOR
Participant ":Model" as model MODEL_COLOR
Participant ":Storage" as storage STORAGE_COLOR

user -[USER_COLOR]> ui : "delete 1"
user -[USER_COLOR]> ui : "delete S1234567X"
activate ui UI_COLOR

ui -[UI_COLOR]> logic : execute("delete 1")
ui -[UI_COLOR]> logic : execute("delete X1234567X")
activate logic LOGIC_COLOR

logic -[LOGIC_COLOR]> model : deletePerson(p)
Expand All @@ -20,7 +20,7 @@ activate model MODEL_COLOR
model -[MODEL_COLOR]-> logic
deactivate model

logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook)
logic -[LOGIC_COLOR]> storage : saveAddressBook(immuniMate)
activate storage STORAGE_COLOR

storage -[STORAGE_COLOR]> storage : Save to file
Expand Down
27 changes: 17 additions & 10 deletions docs/diagrams/CreateCommandModel.puml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,30 @@ participant ":ModelManager" as ModelManager MODEL_COLOR
participant ":ImmuniMate" as ImmuniMate MODEL_COLOR
participant ":UniquePersonList" as UniquePersonList MODEL_COLOR
participant "internalList: ObservableList<Person>" as internalList MODEL_COLOR
participant "p1:Person" as p1 MODEL_COLOR
participant "p:Person" as p MODEL_COLOR
end box

[-> CreateCommand : execute()
activate CreateCommand

CreateCommand -> ModelManager : hasPerson(p)
CreateCommand -> ModelManager : hasPerson(p1)
activate ModelManager

ModelManager -> ImmuniMate: hasPerson(p)
ModelManager -> ImmuniMate: hasPerson(p1)
activate ImmuniMate

ImmuniMate --> UniquePersonList : contains(p)
ImmuniMate -> UniquePersonList : contains(p1)
activate UniquePersonList

UniquePersonList -> internalList : stream().anyMatch(p::isSamePerson)
UniquePersonList -> internalList : stream().anyMatch(p1::isSamePerson)
activate internalList

internalList -> p : isSamePerson(p)
activate p
internalList -> p1 : isSamePerson(p1)
activate p1

p --> internalList
deactivate p
p1 --> internalList
deactivate p1

internalList --> UniquePersonList
deactivate internalList
Expand All @@ -46,12 +47,18 @@ deactivate ImmuniMate
ModelManager --> CreateCommand
deactivate ModelManager

CreateCommand -> ModelManager : addPerson(p)
CreateCommand -> ModelManager : addPerson(...)
activate ModelManager

ModelManager -> ImmuniMate: addPerson(p)
ModelManager -> ImmuniMate: addPerson(...)
activate ImmuniMate

create p
ImmuniMate -> p
activate p
p --> ImmuniMate
deactivate p

ImmuniMate -> UniquePersonList : add(p)
activate UniquePersonList

Expand Down
82 changes: 82 additions & 0 deletions docs/diagrams/DeleteInfoModelDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain
box Logic LOGIC_COLOR_T1
participant "l:Logic" as CreateCommand LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":ModelManager" as ModelManager MODEL_COLOR
participant ":ImmuniMate" as ImmuniMate MODEL_COLOR
participant ":UniquePersonList" as UniquePersonList MODEL_COLOR
participant "internalList: ObservableList<Person>" as internalList MODEL_COLOR
participant "p1:Person" as p1 MODEL_COLOR
participant "p1:Person" as p MODEL_COLOR
end box

[-> CreateCommand : execute()
activate CreateCommand

CreateCommand -> ModelManager : hasPerson(...)
activate ModelManager

ModelManager -> ImmuniMate: hasPerson(p1)
activate ImmuniMate

ImmuniMate -> UniquePersonList : contains(p1)
activate UniquePersonList

UniquePersonList -> internalList : stream().anyMatch(p1::isSamePerson)
activate internalList

internalList -> p1 : isSamePerson(p1)
activate p1

p1 --> internalList
deactivate p1

internalList --> UniquePersonList
deactivate internalList

UniquePersonList --> ImmuniMate
deactivate UniquePersonList

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> CreateCommand
deactivate ModelManager

CreateCommand -> ModelManager : setEmail(...)
activate ModelManager

ModelManager -> ImmuniMate: getPerson(...)
activate ImmuniMate

ImmuniMate -> UniquePersonList : get(...)
activate UniquePersonList

UniquePersonList -> internalList : get(...)
activate internalList

internalList --> UniquePersonList : p
deactivate internalList

UniquePersonList --> ImmuniMate : p
deactivate UniquePersonList

ImmuniMate -> p : setEmail(null)
activate p
p --> ImmuniMate : set email to null
deactivate p

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> CreateCommand
deactivate ModelManager

[<--CreateCommand
deactivate CreateCommand

@enduml
74 changes: 74 additions & 0 deletions docs/diagrams/DeleteInfoSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":ImmuniMateParser" as ImmuniMateParser LOGIC_COLOR
participant ":DeleteInfoCommandParser" as DeleteInfoCommandParser LOGIC_COLOR
participant "d:DeleteInfoCommand" as DeleteInfoCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant "m:Model" as Model MODEL_COLOR
end box

[-> LogicManager : execute("deleteinfo S1234567X e/")
activate LogicManager

LogicManager -> ImmuniMateParser : parseCommand("deleteinfo S1234567X e/")
activate ImmuniMateParser

create DeleteInfoCommandParser
ImmuniMateParser -> DeleteInfoCommandParser
activate DeleteInfoCommandParser

DeleteInfoCommandParser --> ImmuniMateParser
deactivate DeleteInfoCommandParser

ImmuniMateParser -> DeleteInfoCommandParser : parse("S1234567X e/")
activate DeleteInfoCommandParser

create DeleteInfoCommand
DeleteInfoCommandParser -> DeleteInfoCommand
activate DeleteInfoCommand

DeleteInfoCommand --> DeleteInfoCommandParser :
deactivate DeleteInfoCommand

DeleteInfoCommandParser --> ImmuniMateParser : d
deactivate DeleteInfoCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
DeleteInfoCommandParser -[hidden]-> ImmuniMateParser
destroy DeleteInfoCommandParser

ImmuniMateParser --> LogicManager : d
deactivate ImmuniMateParser

LogicManager -> DeleteInfoCommand : execute(m)
activate DeleteInfoCommand

DeleteInfoCommand -> Model : hasPerson(...)
activate Model
Model --> DeleteInfoCommand : false
deactivate Model

DeleteInfoCommand -> Model : setEmail(...)
activate Model
Model --> DeleteInfoCommand : set email of specified person to null
deactivate Model

create CommandResult
DeleteInfoCommand -> CommandResult
activate CommandResult

CommandResult --> DeleteInfoCommand
deactivate CommandResult

DeleteInfoCommand --> LogicManager : r
deactivate DeleteInfoCommand

[<--LogicManager
deactivate LogicManager
@enduml
48 changes: 32 additions & 16 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,45 @@ Package Model as ModelPackage <<Rectangle>>{
Class "<<interface>>\nReadOnlyAddressBook" as ReadOnlyAddressBook
Class "<<interface>>\nReadOnlyUserPrefs" as ReadOnlyUserPrefs
Class "<<interface>>\nModel" as Model
Class AddressBook
Class ImmuniMate
Class ModelManager
Class UserPrefs

Class UniquePersonList
Class Person
Class Address
Class Email
Class Name
Class Phone
Class Tag
Class Nric
Class DateOfBirth
Class Sex
Class Status
Class Email
Class Country
Class Allergies
Class BloodType
Class Condition
Class DateOfAdmission
Class Diagnosis
Class Symptom


Class I #FFFFFF
}

Class HiddenOutside #FFFFFF
HiddenOutside ..> Model

AddressBook .up.|> ReadOnlyAddressBook
ImmuniMate .up.|> ReadOnlyAddressBook

ModelManager .up.|> Model
Model .right.> ReadOnlyUserPrefs
Model .left.> ReadOnlyAddressBook
ModelManager -left-> "1" AddressBook
ModelManager -left-> "1" ImmuniMate
ModelManager -right-> "1" UserPrefs
UserPrefs .up.|> ReadOnlyUserPrefs

AddressBook *--> "1" UniquePersonList
ImmuniMate *--> "1" UniquePersonList
UniquePersonList --> "~* all" Person
Person *--> "1" Nric
Person *--> "1" Name
Expand All @@ -44,22 +55,27 @@ Person *--> "1" Address
Person *--> "1" DateOfBirth
Person *--> "1" Sex
Person *--> "1" Status
Person *--> "0..*" Tags
Person *--> "0..1" Email
Person *--> "0..1" Country
Person *--> "0..1" Allergies
Person *--> "0..1" BloodType
Person *--> "0..1" Condition
Person *--> "0..1" DateOfAdmission
Person *--> "0..1" Diagnosis
Person *--> "0..1" Symptom

Person *--> "1" Email
Person *--> "1" Country
Person *--> "1" Allergies
Person *--> "1" BloodType
Person *--> "1" Condition
Person *--> "1" DateOfAdmission
Person *--> "1" Diagnosis
Person *--> "1" Symptom


Person -[hidden]up--> I
UniquePersonList -[hidden]right-> I

Nric -[hidden]right-> Name
Name -[hidden]right-> Phone
Phone -[hidden]right-> Address
Address -[hidden]right-> Email
Address -[hidden]right-> DateOfBirth
DateOfBirth -[hidden]right-> Sex
Sex -[hidden]right-> Status

ModelManager --> "~* filtered" Person
@enduml

Binary file modified docs/images/ArchitectureSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/CreateCommandModel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/DeleteInfoModelDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/DeleteInfoSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 54b20a3

Please sign in to comment.