Skip to content

Commit

Permalink
Merge branch 'backup' into developer-guide-3
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-setyawan committed Apr 15, 2024
2 parents a989ce3 + af8ca21 commit 0c6e366
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 45 deletions.
114 changes: 98 additions & 16 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 @@ -234,15 +234,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 Expand Up @@ -590,34 +596,110 @@ testers are expected to do more *exploratory* testing.

1. Initial launch

1.1 Download the jar file and copy into an empty folder
1.1 Download the jar file and copy into an empty folder.

1.2 Double-click the jar file Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum.
1.2 Run `java -jar immuniMate.jar` for the jar file Expected: Shows the GUI with a set of sample contacts.

2. Saving window preferences

2.1 Resize the window to an optimum size. Move the window to a different location. Close the window.
2.1 Move the window to a different location. Close the window.

2.2 Re-launch the app by double-clicking the jar file.<br>
2.2 Re-launch the app by running `java -jar ImmuniMate.jar` again.<br>
Expected: The most recent window size and location is retained.

### Adding a person

1. Adding a person while all persons are being shown.
1. Prerequisites: List all persons using the `list` command. Multiple persons in the list.
1. Test case: `create n/Alice Tan ic/S1234567A dob/1990-01-01 hp/12345678 a/123, Jurong West Ave 6, #08-111 s/F st/PENDING`<br>
Expected: A new person is added to the list. The result panel shows the details of the new person.
1. Test case: `create n/Bob Tan ic/T0234567C dob/1990-01-01 hp/12345678 a/123, Jurong West Ave 6, #08-111 s/M st/PENDING`<br>
Expected: A new person is not added to the list. The result panel shows an error message, indicating that the person already exists in the system.
1. Test case: `create n/Charlie Tan ic/S1234567A`<br>
Expected: A new person is not added to the list. The result panel shows an error message, indicating that the command format is invalid.
2. Adding a person while only some persons are being shown
1. Prerequisites: show only 1 person's details using the `find n/alex` command. One person is shown in the list.
1. Test case: `create n/Bob Tan ic/T0234567C dob/1990-01-01 hp/12345678 a/123, Jurong West Ave 6, #08-111 s/M st/PENDING`<br>
Expected: A new person is not added to the list. The result panel shows an error message, indicating that the person already exists in the system.
### Deleting a person

1. Deleting a person while all persons are being shown

1. Prerequisites: List all persons using the `list` command. Multiple persons in the list.
1. Prerequisites:
1. List all persons using the `list` command. Multiple persons in the list.
1. The person with NRIC `S1234567A` is already created in the system with a `create` command.

1. Test case: `delete 1`<br>
Expected: First contact is deleted from the list. Details of the deleted contact shown in the status message. Timestamp in the status bar is updated.
1. Test case: `delete S9234568N`<br>
Expected: First patient is deleted from the list. Details of the deleted patient shown in the status message. Timestamp in the status bar is updated.

1. Test case: `delete 0`<br>
1. Test case: `delete S9876543N`<br>
Expected: No person is deleted. Error details shown in the status message. Status bar remains the same.

1. Other incorrect delete commands to try: `delete`, `delete x`, `...` (where x is larger than the list size)<br>
1. Other incorrect delete commands to try: `delete`, `delete 0`, `...` (where the input for NRIC field does not follow format for NRIC)<br>
Expected: Similar to previous.

1. _{ more test cases …​ }_

2. Deleting a person while only some persons are being shown
1. Prerequisites:
2. Show only 1 person's details using the `find n/alex` command. One person is shown in the list.
3. The person with NRIC `S1234567A` is already created in the system with a `create` command.
1. Test case: `delete S1234567A`<br>
Expected: The person is deleted from the list. The result panel shows the details of the deleted person. The list panel shows a full list of patients.

### Updating a person
1. Updating a existing person's updatable fields
1. Prerequisites:
1. The person with NRIC `S1234567A` is already created in the system with a `create` command.
1. Test case: `update S1234567A a/35 Bishan Road, #10-40 con/myopia`<br>
Expected: The person's address is updated to `35 Bishan Road, #10-40` and condition is updated to `myopia`. The result panel shows the updated person's details.
2. Test case: `update S1234567A a/35 Bishan Road, #10-40 con/`<br>
Expected: The person's both fields are not updated. The result panel shows an error message, indicating that the argument for condition is invalid.
3. Test case: `update S1234567A`<br>
Expected: The person is not updated at all. The result panel shows an error message, indicating that the command format is invalid.
2. Updating a non-existing person
1. Prerequisites:
1. The person with NRIC `S1234568A` does not exist in the system.
2. Test case: `update S1234568A a/35 Bishan Road, #10-40 con/myopia`<br>
Expected: The person is not updated at all. The result panel shows an error message, indicating that the person does not exist in the system.
3. Updating a person's non-updatable fields
1. Prerequisites:
1. The person with NRIC `S1234567A` is already created in the system with a `create` command.
1. Test case: `update S1234567A a/35 Bishan Road, #10-40 con/myopia ic/S1234568A`<br>
Expected: The person's address is updated to `35 Bishan Road, #10-40` and condition is updated to `myopia`. The NRIC is not updated.
### Finding a person

1. Finding a person by name, condition or address
1. Prerequisites:
1. The person with name `Alex Yeoh` exists in the system.
2. The person with condition `diabetes` exists in the system.
3. The person with address `123, Jurong West Ave 6, #08-111` exists in the system.
1. Test case: `find n/Alex Yeoh`<br>
Expected: The person with name `Alex Yeoh` is shown in the list. The result panel shows the details of the person.
1. Test case: `find con/diabetes`<br>
Expected: The person with condition `diabetes` is shown in the list. The result panel shows the details of the person.
1. Test case: `find a/123, Jurong West Ave 6, #08-111`<br>
Expected: The person with address `123, Jurong West Ave 6, #08-111` is shown in the list. The result panel shows the details of the person.
2. Finding a person by NRIC
1. Test case: `find n/S1234567A`<br>
Expected: The person with NRIC `S1234567A` is not shown in the list. The result panel shows an error message, indicating that the command format is invalid.

### Deleting a person's information

1. Deleting a person's optional fields
1. Prerequisites:
1. The person with NRIC `S1234567A` exists in the system.
2. The person with NRIC `S1234568A` does not exist in the system.
1. Test case: `deleteinfo S1234567A a/`<br>
Expected: The person's address becomes null. The result panel shows the updated person's details.
1. Test case: `deleteinfo S1234567A a/ con/`<br>
Expected: The person's address and condition become null. The result panel shows the updated person's details.
1. Test case: `deleteinfo S1234567A`<br>
Expected: The person's information is not deleted. The result panel shows an error message, indicating that the command format is invalid.
1. Test case: `deleteinfo S1234568A e/`<br>
Expected: The person's name is not deleted. The result panel shows an error message, indicating that the person does not exist in the system.
2. Deleting a person's mandatory fields
1. Prerequisites:
1. The person with NRIC `S1234567A` exists in the system.
1. Test case: `deleteinfo S1234567A n/`<br>
Expected: The person's name is not deleted. The result panel shows an error message, indicating that the name field cannot be deleted.
### Saving data

1. Dealing with missing/corrupted data files
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
Loading

0 comments on commit 0c6e366

Please sign in to comment.