From 1831e2cd89c080573f50148160836619a16fbd31 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 13:11:43 +0800 Subject: [PATCH 01/10] Fix DG features sequence diagrams --- docs/diagrams/AddCommandDiagram.puml | 35 +++++++++++--- docs/diagrams/AddNoteSequenceDiagram.puml | 57 +++++++++++++++++++---- docs/diagrams/DeleteSequenceDiagram.puml | 2 +- docs/diagrams/EditCommandDiagram.puml | 45 +++++++++++++++--- docs/diagrams/FindSequenceDiagram.puml | 12 ++++- 5 files changed, 127 insertions(+), 24 deletions(-) diff --git a/docs/diagrams/AddCommandDiagram.puml b/docs/diagrams/AddCommandDiagram.puml index 948ffcc7c60..0481571df01 100644 --- a/docs/diagrams/AddCommandDiagram.puml +++ b/docs/diagrams/AddCommandDiagram.puml @@ -6,18 +6,26 @@ 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 box Model MODEL_COLOR_T1 -participant "m:Model" as Model MODEL_COLOR +participant ":ModelManager" 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 activate AddCommand -AddCommand --> AddCommandParser : +AddCommand --> AddCommandParser 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 diff --git a/docs/diagrams/AddNoteSequenceDiagram.puml b/docs/diagrams/AddNoteSequenceDiagram.puml index c8cfec0e359..8d397685116 100644 --- a/docs/diagrams/AddNoteSequenceDiagram.puml +++ b/docs/diagrams/AddNoteSequenceDiagram.puml @@ -6,18 +6,26 @@ 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 box Model MODEL_COLOR_T1 -participant "m:Model" as Model MODEL_COLOR +participant ":ModelManager" 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,17 +35,31 @@ 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 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 @@ -49,7 +71,26 @@ 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 : setPerson(...) +activate Model + +Model --> AddNoteCommand +deactivate Model + +AddNoteCommand -> Model : isPersonDisplayed(...) +activate Model + +Model --> AddNoteCommand +deactivate Model + +AddNoteCommand -> Model : setDisplayedNote(...) activate Model Model --> AddNoteCommand diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index 8fe89996830..b32fdac8182 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -11,7 +11,7 @@ participant "r:CommandResult" as CommandResult LOGIC_COLOR end box box Model MODEL_COLOR_T1 -participant "m:Model" as Model MODEL_COLOR +participant ":ModelManager" as Model MODEL_COLOR end box [-> LogicManager : execute("delete S0123456A") diff --git a/docs/diagrams/EditCommandDiagram.puml b/docs/diagrams/EditCommandDiagram.puml index d9cc1e3dda8..196dc411258 100644 --- a/docs/diagrams/EditCommandDiagram.puml +++ b/docs/diagrams/EditCommandDiagram.puml @@ -6,18 +6,25 @@ 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 box Model MODEL_COLOR_T1 -participant "m:Model" as Model MODEL_COLOR +participant ":ModelManager" 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,9 +34,23 @@ 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 activate EditCommand @@ -49,7 +70,19 @@ deactivate AddressBookParser LogicManager -> EditCommand : execute(m) activate EditCommand -EditCommand -> Model : setPerson(T0123456A, \n new Person(John Doe, 23456789, ...)) +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 diff --git a/docs/diagrams/FindSequenceDiagram.puml b/docs/diagrams/FindSequenceDiagram.puml index 8b5c1260dd0..ddb59af00b7 100644 --- a/docs/diagrams/FindSequenceDiagram.puml +++ b/docs/diagrams/FindSequenceDiagram.puml @@ -8,10 +8,11 @@ participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR participant ":FindCommandParser" as FindCommandParser LOGIC_COLOR participant "f:FindCommand" as FindCommand LOGIC_COLOR participant "r:CommandResult" as CommandResult LOGIC_COLOR +participant "p :IdentityCardNumberMatchesPredicate" as IdentityCardNumberMatchesPredicate LOGIC_COLOR end box box Model MODEL_COLOR_T1 -participant "m:Model" as Model MODEL_COLOR +participant ":ModelManager" as Model MODEL_COLOR end box [-> LogicManager : execute("find S0123456A") @@ -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 activate FindCommand -FindCommand --> FindCommandParser : +FindCommand --> FindCommandParser : f deactivate FindCommand FindCommandParser --> AddressBookParser : f From c69c1462b504d26222357b57aef51e837c5dd787 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 13:16:47 +0800 Subject: [PATCH 02/10] Add logging implementation --- .../java/seedu/address/logic/commands/AddCommand.java | 5 +++++ .../java/seedu/address/logic/commands/AddNoteCommand.java | 5 +++++ .../java/seedu/address/logic/commands/ClearCommand.java | 6 ++++++ .../java/seedu/address/logic/commands/DeleteCommand.java | 5 +++++ .../java/seedu/address/logic/commands/EditCommand.java | 6 +++++- .../java/seedu/address/logic/commands/FindCommand.java | 8 ++++++++ .../java/seedu/address/logic/commands/HelpCommand.java | 7 +++++++ .../java/seedu/address/logic/commands/ListCommand.java | 6 ++++++ .../java/seedu/address/logic/commands/ShowCommand.java | 7 +++++++ .../java/seedu/address/logic/parser/AddCommandParser.java | 1 - 10 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 9e7f581e578..4826d8fb334 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -9,11 +9,14 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_SEX; +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; import seedu.address.model.person.Person; +import java.util.logging.Logger; + /** * Adds a person to the address book. */ @@ -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,7 @@ public CommandResult execute(Model model) throws CommandException { } model.addPerson(toAdd); + logger.info("Add command has been successfully executed on Person: " + toAdd.toString()); 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 5ebd5cea2e6..4f85fcbe62e 100644 --- a/src/main/java/seedu/address/logic/commands/AddNoteCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddNoteCommand.java @@ -5,7 +5,9 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE; import java.util.List; +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; @@ -35,6 +37,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; @@ -80,6 +84,7 @@ public CommandResult execute(Model model) throws CommandException { model.setDisplayNote(editedPerson); } + logger.info("Addnote command has been successfully executed on Person with IC: " + icPredicate); 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..b69f4301ef4 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -2,14 +2,19 @@ import static java.util.Objects.requireNonNull; +import seedu.address.commons.core.LogsCenter; import seedu.address.model.AddressBook; import seedu.address.model.Model; +import java.util.logging.Logger; + /** * Clears the address book. */ public class ClearCommand extends Command { + private static final Logger logger = LogsCenter.getLogger(ClearCommand.class); + public static final String COMMAND_WORD = "clear"; public static final String MESSAGE_SUCCESS = "ClinicMate has been cleared!"; @@ -18,6 +23,7 @@ public class ClearCommand extends Command { 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 fb80c13ad9c..b4418ee20e6 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -3,7 +3,9 @@ import static java.util.Objects.requireNonNull; import java.util.List; +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; @@ -32,6 +34,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) { @@ -49,6 +53,7 @@ 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: " + predicate); 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 e0371aefc3a..3d71caa211a 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -16,7 +16,9 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; +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; @@ -65,6 +67,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; @@ -97,6 +100,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(), @@ -116,6 +120,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()); @@ -127,7 +132,6 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); // 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(), updatedTags); } diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index beaf7bd8adb..6b4b723ff44 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -2,12 +2,15 @@ import static java.util.Objects.requireNonNull; +import seedu.address.commons.core.LogsCenter; import seedu.address.commons.util.ToStringBuilder; import seedu.address.logic.Messages; import seedu.address.model.Model; import seedu.address.model.person.IdentityCardNumberMatchesPredicate; import seedu.address.model.person.Person; +import java.util.logging.Logger; + /** * Finds and lists all persons in address book whose IC matches the argument IC. * Keyword matching is case-insensitive. @@ -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: " + predicate); + } 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..cdf352f5bad 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -1,7 +1,10 @@ package seedu.address.logic.commands; +import seedu.address.commons.core.LogsCenter; import seedu.address.model.Model; +import java.util.logging.Logger; + /** * Format full help instructions for every command for display. */ @@ -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..021b7402bb1 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -3,12 +3,17 @@ import static java.util.Objects.requireNonNull; import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import seedu.address.commons.core.LogsCenter; import seedu.address.model.Model; +import java.util.logging.Logger; + /** * Lists all persons in the address book to the user. */ public class ListCommand extends Command { + private static final Logger logger = LogsCenter.getLogger(ListCommand.class); + public static final String COMMAND_WORD = "list"; @@ -18,6 +23,7 @@ public class ListCommand extends Command { 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 274f39c003e..06c5d15eb81 100644 --- a/src/main/java/seedu/address/logic/commands/ShowCommand.java +++ b/src/main/java/seedu/address/logic/commands/ShowCommand.java @@ -3,7 +3,9 @@ import static java.util.Objects.requireNonNull; import java.util.List; +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 +32,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; @@ -64,6 +69,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); } @@ -76,6 +82,7 @@ public CommandResult execute(Model model) throws CommandException { model.setDisplayNote(person); + logger.info("Show command has been executed, displaying note of Person with IC " + icPredicate); return new CommandResult( String.format(MESSAGE_SHOW_NOTE_SUCCESS, person.getIdentityCardNumber()) ); diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index fb6ae21cd0b..c91934f6b88 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -59,7 +59,6 @@ public AddCommand parse(String args) throws ParseException { Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); // Use the same add person, but create a DEFAULT object for every thing else - // TODO: change this when the command is updated Person person = new Person(name, phone, email, ic, age, sex, address, Note.DEFAULT, tagList); From 7ea06524f6615d80392005d1f2597597b47d266d Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 13:33:12 +0800 Subject: [PATCH 03/10] Fix checkstyle --- .../java/seedu/address/logic/commands/AddCommand.java | 7 ++++--- .../seedu/address/logic/commands/AddNoteCommand.java | 3 ++- .../java/seedu/address/logic/commands/ClearCommand.java | 8 +++----- .../java/seedu/address/logic/commands/DeleteCommand.java | 3 ++- .../java/seedu/address/logic/commands/FindCommand.java | 6 +++--- .../java/seedu/address/logic/commands/HelpCommand.java | 4 ++-- .../java/seedu/address/logic/commands/ListCommand.java | 9 ++++----- .../java/seedu/address/logic/commands/ShowCommand.java | 3 ++- 8 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 4826d8fb334..9beb1f4b283 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -9,14 +9,14 @@ 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; import seedu.address.model.person.Person; -import java.util.logging.Logger; - /** * Adds a person to the address book. */ @@ -72,7 +72,8 @@ public CommandResult execute(Model model) throws CommandException { } model.addPerson(toAdd); - logger.info("Add command has been successfully executed on Person: " + toAdd.toString()); + 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 4f85fcbe62e..f2143d27a54 100644 --- a/src/main/java/seedu/address/logic/commands/AddNoteCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddNoteCommand.java @@ -84,7 +84,8 @@ public CommandResult execute(Model model) throws CommandException { model.setDisplayNote(editedPerson); } - logger.info("Addnote command has been successfully executed on Person with IC: " + icPredicate); + 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 b69f4301ef4..52b55576831 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -2,22 +2,20 @@ 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; -import java.util.logging.Logger; - /** * Clears the address book. */ public class ClearCommand extends Command { - private static final Logger logger = LogsCenter.getLogger(ClearCommand.class); - 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) { diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index b4418ee20e6..31b7cddaa19 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -53,7 +53,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: " + predicate); + 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/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 6b4b723ff44..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,8 @@ 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; @@ -9,8 +11,6 @@ import seedu.address.model.person.IdentityCardNumberMatchesPredicate; import seedu.address.model.person.Person; -import java.util.logging.Logger; - /** * Finds and lists all persons in address book whose IC matches the argument IC. * Keyword matching is case-insensitive. @@ -42,7 +42,7 @@ 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: " + predicate); + 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."); } diff --git a/src/main/java/seedu/address/logic/commands/HelpCommand.java b/src/main/java/seedu/address/logic/commands/HelpCommand.java index cdf352f5bad..e2b081e2898 100644 --- a/src/main/java/seedu/address/logic/commands/HelpCommand.java +++ b/src/main/java/seedu/address/logic/commands/HelpCommand.java @@ -1,10 +1,10 @@ package seedu.address.logic.commands; +import java.util.logging.Logger; + import seedu.address.commons.core.LogsCenter; import seedu.address.model.Model; -import java.util.logging.Logger; - /** * Format full help instructions for every command for display. */ diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 021b7402bb1..db9e9af8b59 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -3,21 +3,20 @@ 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; -import java.util.logging.Logger; - /** * Lists all persons in the address book to the user. */ public class ListCommand extends Command { - private static final Logger logger = LogsCenter.getLogger(ListCommand.class); - 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) { diff --git a/src/main/java/seedu/address/logic/commands/ShowCommand.java b/src/main/java/seedu/address/logic/commands/ShowCommand.java index 06c5d15eb81..082f1734539 100644 --- a/src/main/java/seedu/address/logic/commands/ShowCommand.java +++ b/src/main/java/seedu/address/logic/commands/ShowCommand.java @@ -82,7 +82,8 @@ public CommandResult execute(Model model) throws CommandException { model.setDisplayNote(person); - logger.info("Show command has been executed, displaying note of Person with IC " + icPredicate); + 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()) ); From ced3063072fe8d4ec70e4d341b0cfad07b6cfd62 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 17:59:26 +0800 Subject: [PATCH 04/10] Update add, addnote, find commands in DG --- docs/DeveloperGuide.md | 75 ++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index f627a4e4abb..54806e8d58b 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -153,16 +153,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 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. @@ -171,17 +179,17 @@ Step 2. The user executes `add n/John Doe …` to add the person in the address -The following sequence diagram shows how an undo 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` 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:
@@ -202,30 +210,36 @@ 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 the 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 `addnote` 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)` +The `addnote` feature has the following operations in `ModelManager` which implements the `Model` interface: +- `Model#setPerson`: Changes the note parameter of the target Person +- `Model#isPersonDisplayed`: Checks if the `Person` has their notes displayed in the person 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 identification 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. @@ -233,17 +247,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` 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:
@@ -253,32 +267,35 @@ 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. @@ -310,12 +327,20 @@ 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 user to input a full and valid IC number + * Pros: Precise results, allows user to directly single out the patient 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 From 4f4e07aa9328457f8e67d72cadab9783067aef33 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 22:13:19 +0800 Subject: [PATCH 05/10] Update DG sequence diagrams --- docs/DeveloperGuide.md | 17 +++++++++-------- docs/diagrams/AddCommandDiagram.puml | 10 +++++++--- docs/diagrams/AddNoteSequenceDiagram.puml | 10 +++++++--- docs/diagrams/DeleteSequenceDiagram.puml | 18 +++++++++++++++--- docs/diagrams/EditCommandDiagram.puml | 10 +++++++--- docs/diagrams/FindSequenceDiagram.puml | 10 +++++++--- 6 files changed, 52 insertions(+), 23 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 54806e8d58b..b9169837eb9 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -159,7 +159,7 @@ The `add` feature is implemented using the `AddCommand` class. The `AddCommand` - all compulsory parameters are present - no duplicate `Person` in ClinicMate -The `add` mechanism is facilitated by `AddressBook`. It implements `ModelManager#addPerson(Person p)`which allows users to add patients’ contacts +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)`. Apart from that, the feature also includes the following operation in `ModelManager`, which implements the `Model` interface: @@ -225,7 +225,7 @@ The following activity diagram summarizes what happens when a user executes a ne #### Implementation -The `addnote` 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)` @@ -301,7 +301,8 @@ Given below is an example usage scenario and how the find mechanism behaves at e 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 identification 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. @@ -347,7 +348,7 @@ The following activity diagram summarizes what happens when a user executes a ne #### 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#deletePerson(Person target)`. @@ -355,8 +356,8 @@ Given below is an example usage scenario and how the delete mechanism behaves at 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 identification 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. @@ -370,7 +371,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` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram. @@ -387,7 +388,7 @@ 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). +* 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 diff --git a/docs/diagrams/AddCommandDiagram.puml b/docs/diagrams/AddCommandDiagram.puml index 0481571df01..417e094dcc2 100644 --- a/docs/diagrams/AddCommandDiagram.puml +++ b/docs/diagrams/AddCommandDiagram.puml @@ -12,7 +12,7 @@ participant "r:CommandResult" as CommandResult LOGIC_COLOR end box box Model MODEL_COLOR_T1 -participant ":ModelManager" as Model MODEL_COLOR +participant "m:Model" as Model MODEL_COLOR end box note left of LogicManager @@ -46,10 +46,10 @@ 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 @@ -86,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 8d397685116..dd95d7cdc76 100644 --- a/docs/diagrams/AddNoteSequenceDiagram.puml +++ b/docs/diagrams/AddNoteSequenceDiagram.puml @@ -14,7 +14,7 @@ participant "r:CommandResult" as CommandResult LOGIC_COLOR end box box Model MODEL_COLOR_T1 -participant ":ModelManager" as Model MODEL_COLOR +participant "m:Model" as Model MODEL_COLOR end box note left of LogicManager @@ -53,7 +53,7 @@ Note --> AddNoteCommandParser deactivate Note create AddNoteCommand -AddNoteCommandParser -> AddNoteCommand +AddNoteCommandParser -> AddNoteCommand : new AddNoteCommand(i, n, false) activate AddNoteCommand AddNoteCommand --> AddNoteCommandParser : a @@ -65,7 +65,7 @@ deactivate AddNoteCommandParser AddNoteCommandParser -[hidden]-> AddressBookParser destroy AddNoteCommandParser -AddressBookParser --> LogicManager : n +AddressBookParser --> LogicManager : a deactivate AddressBookParser LogicManager -> AddNoteCommand : execute(m) @@ -106,6 +106,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 b32fdac8182..f64e09141a4 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -6,12 +6,13 @@ 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 box Model MODEL_COLOR_T1 -participant ":ModelManager" as Model MODEL_COLOR +participant "m:Model" as Model MODEL_COLOR end box [-> LogicManager : execute("delete S0123456A") @@ -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 @@ -65,6 +73,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 196dc411258..68069d702b6 100644 --- a/docs/diagrams/EditCommandDiagram.puml +++ b/docs/diagrams/EditCommandDiagram.puml @@ -13,7 +13,7 @@ participant "r:CommandResult" as CommandResult LOGIC_COLOR end box box Model MODEL_COLOR_T1 -participant ":ModelManager" as Model MODEL_COLOR +participant "m:Model" as Model MODEL_COLOR end box note left of LogicManager @@ -52,10 +52,10 @@ 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 @@ -98,6 +98,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 ddb59af00b7..39c56457347 100644 --- a/docs/diagrams/FindSequenceDiagram.puml +++ b/docs/diagrams/FindSequenceDiagram.puml @@ -6,13 +6,13 @@ 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 -participant "p :IdentityCardNumberMatchesPredicate" as IdentityCardNumberMatchesPredicate LOGIC_COLOR end box box Model MODEL_COLOR_T1 -participant ":ModelManager" as Model MODEL_COLOR +participant "m:Model" as Model MODEL_COLOR end box [-> LogicManager : execute("find S0123456A") @@ -39,7 +39,7 @@ IdentityCardNumberMatchesPredicate --> FindCommandParser deactivate IdentityCardNumberMatchesPredicate create FindCommand -FindCommandParser -> FindCommand +FindCommandParser -> FindCommand : new FindCommand(p) activate FindCommand FindCommand --> FindCommandParser : f @@ -73,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 From 0220e31a5e97368c406eb2257d27d5640f6ee79a Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 22:27:38 +0800 Subject: [PATCH 06/10] Fix checkstyle --- src/main/java/seedu/address/logic/commands/DeleteCommand.java | 1 - src/main/java/seedu/address/logic/commands/ShowCommand.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index e1af33cd5c1..6ebcdb27bb8 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -2,7 +2,6 @@ import static java.util.Objects.requireNonNull; -import java.util.List; import java.util.logging.Logger; import seedu.address.commons.core.LogsCenter; diff --git a/src/main/java/seedu/address/logic/commands/ShowCommand.java b/src/main/java/seedu/address/logic/commands/ShowCommand.java index d4e956ba5a6..1311c51b1e8 100644 --- a/src/main/java/seedu/address/logic/commands/ShowCommand.java +++ b/src/main/java/seedu/address/logic/commands/ShowCommand.java @@ -2,7 +2,6 @@ import static java.util.Objects.requireNonNull; -import java.util.List; import java.util.logging.Logger; import seedu.address.commons.core.LogsCenter; From c52bd388860fd51985b3018e5b74e97ebc577e89 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 22:45:11 +0800 Subject: [PATCH 07/10] Fix typos --- docs/DeveloperGuide.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index decd311b457..4d6fd3f77cc 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -176,8 +176,8 @@ Given below is an example usage scenario and how the `add` mechanism behaves at 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 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 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. @@ -218,7 +218,7 @@ The following activity diagram summarizes what happens when a user executes a ne * Pros: Shorter command to type to add a patient. * Cons: * We must ensure that the implementation of each individual commands is correct. - * Might not have all the relevant information of the patients. Messy to keep track. + * 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 ClinicMate. @@ -238,14 +238,14 @@ These operations are exposed in the `Model` interface as `Model#setPerson(Person The `addnote` feature has the following operations in `ModelManager` which implements the `Model` interface: - `Model#setPerson`: Changes the note parameter of the target Person -- `Model#isPersonDisplayed`: Checks if the `Person` has their notes displayed in the person notes panel +- `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 n\Covid` to add a note to the person in ClinicMate with the unique identification number `T0123456A`. +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. @@ -308,7 +308,7 @@ Given below is an example usage scenario and how the find mechanism behaves at e Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state. -Step 2. The user executes `find S0123456A` to find the person in the address book with the unique identification number `S0123456A`. The find command calls `Model#updateFilteredPersonList(Predicate predicate)`, +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. @@ -336,8 +336,8 @@ The following activity diagram summarizes what happens when a user executes a ne #### Design Considerations & Alternatives Considered **Aspect: Filtering patients** -* **Alternative 1 (Current Choice):** Requires user to input a full and valid IC number - * Pros: Precise results, allows user to directly single out the patient details +* **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 @@ -363,7 +363,7 @@ Given below is an example usage scenario and how the delete mechanism behaves at Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state. -Step 2. The user executes `delete S0123456A` to delete the person in the address book with the unique identification number `S0123456A`. +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. From 82a75cf89c08080d0dca3aeef14f4dd679c6f1a6 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 22:49:33 +0800 Subject: [PATCH 08/10] Fix missing details --- docs/DeveloperGuide.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index 4d6fd3f77cc..b802ff3b190 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -192,7 +192,7 @@ The following sequence diagram illustrates how the `add` command works and goes -**Note:** The lifeline for `AddCommandParser` 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. @@ -260,7 +260,7 @@ The following sequence diagram shows how an `addnote` operation goes through the -**Note:** The lifeline for `AddNoteCommandParser` 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. @@ -323,7 +323,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. @@ -378,7 +378,7 @@ The following sequence diagram shows how a delete operation goes through the `Lo -**Note:** The lifeline for `DeleteCommandParser` 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. @@ -424,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. From 846bc509dd084b85e31d3b95ca4f811fd6103c0a Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 23:06:36 +0800 Subject: [PATCH 09/10] Fix Addnote and delete sequence diagrams --- docs/DeveloperGuide.md | 7 ++++--- docs/diagrams/AddNoteSequenceDiagram.puml | 6 ++++++ docs/diagrams/DeleteSequenceDiagram.puml | 6 ++++++ docs/diagrams/EditCommandDiagram.puml | 6 ++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index b802ff3b190..e0734e1ef88 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -234,9 +234,9 @@ The following activity diagram summarizes what happens when a user executes a ne 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 as `Model#getPersonIfExists(Predicate predicate)` and `Model#setPerson(Person target, Person editedPerson)` -The `addnote` feature has the following operations in `ModelManager` which implements the `Model` interface: +The `addnote` feature also has the following operations in `ModelManager` which implements the `Model` interface: - `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 @@ -357,7 +357,8 @@ The following activity diagram summarizes what happens when a user executes a ne 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#deletePerson(Person target)`. +These operations are exposed in the `Model` interface as `Model#getPersonIfExists(Predicate predicate)` and `Model#deletePerson(Person target)`. + Given below is an example usage scenario and how the delete mechanism behaves at each step. diff --git a/docs/diagrams/AddNoteSequenceDiagram.puml b/docs/diagrams/AddNoteSequenceDiagram.puml index dd95d7cdc76..58b0ba92303 100644 --- a/docs/diagrams/AddNoteSequenceDiagram.puml +++ b/docs/diagrams/AddNoteSequenceDiagram.puml @@ -78,6 +78,12 @@ activate Person Person --> AddNoteCommand deactivate Person +AddNoteCommand -> Model : getPersonIfExists(...) +activate Model + +Model --> AddNoteCommand +deactivate Model + AddNoteCommand -> Model : setPerson(...) activate Model diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml index f64e09141a4..74bd45903e4 100644 --- a/docs/diagrams/DeleteSequenceDiagram.puml +++ b/docs/diagrams/DeleteSequenceDiagram.puml @@ -57,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 diff --git a/docs/diagrams/EditCommandDiagram.puml b/docs/diagrams/EditCommandDiagram.puml index 68069d702b6..f1477bbf20c 100644 --- a/docs/diagrams/EditCommandDiagram.puml +++ b/docs/diagrams/EditCommandDiagram.puml @@ -70,6 +70,12 @@ deactivate AddressBookParser LogicManager -> EditCommand : execute(m) activate EditCommand +EditCommand -> Model : getPersonIfExists(...) +activate Model + +Model --> EditCommand +deactivate Model + EditCommand -> Model : hasPerson(...) activate Model From 7e78654d9a10027b5e7bde36eb178274c59de9b1 Mon Sep 17 00:00:00 2001 From: jiahui0309 Date: Sun, 14 Apr 2024 23:16:21 +0800 Subject: [PATCH 10/10] Edit DG comments --- docs/DeveloperGuide.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index e0734e1ef88..876b46a0c1d 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -234,9 +234,8 @@ The following activity diagram summarizes what happens when a user executes a ne 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#getPersonIfExists(Predicate predicate)` and `Model#setPerson(Person target, Person editedPerson)` - -The `addnote` feature also has the following operations in `ModelManager` which implements the `Model` interface: +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