From fdf67fdd087c6ef2869d732ad694c7f654ecf92c Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Thu, 20 Feb 2020 15:51:07 +0800 Subject: [PATCH 001/611] Replace the URL in the attribute repoURL --- docs/DeveloperGuide.adoc | 2 +- docs/UserGuide.adoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 3d65905a853..6fe479b42f7 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -12,7 +12,7 @@ ifdef::env-github[] :note-caption: :information_source: :warning-caption: :warning: endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3/tree/master +:repoURL: https://github.com/huixianc/main By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT` diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 4e5d297a19f..0d10e028c5c 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -12,7 +12,7 @@ ifdef::env-github[] :tip-caption: :bulb: :note-caption: :information_source: endif::[] -:repoURL: https://github.com/se-edu/addressbook-level3 +:repoURL: https://github.com/huixianc/main By: `Team SE-EDU` Since: `Jun 2016` Licence: `MIT` From 1002ab2ed8a1a25e4cf6180c33e2e52fcef5029a Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Thu, 20 Feb 2020 20:13:21 +0800 Subject: [PATCH 002/611] Update the link to the 'build status' badge at top of the README --- README.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index e36efe534bb..6a00fb53dba 100644 --- a/README.adoc +++ b/README.adoc @@ -1,7 +1,7 @@ = Address Book (Level 3) ifdef::env-github,env-browser[:relfileprefix: docs/] -https://travis-ci.org/se-edu/addressbook-level3[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] +https://travis-ci.org/huixianc/main[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] From 10b1c9f1b5998a374dd904ecd818bd006036966c Mon Sep 17 00:00:00 2001 From: BryanYap972 Date: Thu, 20 Feb 2020 20:30:23 +0800 Subject: [PATCH 003/611] initial commit --- src/main/java/seedu/address/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/Main.java b/src/main/java/seedu/address/Main.java index 052a5068631..88439c263c2 100644 --- a/src/main/java/seedu/address/Main.java +++ b/src/main/java/seedu/address/Main.java @@ -3,7 +3,7 @@ import javafx.application.Application; /** - * The main entry point to the application. + * The main entry point to application. * * This is a workaround for the following error when MainApp is made the * entry point of the application: From 092ea8546f20d2e15cd8774ec9a42d2d5e75e22b Mon Sep 17 00:00:00 2001 From: BryanYap972 Date: Thu, 20 Feb 2020 20:32:20 +0800 Subject: [PATCH 004/611] initial commit --- src/main/java/seedu/address/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/Main.java b/src/main/java/seedu/address/Main.java index 88439c263c2..3eee30228ce 100644 --- a/src/main/java/seedu/address/Main.java +++ b/src/main/java/seedu/address/Main.java @@ -8,7 +8,7 @@ * This is a workaround for the following error when MainApp is made the * entry point of the application: * - * Error: JavaFX runtime components are missing, and are required to run this application + * Error: JavaFX runtime components missing, and are required to run this application * * The reason is that MainApp extends Application. In that case, the * LauncherHelper will check for the javafx.graphics module to be present From c2ba92b120421ae53981e02003ea048acee422e4 Mon Sep 17 00:00:00 2001 From: Yap Wen Jun Bryan <52154266+BryanYap972@users.noreply.github.com> Date: Thu, 20 Feb 2020 20:39:31 +0800 Subject: [PATCH 005/611] Revert "Travis" --- src/main/java/seedu/address/Main.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/Main.java b/src/main/java/seedu/address/Main.java index 3eee30228ce..052a5068631 100644 --- a/src/main/java/seedu/address/Main.java +++ b/src/main/java/seedu/address/Main.java @@ -3,12 +3,12 @@ import javafx.application.Application; /** - * The main entry point to application. + * The main entry point to the application. * * This is a workaround for the following error when MainApp is made the * entry point of the application: * - * Error: JavaFX runtime components missing, and are required to run this application + * Error: JavaFX runtime components are missing, and are required to run this application * * The reason is that MainApp extends Application. In that case, the * LauncherHelper will check for the javafx.graphics module to be present From dedc1c6adffd0ec487c86a25e0b4f244cd81a0e0 Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Mon, 24 Feb 2020 16:01:39 +0800 Subject: [PATCH 006/611] removed codacy badge --- README.adoc | 1 - build.gradle | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index 6a00fb53dba..82c59413572 100644 --- a/README.adoc +++ b/README.adoc @@ -4,7 +4,6 @@ ifdef::env-github,env-browser[:relfileprefix: docs/] https://travis-ci.org/huixianc/main[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] -https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] ifdef::env-github[] diff --git a/build.gradle b/build.gradle index 93029ef8262..813e412f1a9 100644 --- a/build.gradle +++ b/build.gradle @@ -133,8 +133,8 @@ asciidoctor { idprefix: '', // for compatibility with GitHub preview idseparator: '-', 'site-root': "${sourceDir}", // must be the same as sourceDir, do not modify - 'site-name': 'AddressBook-Level3', - 'site-githuburl': 'https://github.com/se-edu/addressbook-level3', + 'site-name': 'NOVA', + 'site-githuburl': 'https://github.com/huixianc/main', 'site-seedu': true, // delete this line if your project is not a fork (not a SE-EDU project) ] From 91a70c35041088be3a4593b4d1956047114b2bae Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Mon, 24 Feb 2020 16:14:27 +0800 Subject: [PATCH 007/611] changed documentation back to original --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 813e412f1a9..93029ef8262 100644 --- a/build.gradle +++ b/build.gradle @@ -133,8 +133,8 @@ asciidoctor { idprefix: '', // for compatibility with GitHub preview idseparator: '-', 'site-root': "${sourceDir}", // must be the same as sourceDir, do not modify - 'site-name': 'NOVA', - 'site-githuburl': 'https://github.com/huixianc/main', + 'site-name': 'AddressBook-Level3', + 'site-githuburl': 'https://github.com/se-edu/addressbook-level3', 'site-seedu': true, // delete this line if your project is not a fork (not a SE-EDU project) ] From a6f7c07516793eb714093221d1856ff044b1d762 Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Mon, 24 Feb 2020 16:41:16 +0800 Subject: [PATCH 008/611] added codacy badge back --- README.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/README.adoc b/README.adoc index 82c59413572..6a00fb53dba 100644 --- a/README.adoc +++ b/README.adoc @@ -4,6 +4,7 @@ ifdef::env-github,env-browser[:relfileprefix: docs/] https://travis-ci.org/huixianc/main[image:https://travis-ci.org/se-edu/addressbook-level3.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level3[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/se-edu/addressbook-level3?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level3/badge.svg?branch=master[Coverage Status]] +https://www.codacy.com/app/damith/addressbook-level3?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level3&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] ifdef::env-github[] From 00e9532b9a63f704e6779605a7b20f56d8fecf9c Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Mon, 24 Feb 2020 18:26:25 +0800 Subject: [PATCH 009/611] changed documentation --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 93029ef8262..813e412f1a9 100644 --- a/build.gradle +++ b/build.gradle @@ -133,8 +133,8 @@ asciidoctor { idprefix: '', // for compatibility with GitHub preview idseparator: '-', 'site-root': "${sourceDir}", // must be the same as sourceDir, do not modify - 'site-name': 'AddressBook-Level3', - 'site-githuburl': 'https://github.com/se-edu/addressbook-level3', + 'site-name': 'NOVA', + 'site-githuburl': 'https://github.com/huixianc/main', 'site-seedu': true, // delete this line if your project is not a fork (not a SE-EDU project) ] From 590bd2dd60c48e1d86a29ddb170178d486416050 Mon Sep 17 00:00:00 2001 From: huixianc <50432304+huixianc@users.noreply.github.com> Date: Mon, 24 Feb 2020 19:16:55 +0800 Subject: [PATCH 010/611] added annotations for tutorial 1 --- src/main/java/seedu/address/logic/LogicManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index d47ce874b1a..226fe0b5408 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -36,13 +36,18 @@ public LogicManager(Model model, Storage storage) { @Override public CommandResult execute(String commandText) throws CommandException, ParseException { + //Logging, safe to ignore logger.info("----------------[USER COMMAND][" + commandText + "]"); CommandResult commandResult; + //Parse user input from String to a Command Command command = addressBookParser.parseCommand(commandText); + //Executes the Command and stores the result commandResult = command.execute(model); try { + //We can deduce that the previous line of code modifies model in some way + // since it's being stored here. storage.saveAddressBook(model.getAddressBook()); } catch (IOException ioe) { throw new CommandException(FILE_OPS_ERROR_MESSAGE + ioe, ioe); From 069c06c3b46f03466de549fdf43ff035be59cc43 Mon Sep 17 00:00:00 2001 From: BryanYap972 Date: Wed, 26 Feb 2020 12:48:39 +0800 Subject: [PATCH 011/611] Testing --- main | 1 + src/main/java/seedu/address/commons/core/GuiSettings.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 main diff --git a/main b/main new file mode 160000 index 00000000000..5ca0de20676 --- /dev/null +++ b/main @@ -0,0 +1 @@ +Subproject commit 5ca0de206769431c7a42a7cec80a45901f0d859b diff --git a/src/main/java/seedu/address/commons/core/GuiSettings.java b/src/main/java/seedu/address/commons/core/GuiSettings.java index 5ace559ad15..dc4330bdb8b 100644 --- a/src/main/java/seedu/address/commons/core/GuiSettings.java +++ b/src/main/java/seedu/address/commons/core/GuiSettings.java @@ -6,7 +6,7 @@ /** * A Serializable class that contains the GUI settings. - * Guarantees: immutable. + * Guaranteed: immutable. */ public class GuiSettings implements Serializable { From 7eb04a04b42267b4fd4c83feda8dd61fdc03e33d Mon Sep 17 00:00:00 2001 From: BryanYap972 Date: Wed, 26 Feb 2020 12:58:01 +0800 Subject: [PATCH 012/611] Testing --- main | 1 - 1 file changed, 1 deletion(-) delete mode 160000 main diff --git a/main b/main deleted file mode 160000 index 5ca0de20676..00000000000 --- a/main +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5ca0de206769431c7a42a7cec80a45901f0d859b From aaae9ce844060fd604548d7ba89d4014b4b9e723 Mon Sep 17 00:00:00 2001 From: BryanYap972 Date: Wed, 26 Feb 2020 17:55:27 +0800 Subject: [PATCH 013/611] Added remark command. --- .../address/logic/commands/AddCommand.java | 1 + .../address/logic/commands/EditCommand.java | 4 +- .../address/logic/commands/RemarkCommand.java | 63 +++++++++++++++++++ .../logic/parser/AddCommandParser.java | 4 +- .../logic/parser/AddressBookParser.java | 4 ++ .../seedu/address/logic/parser/CliSyntax.java | 2 +- .../logic/parser/RemarkCommandParser.java | 39 ++++++++++++ .../seedu/address/model/person/Person.java | 11 +++- .../seedu/address/model/person/Remark.java | 33 ++++++++++ .../address/model/util/SampleDataUtil.java | 16 +++-- .../address/storage/JsonAdaptedPerson.java | 14 ++++- .../java/seedu/address/ui/PersonCard.java | 5 ++ src/main/resources/view/PersonListCard.fxml | 1 + .../duplicatePersonAddressBook.json | 6 +- .../typicalPersonsAddressBook.json | 21 ++++--- .../storage/JsonAdaptedPersonTest.java | 23 ++++--- .../seedu/address/testutil/PersonBuilder.java | 16 ++++- .../address/testutil/TypicalPersons.java | 4 +- 18 files changed, 234 insertions(+), 33 deletions(-) create mode 100644 src/main/java/seedu/address/logic/commands/RemarkCommand.java create mode 100644 src/main/java/seedu/address/logic/parser/RemarkCommandParser.java create mode 100644 src/main/java/seedu/address/model/person/Remark.java diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 71656d7c5c8..db9ca938c6b 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -11,6 +11,7 @@ import seedu.address.model.Model; import seedu.address.model.person.Person; + /** * Adds a person to the address book. */ diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 7e36114902f..28b7e3bb9a1 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -25,6 +25,7 @@ import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; +import seedu.address.model.person.Remark; /** * Edits the details of an existing person in the address book. @@ -98,8 +99,9 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); + Remark updatedRemark = personToEdit.getRemark(); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags, updatedRemark); } @Override diff --git a/src/main/java/seedu/address/logic/commands/RemarkCommand.java b/src/main/java/seedu/address/logic/commands/RemarkCommand.java new file mode 100644 index 00000000000..8a73170910e --- /dev/null +++ b/src/main/java/seedu/address/logic/commands/RemarkCommand.java @@ -0,0 +1,63 @@ +package seedu.address.logic.commands; + +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import seedu.address.commons.core.index.Index; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.Model; +import seedu.address.model.person.Remark; + +/** + * Changes the remark of an existing person in the address book. + */ +public class RemarkCommand extends Command { + + public static final String COMMAND_WORD = "remark"; + public static final String MESSAGE_ARGUMENTS = "Index: %1$d, Remark: %2$s"; + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the remark of the person identified " + + "by the index number used in the last person listing. " + + "Existing remark will be overwritten by the input.\n" + + "Parameters: INDEX (must be a positive integer) " + + "r/ [REMARK]\n" + + "Example: " + COMMAND_WORD + " 1 " + + "r/ Likes to swim."; + + public static final String MESSAGE_NOT_IMPLEMENTED_YET = "Remark command not implemented yet"; + + private final Index index; + private final Remark remark; + + /** + * @param index of the person in the filtered person list to edit the remark + * @param remark of the person to be updated to + */ + public RemarkCommand(Index index, Remark remark) { + requireAllNonNull(index, remark); + + this.index = index; + this.remark = remark; + } + + @Override + public CommandResult execute(Model model) throws CommandException { + throw new CommandException(MESSAGE_NOT_IMPLEMENTED_YET); + } + + @Override + public boolean equals(Object other) { + // short circuit if same object + if (other == this) { + return true; + } + + // instanceof handles nulls + if (!(other instanceof RemarkCommand)) { + return false; + } + + // state check + RemarkCommand e = (RemarkCommand) other; + return index.equals(e.index) + && remark.equals(e.remark); + } +} diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3b8bfa035e8..d854752f935 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -17,6 +17,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Remark; import seedu.address.model.tag.Tag; /** @@ -43,8 +44,9 @@ public AddCommand parse(String args) throws ParseException { Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); + Remark remark = new Remark(""); - Person person = new Person(name, phone, email, address, tagList); + Person person = new Person(name, phone, email, address, tagList, remark); return new AddCommand(person); } diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index 1e466792b46..b650f13a6b9 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -15,6 +15,7 @@ import seedu.address.logic.commands.FindCommand; import seedu.address.logic.commands.HelpCommand; import seedu.address.logic.commands.ListCommand; +import seedu.address.logic.commands.RemarkCommand; import seedu.address.logic.parser.exceptions.ParseException; /** @@ -68,6 +69,9 @@ public Command parseCommand(String userInput) throws ParseException { case HelpCommand.COMMAND_WORD: return new HelpCommand(); + case RemarkCommand.COMMAND_WORD: + return new RemarkCommandParser().parse(arguments); + default: throw new ParseException(MESSAGE_UNKNOWN_COMMAND); } diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf119..798f15d2d81 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,5 +11,5 @@ public class CliSyntax { public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); - + public static final Prefix PREFIX_REMARK = new Prefix("r/"); } diff --git a/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java new file mode 100644 index 00000000000..97aa402a14f --- /dev/null +++ b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java @@ -0,0 +1,39 @@ +package seedu.address.logic.parser; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; + +import seedu.address.commons.core.index.Index; +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.logic.commands.RemarkCommand; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.person.Remark; + +/** + * Parses input arguments and creates a new {@code RemarkCommand} object + */ +public class RemarkCommandParser implements Parser { + + /** + * Parses the given {@code String} of arguments in the context of the {@code RemarkCommand} + * and returns a {@code RemarkCommand} object for execution. + * @throws ParseException if the user input does not conform the expected format + */ + public RemarkCommand parse(String args) throws ParseException { + requireNonNull(args); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_REMARK); + + Index index; + try { + index = ParserUtil.parseIndex(argMultimap.getPreamble()); + } catch (IllegalValueException ive) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, RemarkCommand.MESSAGE_USAGE), ive); + } + + String value = argMultimap.getValue(PREFIX_REMARK).orElse(""); + Remark remark = new Remark(value); + + return new RemarkCommand(index, remark); + } +} \ No newline at end of file diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 557a7a60cd5..ea52c4d0792 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -20,20 +20,23 @@ public class Person { private final Phone phone; private final Email email; + // Data fields private final Address address; + private final Remark remark; private final Set tags = new HashSet<>(); /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, Set tags) { + public Person(Name name, Phone phone, Email email, Address address, Set tags, Remark remark) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; this.tags.addAll(tags); + this.remark = remark; } public Name getName() { @@ -48,6 +51,10 @@ public Email getEmail() { return email; } + public Remark getRemark() { + return remark; + } + public Address getAddress() { return address; } @@ -112,6 +119,8 @@ public String toString() { .append(getEmail()) .append(" Address: ") .append(getAddress()) + .append(" Remarks: ") + .append(getRemark()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/model/person/Remark.java b/src/main/java/seedu/address/model/person/Remark.java new file mode 100644 index 00000000000..2e5c65280b9 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Remark.java @@ -0,0 +1,33 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; + +/** + * Represents a Person's remark in the address book. + * Guarantees: immutable; is always valid + */ +public class Remark { + public final String value; + + public Remark(String remark) { + requireNonNull(remark); + value = remark; + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Remark // instanceof handles nulls + && value.equals(((Remark) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 1806da4facf..5c79a1fd4ef 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -11,32 +11,36 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Remark; import seedu.address.model.tag.Tag; /** * Contains utility methods for populating {@code AddressBook} with sample data. */ public class SampleDataUtil { + + public static final Remark EMPTY_REMARK = new Remark(""); + public static Person[] getSamplePersons() { return new Person[] { new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), new Address("Blk 30 Geylang Street 29, #06-40"), - getTagSet("friends")), + getTagSet("friends"), EMPTY_REMARK), new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - getTagSet("colleagues", "friends")), + getTagSet("colleagues", "friends"), EMPTY_REMARK), new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), - getTagSet("neighbours")), + getTagSet("neighbours"), EMPTY_REMARK), new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), - getTagSet("family")), + getTagSet("family"), EMPTY_REMARK), new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), new Address("Blk 47 Tampines Street 20, #17-35"), - getTagSet("classmates")), + getTagSet("classmates"), EMPTY_REMARK), new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), new Address("Blk 45 Aljunied Street 85, #11-31"), - getTagSet("colleagues")) + getTagSet("colleagues"), EMPTY_REMARK) }; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index a6321cec2ea..a14efe6889a 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -16,6 +16,7 @@ import seedu.address.model.person.Person; import seedu.address.model.person.Phone; import seedu.address.model.tag.Tag; +import seedu.address.model.person.Remark; /** * Jackson-friendly version of {@link Person}. @@ -29,6 +30,7 @@ class JsonAdaptedPerson { private final String email; private final String address; private final List tagged = new ArrayList<>(); + private final String remark; /** * Constructs a {@code JsonAdaptedPerson} with the given person details. @@ -36,7 +38,7 @@ class JsonAdaptedPerson { @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @JsonProperty("email") String email, @JsonProperty("address") String address, - @JsonProperty("tagged") List tagged) { + @JsonProperty("tagged") List tagged, @JsonProperty("remark") String remark) { this.name = name; this.phone = phone; this.email = email; @@ -44,6 +46,7 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone if (tagged != null) { this.tagged.addAll(tagged); } + this.remark = remark; } /** @@ -57,6 +60,7 @@ public JsonAdaptedPerson(Person source) { tagged.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); + remark = source.getRemark().value; } /** @@ -103,7 +107,13 @@ public Person toModelType() throws IllegalValueException { final Address modelAddress = new Address(address); final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags); + + if (remark == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Remark.class.getSimpleName())); + } + final Remark modelRemark = new Remark(remark); + + return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags, modelRemark); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index 0684b088868..11eeb6c19be 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -38,6 +38,10 @@ public class PersonCard extends UiPart { private Label address; @FXML private Label email; + + @FXML + private Label remark; + @FXML private FlowPane tags; @@ -52,6 +56,7 @@ public PersonCard(Person person, int displayedIndex) { person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + remark.setText(person.getRemark().value); } @Override diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f08ea32ad55..d1a7eb614f8 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -31,6 +31,7 @@