diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index b0ec60e4ef8..876b46a0c1d 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -160,16 +160,24 @@ This section describes some noteworthy details on how certain features are imple #### Implementation: -The add mechanism is facilitated by `AddressBook`. It implements `AddressBook#addPerson(Person p)`which allow users to add patients’ contacts and relevant patient information into the addressbook. +The `add` feature is implemented using the `AddCommand` class. The `AddCommand` object takes in a `Person` object. +`Person` object is created if the following conditions are satisfied: +- all the inputs for the parameters are valid +- all compulsory parameters are present +- no duplicate `Person` in ClinicMate -These operations are exposed in the `Model` interface as `Model#addPerson(Person p)`. +The add mechanism is facilitated by `AddressBook`. It implements `ModelManager#addPerson(Person p)`which allows users to add patients’ contacts +and relevant patient information into ClinicMate. These operations are exposed in the `Model` interface as `Model#addPerson(Person p)`. -Given below is an example usage scenario and how the add mechanism behaves at each step. +Apart from that, the feature also includes the following operation in `ModelManager`, which implements the `Model` interface: +- `Model#hasPerson(Person person)`: Checks if the `Person` to be added is already an existing `Person` profile in ClinicMate -Step 1. The user launches the application for the first time. The `AddressBook` will be initialized with the initial address book state. +Given below is an example usage scenario and how the `add` mechanism behaves at each step. -Step 2. The user executes `add n\John Doe …` to add the person in the address book with the unique identification number `T0123456A`. The add command calls `Model#addPerson(Person p)`, causing the modified state of the address book after the `add n\John Doe …` command executes to be saved. +Step 1. The user launches the application for the first time. `ClinicMate` will be initialized with the initial address book state. +Step 2. The user executes `add n\John Doe p\12345678 e\john@mail.com i\T0123456A ag\12 s\M a\John street, block 123, #01-01` to add the person in the address book with the unique IC number `T0123456A`. +The `add` command calls `Model#addPerson(Person p)`, causing the modified state of the address book after the `add n\John Doe …` command executes to be saved. @@ -178,17 +186,17 @@ Step 2. The user executes `add n\John Doe …` to add the person in the address -The following sequence diagram shows how an add operation goes through the `Logic` component: +The following sequence diagram illustrates how the `add` command works and goes through the `Logic` and `Model` components. -**Note:** The lifeline for `AddCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. +**Note:** The lifeline for `AddCommandParser` and `AddCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. -The following activity diagram summarizes what happens when a user executes a new command: +The following activity diagram summarizes what happens when a user executes a new `add` command:
@@ -209,30 +217,35 @@ The following activity diagram summarizes what happens when a user executes a ne * **Alternative 2:** Allow users to add patients by adding fields as and when is needed (i.e. not make all the fields compulsory). * Pros: Shorter command to type to add a patient. * Cons: - * We must ensure that the implementation of each individual command are correct. - * Might not have all the relevant information of all patients. Messy to keep track. + * We must ensure that the implementation of each individual commands is correct. + * Might not have all the relevant information of patients. Messy to keep track. **Aspect: Display of new contact when command is successful:** -* Current choice: Displays the new contact with relevant patient information in the addressbook. +* Current choice: Displays the new contact with relevant patient information in ClinicMate. * Rationale: Users will be able to view the patient and the information added easily. **Aspect: Display of error message when command is unsuccessful:** -* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, duplicate person, invalid ic format). +* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, duplicate person, invalid IC number format). * Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful. ### Add/replace note feature #### Implementation -The add/replace notes mechanism is facilitated by `AddressBook`. It implements `AddressBook#setPerson(Person target, Person editedPerson)` which allow users to add/replace patients’ notes in the addressbook. +The add/replace note mechanism is facilitated by `AddressBook`. It implements `AddressBook#setPerson(Person target, Person editedPerson)` which allow users to add/replace patients’ notes in the addressbook. -These operations are exposed in the `Model` interface as `Model#setPerson(Person target, Person editedPerson)` +These operations are exposed in the `Model` interface: +- `Model#getPersonIfExists`: Checks if the person with the predicate exists +- `Model#setPerson`: Changes the note parameter of the target Person +- `Model#isPersonDisplayed`: Checks if the `Person` has their notes displayed in the patient notes panel +- `Model#setDisplayedNote`: If `Model#isPersonDisplayed` returns true, the notes displayed will be updated Given below is an example usage scenario and how the add/replace note mechanism behaves at each step. Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state. -Step 2. The user executes `addnote T0123456A …` to add a note to the person in the address book with the unique identification number `T0123456A`. The addnote command calls `Model#setPerson(Person target, Person editedPerson)`, causing the modified state of the address book after the `addnote T0123456A …` command executes to be saved. +Step 2. The user executes `addnote T0123456A n\Covid` to add a note to the person in ClinicMate with the unique IC number `T0123456A`. +The `addnote` command calls `Model#setPerson(Person target, Person editedPerson)`, causing the modified state of ClinicMate after the `addnote T0123456A n\Covid` command executes to be saved. @@ -240,17 +253,17 @@ Step 2. The user executes `addnote T0123456A …` to add a note to the person in -The following sequence diagram shows how an addnote operation goes through the `Logic` component: +The following sequence diagram shows how an `addnote` operation goes through the `Logic` component: -**Note:** The lifeline for `AddNoteCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. +**Note:** The lifeline for `AddNoteCommandParser` and `AddNoteCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. -The following activity diagram summarizes what happens when a user executes a new command: +The following activity diagram summarizes what happens when a user executes a new `addnote` command:
@@ -260,38 +273,42 @@ The following activity diagram summarizes what happens when a user executes a ne **Aspect: How to add or replace:** -* **Alternative 1 (current choice):** Have a flag (-replace) to allow users to replace the whole note section of specified patient. This is on top of the normal add note command where new notes are appended to the existing note itself. +* **Alternative 1 (Current Choice):** Have a flag (-replace) to allow users to replace the whole note section of specified patient. +* This is an extension of the normal `addnote` command where new notes are appended to the existing note itself. * Pros: * Able to edit/clean up notes section. * Gives users the freedom to decide how they want to keep notes. * Cons: - * Users might not want to replace all the notes they have (just want to edit a section). + * Users might not want to replace all the notes they have, and might just want to edit a section. * **Alternative 2:** Allow users to only add notes to patients. * Pros: More structured command to add notes to patient. * Cons: Not able to give users the freedom to ‘edit’ the notes they have. **Aspect: Display of new note when command is successful:** -* Current choice: Displays the new note in the correct patient’s section in the addressbook. +* Current choice: Displays the new note in the correct patient’s section in ClinicMate. * Rationale: Users will be able to view the new note added easily. **Aspect: Display of error message when command is unsuccessful:** -* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format). +* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid IC number format). * Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful. ### Find feature #### Implementation -The find mechanism is facilitated by `ModelManager`. It implements `ModelManager#updateFilteredPersonList(Predicate predicate)` which allow users to find patients in the addressbook. +The find mechanism is facilitated by `ModelManager`. It implements `ModelManager#updateFilteredPersonList(Predicate predicate)` +which allow users to find patients in ClinicMate. These operations are exposed in the `Model` interface as `Model#updateFilteredPersonList(Predicate predicate)`. +`predicate` takes in a `IdentityCardNumberMatchesPredicate` to filter the list of patients. Given below is an example usage scenario and how the find mechanism behaves at each step. Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state. -Step 2. The user executes `find T0123456A …` to find the person in the address book with the unique identification number `T0123456A`. The find command calls `Model#updateFilteredPersonList(Predicate predicate)`, causing the modified state of the address book after the `find T0123456A …` command executes to be displayed. +Step 2. The user executes `find S0123456A` to find the person in the address book with the unique IC number `S0123456A`. The `find` command calls `Model#updateFilteredPersonList(Predicate predicate)`, +causing the modified state of the address book after the `find S0123456A` command executes to be displayed. @@ -305,7 +322,7 @@ The following sequence diagram shows how a find operation goes through the `Logi -**Note:** The lifeline for `FindCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. +**Note:** The lifeline for `FindCommand` and `FindCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. @@ -317,28 +334,37 @@ The following activity diagram summarizes what happens when a user executes a ne #### Design Considerations & Alternatives Considered -**Aspect: Display of filtered list/contact when command is successful:** -* Current choice: Displays the correct patient’s contact in the addressbook. +**Aspect: Filtering patients** +* **Alternative 1 (Current Choice):** Requires users to input a full and valid IC number + * Pros: Precise results, allows users to directly single out the patient's details + * Cons: Might omit relevant results if the user types the IC number incorrectly +* Alternative 2: Match all relevant patients' profiles even if the user enters a partial IC number + * Pros: Flexible search, more time-efficient, returns results even without typing the whole IC number + * Cons: Might produce more results than expected. Might incorrectly refer to the wrong patient details. + +**Aspect: Display of filtered list when command is successful:** +* Current choice: Displays the correct patient’s contact in the patient list panel. * Rationale: Users will be able to view the contact added easily. **Aspect: Display of error message when command is unsuccessful:** -* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format). +* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid IC number format). * Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful. ### Delete feature #### Implementation -The find mechanism is facilitated by `Addressbook`. It implements `Addressbook#removePerson(Person key)` which allow users to delete patients in the addressbook. +The delete mechanism is facilitated by `Addressbook`. It implements `Addressbook#removePerson(Person key)` which allow users to delete patients in the addressbook. + +These operations are exposed in the `Model` interface as `Model#getPersonIfExists(Predicate predicate)` and `Model#deletePerson(Person target)`. -These operations are exposed in the `Model` interface as `Model#deletePerson(Person target)`. Given below is an example usage scenario and how the delete mechanism behaves at each step. Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state. -Step 2. The user executes `delete T0123456A` to delete the person in the address book with the unique identification number `T0123456A`. -The delete command calls `Model#deletePerson(Person target)`, causing the modified state of the address book after the `delete T0123456A` command executes to be saved. +Step 2. The user executes `delete S0123456A` to delete the person in the address book with the unique IC number `S0123456A`. +The delete command calls `Model#deletePerson(Person target)`, causing the modified state of the address book after the `delete S0123456A` command executes to be saved. @@ -352,7 +378,7 @@ The following sequence diagram shows how a delete operation goes through the `Lo -**Note:** The lifeline for `DeleteCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. +**Note:** The lifeline for `DeleteCommandParser` and `DeleteCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. @@ -369,8 +395,8 @@ The following activity diagram summarizes what happens when a user executes a ne * Rationale: Users will be able to view the updated contact list easily. **Aspect: Display of error message when command is unsuccessful:** -* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format). - * Rationale: Users will be able to learn of their error quickly annd have an idea of what to edit to make the command successful. +* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid IC number format). + * Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful. ### Edit feature @@ -398,7 +424,7 @@ The following sequence diagram shows how an edit operation goes through the `Log -**Note:** The lifeline for `EditCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. +**Note:** The lifeline for `EditCommand` and `EditCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. diff --git a/docs/diagrams/AddCommandDiagram.puml b/docs/diagrams/AddCommandDiagram.puml index 948ffcc7c60..417e094dcc2 100644 --- a/docs/diagrams/AddCommandDiagram.puml +++ b/docs/diagrams/AddCommandDiagram.puml @@ -6,7 +6,8 @@ box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR participant ":AddCommandParser" as AddCommandParser LOGIC_COLOR -participant "d:AddCommand" as AddCommand LOGIC_COLOR +participant "p:Person" as Person LOGIC_COLOR +participant "a:AddCommand" as AddCommand LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR end box @@ -14,10 +15,17 @@ box Model MODEL_COLOR_T1 participant "m:Model" as Model MODEL_COLOR end box -[-> LogicManager : execute("add n/John Doe p/12345678 \n e/john@mail.com i/T0123456A ag/12 s/Male \n a/John street, block 123, #01-01") +note left of LogicManager + In the diagram, params refers to the following: + "n\John Doe p\12345678 + e\john@mail.com i\T0123456A ag\12 s\M + a\John street, block 123, #01-01" +end note + +[-> LogicManager : execute("add params") activate LogicManager -LogicManager -> AddressBookParser : parseCommand("add n/John Doe p/12345678 \n e/john@mail.com i/T0123456A ag/12 s/Male \n a/John street, block 123, #01-01") +LogicManager -> AddressBookParser : parseCommand("add params") activate AddressBookParser create AddCommandParser @@ -27,14 +35,21 @@ activate AddCommandParser AddCommandParser --> AddressBookParser deactivate AddCommandParser -AddressBookParser -> AddCommandParser : parse("add n/John Doe p/12345678 \n e/john@mail.com i/T0123456A ag/12 s/Male \n a/John street, block 123, #01-01") +AddressBookParser -> AddCommandParser : parse("params") activate AddCommandParser +create Person +AddCommandParser -> Person: +activate Person + +Person --> AddCommandParser +deactivate Person + create AddCommand -AddCommandParser -> AddCommand +AddCommandParser -> AddCommand : new AddCommand(p) activate AddCommand -AddCommand --> AddCommandParser : +AddCommand --> AddCommandParser : a deactivate AddCommand AddCommandParser --> AddressBookParser : a @@ -49,7 +64,13 @@ deactivate AddressBookParser LogicManager -> AddCommand : execute(m) activate AddCommand -AddCommand -> Model : setPerson(T0123456A, \n new Person(John Doe, 12345678, ...)) +AddCommand -> Model : hasPerson(p) +activate Model + +Model --> AddCommand +deactivate Model + +AddCommand -> Model : addPerson(p) activate Model Model --> AddCommand @@ -65,6 +86,10 @@ deactivate CommandResult AddCommand --> LogicManager : r deactivate AddCommand +'Hidden arrow to position the destroy marker below the end of the activation bar. +AddCommand -[hidden]-> LogicManager +destroy AddCommand + [<--LogicManager deactivate LogicManager @enduml diff --git a/docs/diagrams/AddNoteSequenceDiagram.puml b/docs/diagrams/AddNoteSequenceDiagram.puml index c8cfec0e359..58b0ba92303 100644 --- a/docs/diagrams/AddNoteSequenceDiagram.puml +++ b/docs/diagrams/AddNoteSequenceDiagram.puml @@ -6,7 +6,10 @@ box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR participant ":AddNoteCommandParser" as AddNoteCommandParser LOGIC_COLOR -participant "n:AddNoteCommand" as AddNoteCommand LOGIC_COLOR +participant "i:IdentityCardNumberMatchesPredicate" as IdentityCardNumberPredicate LOGIC_COLOR +participant "n:Note" as Note LOGIC_COLOR +participant "a:AddNoteCommand" as AddNoteCommand LOGIC_COLOR +participant "p:Person" as Person LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR end box @@ -14,10 +17,15 @@ box Model MODEL_COLOR_T1 participant "m:Model" as Model MODEL_COLOR end box -[-> LogicManager : execute("addnote \n i/T0123456A n/Covid") +note left of LogicManager + In the diagram, params refers to the following: + "T0123456A n\Covid" +end note + +[-> LogicManager : execute("addnote params") activate LogicManager -LogicManager -> AddressBookParser : parseCommand("addnote \n i/T0123456A n/Covid") +LogicManager -> AddressBookParser : parseCommand("addnote params") activate AddressBookParser create AddNoteCommandParser @@ -27,29 +35,68 @@ activate AddNoteCommandParser AddNoteCommandParser --> AddressBookParser deactivate AddNoteCommandParser -AddressBookParser -> AddNoteCommandParser : parse("i/T0123456A n/Covid") +AddressBookParser -> AddNoteCommandParser : parse("params") activate AddNoteCommandParser +create IdentityCardNumberPredicate +AddNoteCommandParser -> IdentityCardNumberPredicate: +activate IdentityCardNumberPredicate + +IdentityCardNumberPredicate --> AddNoteCommandParser +deactivate IdentityCardNumberPredicate + +create Note +AddNoteCommandParser -> Note: +activate Note + +Note --> AddNoteCommandParser +deactivate Note + create AddNoteCommand -AddNoteCommandParser -> AddNoteCommand +AddNoteCommandParser -> AddNoteCommand : new AddNoteCommand(i, n, false) activate AddNoteCommand -AddNoteCommand --> AddNoteCommandParser : +AddNoteCommand --> AddNoteCommandParser : a deactivate AddNoteCommand -AddNoteCommandParser --> AddressBookParser : n +AddNoteCommandParser --> AddressBookParser : a deactivate AddNoteCommandParser 'Hidden arrow to position the destroy marker below the end of the activation bar. AddNoteCommandParser -[hidden]-> AddressBookParser destroy AddNoteCommandParser -AddressBookParser --> LogicManager : n +AddressBookParser --> LogicManager : a deactivate AddressBookParser LogicManager -> AddNoteCommand : execute(m) activate AddNoteCommand -AddNoteCommand -> Model : setPerson(T0123456A, \n new Person(..., Covid, ...)) +create Person +AddNoteCommand -> Person: +activate Person + +Person --> AddNoteCommand +deactivate Person + +AddNoteCommand -> Model : getPersonIfExists(...) +activate Model + +Model --> AddNoteCommand +deactivate Model + +AddNoteCommand -> Model : setPerson(...) +activate Model + +Model --> AddNoteCommand +deactivate Model + +AddNoteCommand -> Model : isPersonDisplayed(...) +activate Model + +Model --> AddNoteCommand +deactivate Model + +AddNoteCommand -> Model : setDisplayedNote(...) activate Model Model --> AddNoteCommand @@ -65,6 +112,10 @@ deactivate CommandResult AddNoteCommand --> LogicManager : r deactivate AddNoteCommand +'Hidden arrow to position the destroy marker below the end of the activation bar. +AddNoteCommand -[hidden]-> LogicManager +destroy AddNoteCommand + [<--LogicManager deactivate LogicManager @enduml diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index 8fe89996830..74bd45903e4 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -6,6 +6,7 @@ box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR participant ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR +participant "p :IdentityCardNumberMatchesPredicate" as IdentityCardNumberMatchesPredicate LOGIC_COLOR participant "d:DeleteCommand" as DeleteCommand LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR end box @@ -30,11 +31,18 @@ deactivate DeleteCommandParser AddressBookParser -> DeleteCommandParser : parse("S0123456A") activate DeleteCommandParser +create IdentityCardNumberMatchesPredicate +DeleteCommandParser -> IdentityCardNumberMatchesPredicate +activate IdentityCardNumberMatchesPredicate + +IdentityCardNumberMatchesPredicate --> DeleteCommandParser +deactivate IdentityCardNumberMatchesPredicate + create DeleteCommand -DeleteCommandParser -> DeleteCommand +DeleteCommandParser -> DeleteCommand : new DeleteCommand(p) activate DeleteCommand -DeleteCommand --> DeleteCommandParser : +DeleteCommand --> DeleteCommandParser : d deactivate DeleteCommand DeleteCommandParser --> AddressBookParser : d @@ -49,6 +57,12 @@ deactivate AddressBookParser LogicManager -> DeleteCommand : execute(m) activate DeleteCommand +DeleteCommand -> Model : getPersonIfExists(S0123456A) +activate Model + +Model --> DeleteCommand +deactivate Model + DeleteCommand -> Model : deletePerson(S0123456A) activate Model @@ -65,6 +79,10 @@ deactivate CommandResult DeleteCommand --> LogicManager : r deactivate DeleteCommand +'Hidden arrow to position the destroy marker below the end of the activation bar. +DeleteCommand -[hidden]-> LogicManager +destroy DeleteCommand + [<--LogicManager deactivate LogicManager @enduml diff --git a/docs/diagrams/EditCommandDiagram.puml b/docs/diagrams/EditCommandDiagram.puml index d9cc1e3dda8..f1477bbf20c 100644 --- a/docs/diagrams/EditCommandDiagram.puml +++ b/docs/diagrams/EditCommandDiagram.puml @@ -6,7 +6,9 @@ box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR participant ":EditCommandParser" as EditCommandParser LOGIC_COLOR -participant "d:EditCommand" as EditCommand LOGIC_COLOR +participant "i:IdentityCardNumberMatchesPredicate" as IdentityCardNumberPredicate LOGIC_COLOR +participant "d:EditPersonDescriptor" as EditPersonDescriptor LOGIC_COLOR +participant "e:EditCommand" as EditCommand LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR end box @@ -14,10 +16,15 @@ box Model MODEL_COLOR_T1 participant "m:Model" as Model MODEL_COLOR end box -[-> LogicManager : execute("edit T0123456A p/23456789") +note left of LogicManager + In the diagram, params refers to the following: + "T0123456A p\23456789" +end note + +[-> LogicManager : execute("edit params") activate LogicManager -LogicManager -> AddressBookParser : parseCommand("edit T0123456A p/23456789") +LogicManager -> AddressBookParser : parseCommand("edit params") activate AddressBookParser create EditCommandParser @@ -27,14 +34,28 @@ activate EditCommandParser EditCommandParser --> AddressBookParser deactivate EditCommandParser -AddressBookParser -> EditCommandParser : parse("p/23456789") +AddressBookParser -> EditCommandParser : parse("params") activate EditCommandParser +create IdentityCardNumberPredicate +EditCommandParser -> IdentityCardNumberPredicate: +activate IdentityCardNumberPredicate + +IdentityCardNumberPredicate --> EditCommandParser +deactivate IdentityCardNumberPredicate + +create EditPersonDescriptor +EditCommandParser -> EditPersonDescriptor: +activate EditPersonDescriptor + +EditPersonDescriptor --> EditCommandParser +deactivate EditPersonDescriptor + create EditCommand -EditCommandParser -> EditCommand +EditCommandParser -> EditCommand : new EditCommand(i, d) activate EditCommand -EditCommand --> EditCommandParser : +EditCommand --> EditCommandParser : e deactivate EditCommand EditCommandParser --> AddressBookParser : e @@ -49,7 +70,25 @@ deactivate AddressBookParser LogicManager -> EditCommand : execute(m) activate EditCommand -EditCommand -> Model : setPerson(T0123456A, \n new Person(John Doe, 23456789, ...)) +EditCommand -> Model : getPersonIfExists(...) +activate Model + +Model --> EditCommand +deactivate Model + +EditCommand -> Model : hasPerson(...) +activate Model + +Model --> EditCommand +deactivate Model + +EditCommand -> Model : setPerson(...) +activate Model + +Model --> EditCommand +deactivate Model + +EditCommand -> Model : updateFilteredPersonList(...) activate Model Model --> EditCommand @@ -65,6 +104,10 @@ deactivate CommandResult EditCommand --> LogicManager : r deactivate EditCommand +'Hidden arrow to position the destroy marker below the end of the activation bar. +EditCommand -[hidden]-> LogicManager +destroy EditCommand + [<--LogicManager deactivate LogicManager @enduml diff --git a/docs/diagrams/FindSequenceDiagram.puml b/docs/diagrams/FindSequenceDiagram.puml index 8b5c1260dd0..39c56457347 100644 --- a/docs/diagrams/FindSequenceDiagram.puml +++ b/docs/diagrams/FindSequenceDiagram.puml @@ -6,6 +6,7 @@ box Logic LOGIC_COLOR_T1 participant ":LogicManager" as LogicManager LOGIC_COLOR participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR participant ":FindCommandParser" as FindCommandParser LOGIC_COLOR +participant "p :IdentityCardNumberMatchesPredicate" as IdentityCardNumberMatchesPredicate LOGIC_COLOR participant "f:FindCommand" as FindCommand LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR end box @@ -30,11 +31,18 @@ deactivate FindCommandParser AddressBookParser -> FindCommandParser : parse("S0123456A") activate FindCommandParser +create IdentityCardNumberMatchesPredicate +FindCommandParser -> IdentityCardNumberMatchesPredicate +activate IdentityCardNumberMatchesPredicate + +IdentityCardNumberMatchesPredicate --> FindCommandParser +deactivate IdentityCardNumberMatchesPredicate + create FindCommand -FindCommandParser -> FindCommand +FindCommandParser -> FindCommand : new FindCommand(p) activate FindCommand -FindCommand --> FindCommandParser : +FindCommand --> FindCommandParser : f deactivate FindCommand FindCommandParser --> AddressBookParser : f @@ -65,6 +73,10 @@ deactivate CommandResult FindCommand --> LogicManager : r deactivate FindCommand +'Hidden arrow to position the destroy marker below the end of the activation bar. +FindCommand -[hidden]-> LogicManager +destroy FindCommand + [<--LogicManager deactivate LogicManager @enduml diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 9e7f581e578..9beb1f4b283 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -9,6 +9,9 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_SEX; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; @@ -48,6 +51,7 @@ public class AddCommand extends Command { + "Sex: %6$s\n" + "Address: %7$s\n"; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in ClinicMate"; + private static final Logger logger = LogsCenter.getLogger(AddCommand.class); private final Person toAdd; @@ -68,6 +72,8 @@ public CommandResult execute(Model model) throws CommandException { } model.addPerson(toAdd); + logger.info("Add command has been successfully executed on Person with IC Number: " + + toAdd.getIdentityCardNumber()); String successMessage = String.format(MESSAGE_SUCCESS, toAdd.getName(), toAdd.getPhone(), diff --git a/src/main/java/seedu/address/logic/commands/AddNoteCommand.java b/src/main/java/seedu/address/logic/commands/AddNoteCommand.java index cbe85d79dba..93d29d6aed8 100644 --- a/src/main/java/seedu/address/logic/commands/AddNoteCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddNoteCommand.java @@ -4,6 +4,9 @@ import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; @@ -33,6 +36,8 @@ public class AddNoteCommand extends Command { + PREFIX_NOTE + "Diabetes -replace"; public static final String MESSAGE_MODIFY_NOTE_SUCCESS = "Note for %1$s (IC: %2$s) modified successfully!"; + private static final Logger logger = LogsCenter.getLogger(AddNoteCommand.class); + private final IdentityCardNumberMatchesPredicate icPredicate; private final Note note; private final boolean isReplace; @@ -75,6 +80,8 @@ public CommandResult execute(Model model) throws CommandException { model.setDisplayNote(editedPerson); } + logger.info("Addnote command has been successfully executed on Person with IC: " + + personToEdit.getIdentityCardNumber()); return new CommandResult(generateSuccessMessage(editedPerson)); } diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index fd80c045579..52b55576831 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -2,6 +2,9 @@ import static java.util.Objects.requireNonNull; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.model.AddressBook; import seedu.address.model.Model; @@ -12,12 +15,13 @@ public class ClearCommand extends Command { public static final String COMMAND_WORD = "clear"; public static final String MESSAGE_SUCCESS = "ClinicMate has been cleared!"; - + private static final Logger logger = LogsCenter.getLogger(ClearCommand.class); @Override public CommandResult execute(Model model) { requireNonNull(model); model.setAddressBook(new AddressBook()); + logger.info("Clear command has been executed."); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 5480874d7cc..6ebcdb27bb8 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -2,6 +2,9 @@ import static java.util.Objects.requireNonNull; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; @@ -30,6 +33,8 @@ public class DeleteCommand extends Command { + "Sex: %6$s\n" + "Address: %7$s\n";; + private static final Logger logger = LogsCenter.getLogger(DeleteCommand.class); + private final IdentityCardNumberMatchesPredicate predicate; public DeleteCommand(IdentityCardNumberMatchesPredicate predicate) { @@ -44,6 +49,8 @@ public CommandResult execute(Model model) throws CommandException { .orElseThrow(() -> new CommandException(Messages.MESSAGE_NO_MATCHING_IC_DELETE)); model.deletePerson(personToDelete); + logger.info("Delete command has been executed on Person with IC Number: " + + personToDelete.getIdentityCardNumber()); String successMessage = String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete.getName(), personToDelete.getPhone(), diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index f47d98d9f9f..c09db452bfc 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -12,7 +12,9 @@ import java.util.Objects; import java.util.Optional; +import java.util.logging.Logger; +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.CollectionUtil; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; @@ -60,6 +62,7 @@ public class EditCommand extends Command { + "Address: %7$s\n"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in ClinicMate."; + private static final Logger logger = LogsCenter.getLogger(EditCommand.class); private final EditPersonDescriptor editPersonDescriptor; private final IdentityCardNumberMatchesPredicate predicate; @@ -88,6 +91,7 @@ public CommandResult execute(Model model) throws CommandException { } model.setPerson(personToEdit, editedPerson); + logger.info("Edit command has been executed on Person with IC Number: " + predicate); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); String successMessage = String.format(MESSAGE_EDIT_PERSON_SUCCESS, editedPerson.getName(), @@ -107,6 +111,7 @@ public CommandResult execute(Model model) throws CommandException { */ private static Person createEditedPerson(Person personToEdit, EditPersonDescriptor editPersonDescriptor) { assert personToEdit != null; + assert editPersonDescriptor != null; Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); @@ -117,7 +122,6 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); // Use the same person for existing fields, but copies the object for every thing else - // TODO: change this when the command is updated return new Person(updatedName, updatedPhone, updatedEmail, updatedIC, updatedAge, updatedSex, updatedAddress, personToEdit.getNote()); } diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index beaf7bd8adb..877733d7a65 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -2,6 +2,9 @@ import static java.util.Objects.requireNonNull; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.model.Model; @@ -21,6 +24,8 @@ public class FindCommand extends Command { + "Parameters: IC\n" + "Example: " + COMMAND_WORD + " t1234567A"; + private static final Logger logger = LogsCenter.getLogger(FindCommand.class); + private final IdentityCardNumberMatchesPredicate predicate; public FindCommand(IdentityCardNumberMatchesPredicate predicate) { @@ -37,6 +42,9 @@ public CommandResult execute(Model model) { if (model.getFilteredPersonList().size() == 1) { Person person = model.getFilteredPersonList().get(0); model.setDisplayNote(person); + logger.info("Find command has been executed on Person with IC Number: " + person.getIdentityCardNumber()); + } else { + logger.info("Find command has been executed with no matching Person found."); } return new CommandResult( diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index bf824f91bd0..e2b081e2898 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -1,5 +1,8 @@ package seedu.address.logic.commands; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.model.Model; /** @@ -13,9 +16,13 @@ public class HelpCommand extends Command { + "Example: " + COMMAND_WORD; public static final String SHOWING_HELP_MESSAGE = "Opened help window."; + private static final Logger logger = LogsCenter.getLogger(HelpCommand.class); + @Override public CommandResult execute(Model model) { + + logger.info("Help command has been executed."); return new CommandResult(SHOWING_HELP_MESSAGE, true, false); } } diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 8e040763bb4..db9e9af8b59 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -3,6 +3,9 @@ import static java.util.Objects.requireNonNull; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.model.Model; /** @@ -11,13 +14,15 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; - public static final String MESSAGE_SUCCESS = "Listed all persons"; + private static final Logger logger = LogsCenter.getLogger(ListCommand.class); + @Override public CommandResult execute(Model model) { requireNonNull(model); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); + logger.info("Executed list command."); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/logic/commands/ShowCommand.java b/src/main/java/seedu/address/logic/commands/ShowCommand.java index 4643c582cd1..1311c51b1e8 100644 --- a/src/main/java/seedu/address/logic/commands/ShowCommand.java +++ b/src/main/java/seedu/address/logic/commands/ShowCommand.java @@ -2,6 +2,9 @@ import static java.util.Objects.requireNonNull; +import java.util.logging.Logger; + +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; @@ -26,6 +29,9 @@ public class ShowCommand extends Command { + "Parameters: IC (optional)\n" + "Example (to display note): " + COMMAND_WORD + " t1234567A\n" + "Example (to clear display): " + COMMAND_WORD; + + private static final Logger logger = LogsCenter.getLogger(ShowCommand.class); + private final IdentityCardNumberMatchesPredicate icPredicate; private final boolean isClear; @@ -60,6 +66,7 @@ public CommandResult execute(Model model) throws CommandException { requireNonNull(model); if (isClear) { model.clearDisplayNote(); + logger.info("Show command has been executed and cleared display note."); return new CommandResult(MESSAGE_CLEAR_NOTE_SUCCESS); } @@ -67,6 +74,8 @@ public CommandResult execute(Model model) throws CommandException { .orElseThrow(() -> new CommandException(Messages.MESSAGE_NO_MATCHING_IC)); model.setDisplayNote(person); + logger.info("Show command has been executed, displaying note of Person with IC Number:" + + person.getIdentityCardNumber()); return new CommandResult( String.format(MESSAGE_SHOW_NOTE_SUCCESS, person.getIdentityCardNumber()) );