From 330c0a699c514c49eefc6e2af68f911d5f910cef Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:01:51 +0800 Subject: [PATCH 01/49] Update Messages.java --- src/main/java/staffconnect/logic/Messages.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/staffconnect/logic/Messages.java b/src/main/java/staffconnect/logic/Messages.java index 237754bf0e1..7e6639ea5ac 100644 --- a/src/main/java/staffconnect/logic/Messages.java +++ b/src/main/java/staffconnect/logic/Messages.java @@ -40,6 +40,8 @@ public static String format(Person person) { .append("; Phone: ") .append(person.getPhone()) .append("; Email: ") + .append(person.getFaculty()) + .append("; Faculty: ") .append(person.getEmail()) .append("; Venue: ") .append(person.getVenue()) From f66399e8b268adf3137fbce45d410843643adfda Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:04:09 +0800 Subject: [PATCH 02/49] Update CliSyntax.java Represent faculty by "f/" --- src/main/java/staffconnect/logic/parser/CliSyntax.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/staffconnect/logic/parser/CliSyntax.java b/src/main/java/staffconnect/logic/parser/CliSyntax.java index 9493ab188e5..9676d720b05 100644 --- a/src/main/java/staffconnect/logic/parser/CliSyntax.java +++ b/src/main/java/staffconnect/logic/parser/CliSyntax.java @@ -9,6 +9,7 @@ public class CliSyntax { public static final Prefix PREFIX_NAME = new Prefix("n/"); public static final Prefix PREFIX_PHONE = new Prefix("p/"); public static final Prefix PREFIX_EMAIL = new Prefix("e/"); + public static final Prefix PREFIX_FACULTY = new Prefix("f/"); public static final Prefix PREFIX_VENUE = new Prefix("v/"); public static final Prefix PREFIX_MODULE = new Prefix("m/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); From 91e8a9d44303680cb9073030f76af01768ba6bac Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:10:32 +0800 Subject: [PATCH 03/49] Update AddCommand and AddCommandParser to use Faculty --- .../staffconnect/logic/commands/AddCommand.java | 3 +++ .../staffconnect/logic/parser/AddCommandParser.java | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/staffconnect/logic/commands/AddCommand.java b/src/main/java/staffconnect/logic/commands/AddCommand.java index e89a8a8ad1a..101401e8899 100644 --- a/src/main/java/staffconnect/logic/commands/AddCommand.java +++ b/src/main/java/staffconnect/logic/commands/AddCommand.java @@ -3,6 +3,7 @@ import static java.util.Objects.requireNonNull; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; +import static staffconnect.logic.parser.CliSyntax.PREFIX_FACULTY; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -26,6 +27,7 @@ public class AddCommand extends Command { + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + + PREFIX_FACULTY + "FACULTY " + PREFIX_VENUE + "VENUE " + PREFIX_MODULE + "MODULE " + "[" + PREFIX_TAG + "TAG]...\n" @@ -33,6 +35,7 @@ public class AddCommand extends Command { + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + + PREFIX_FACULTY + "Computing " + PREFIX_VENUE + "311, Clementi Ave 2, #02-25 " + PREFIX_MODULE + "CS2103 " + PREFIX_TAG + "friends " diff --git a/src/main/java/staffconnect/logic/parser/AddCommandParser.java b/src/main/java/staffconnect/logic/parser/AddCommandParser.java index 3b8bf5a2f62..43268f97c41 100644 --- a/src/main/java/staffconnect/logic/parser/AddCommandParser.java +++ b/src/main/java/staffconnect/logic/parser/AddCommandParser.java @@ -3,6 +3,7 @@ import static staffconnect.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; +import static staffconnect.logic.parser.CliSyntax.PREFIX_FACULTY; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -15,6 +16,7 @@ import staffconnect.logic.parser.exceptions.ParseException; import staffconnect.model.person.Email; import staffconnect.model.person.Module; +import staffconnect.model.person.Faculty; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -33,23 +35,24 @@ public class AddCommandParser implements Parser { */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, - PREFIX_EMAIL, PREFIX_VENUE, PREFIX_MODULE, PREFIX_TAG); + PREFIX_EMAIL, PREFIX_FACULTY, PREFIX_VENUE, PREFIX_MODULE, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_VENUE, PREFIX_MODULE) - || !argMultimap.getPreamble().isEmpty()) { + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_FACULTY + , PREFIX_VENUE, PREFIX_MODULE) || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_FACULTY, PREFIX_VENUE, PREFIX_MODULE); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); Venue venue = ParserUtil.parseVenue(argMultimap.getValue(PREFIX_VENUE).get()); + Faculty faculty = ParserUtil.parseFaculty(argMultimap.getValue(PREFIX_FACULTY).get()); Module module = ParserUtil.parseModule(argMultimap.getValue(PREFIX_MODULE).get()); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, venue, module, tagList); + Person person = new Person(name, phone, email, faculty, venue, module, tagList); return new AddCommand(person); } From ded5c453fb8e74585740d559bfc3a19c9c5fddd0 Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:21:26 +0800 Subject: [PATCH 04/49] Update EditCommand and EditCommandParser to use Faculty --- .../logic/commands/EditCommand.java | 21 +++++++++++++++++-- .../logic/parser/EditCommandParser.java | 8 +++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/staffconnect/logic/commands/EditCommand.java b/src/main/java/staffconnect/logic/commands/EditCommand.java index a2a253942d1..ac2fa35af5b 100644 --- a/src/main/java/staffconnect/logic/commands/EditCommand.java +++ b/src/main/java/staffconnect/logic/commands/EditCommand.java @@ -3,6 +3,7 @@ import static java.util.Objects.requireNonNull; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; +import static staffconnect.logic.parser.CliSyntax.PREFIX_FACULTY; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -24,6 +25,7 @@ import staffconnect.model.Model; import staffconnect.model.person.Email; import staffconnect.model.person.Module; +import staffconnect.model.person.Faculty; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -44,6 +46,7 @@ public class EditCommand extends Command { + "[" + PREFIX_NAME + "NAME] " + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " + + "[" + PREFIX_FACULTY + "FACULTY] " + "[" + PREFIX_VENUE + "VENUE] " + "[" + PREFIX_MODULE + "MODULE] " + "[" + PREFIX_TAG + "TAG]...\n" @@ -101,11 +104,13 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName()); Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); + Faculty updatedFaculty = editPersonDescriptor.getFaculty().orElse(personToEdit.getFaculty()); Venue updatedVenue = editPersonDescriptor.getVenue().orElse(personToEdit.getVenue()); Module updatedModule = editPersonDescriptor.getModule().orElse(personToEdit.getModule()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedVenue, updatedModule, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedFaculty, + updatedVenue, updatedModule, updatedTags); } @Override @@ -140,6 +145,7 @@ public static class EditPersonDescriptor { private Name name; private Phone phone; private Email email; + private Faculty faculty; private Venue venue; private Module module; private Set tags; @@ -154,6 +160,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setName(toCopy.name); setPhone(toCopy.phone); setEmail(toCopy.email); + setFaculty(toCopy.faculty); setVenue(toCopy.venue); setModule(toCopy.module); setTags(toCopy.tags); @@ -163,7 +170,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, venue, module, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, faculty, venue, module, tags); } public void setName(Name name) { @@ -190,6 +197,14 @@ public Optional getEmail() { return Optional.ofNullable(email); } + public void setFaculty(Faculty faculty) { + this.faculty = faculty; + } + + public Optional getFaculty() { + return Optional.ofNullable(faculty); + } + public void setVenue(Venue venue) { this.venue = venue; } @@ -238,6 +253,7 @@ public boolean equals(Object other) { return Objects.equals(name, otherEditPersonDescriptor.name) && Objects.equals(phone, otherEditPersonDescriptor.phone) && Objects.equals(email, otherEditPersonDescriptor.email) + && Objects.equals(faculty, otherEditPersonDescriptor.faculty) && Objects.equals(venue, otherEditPersonDescriptor.venue) && Objects.equals(module, otherEditPersonDescriptor.module) && Objects.equals(tags, otherEditPersonDescriptor.tags); @@ -249,6 +265,7 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) + .add("faculty", faculty) .add("venue", venue) .add("module", module) .add("tags", tags) diff --git a/src/main/java/staffconnect/logic/parser/EditCommandParser.java b/src/main/java/staffconnect/logic/parser/EditCommandParser.java index 3249935c101..a229119e0a3 100644 --- a/src/main/java/staffconnect/logic/parser/EditCommandParser.java +++ b/src/main/java/staffconnect/logic/parser/EditCommandParser.java @@ -4,6 +4,7 @@ import static staffconnect.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; +import static staffconnect.logic.parser.CliSyntax.PREFIX_FACULTY; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -33,7 +34,7 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_FACULTY, PREFIX_VENUE, PREFIX_MODULE, PREFIX_TAG); Index index; @@ -44,7 +45,7 @@ public EditCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_FACULTY, PREFIX_VENUE, PREFIX_MODULE); EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); @@ -58,6 +59,9 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) { editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get())); } + if (argMultimap.getValue(PREFIX_FACULTY).isPresent()) { + editPersonDescriptor.setFaculty(ParserUtil.parseFaculty(argMultimap.getValue(PREFIX_FACULTY).get())); + } if (argMultimap.getValue(PREFIX_VENUE).isPresent()) { editPersonDescriptor.setVenue(ParserUtil.parseVenue(argMultimap.getValue(PREFIX_VENUE).get())); } From d7ed9716d78b70b7d3cc790fffa3c1ac65a64db5 Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:29:09 +0800 Subject: [PATCH 05/49] Update ParserUtil to include Faculty --- .../staffconnect/logic/parser/ParserUtil.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/staffconnect/logic/parser/ParserUtil.java b/src/main/java/staffconnect/logic/parser/ParserUtil.java index 454061da8b3..1e9968154c7 100644 --- a/src/main/java/staffconnect/logic/parser/ParserUtil.java +++ b/src/main/java/staffconnect/logic/parser/ParserUtil.java @@ -11,6 +11,7 @@ import staffconnect.logic.parser.exceptions.ParseException; import staffconnect.model.person.Email; import staffconnect.model.person.Module; +import staffconnect.model.person.Faculty; import staffconnect.model.person.Name; import staffconnect.model.person.Phone; import staffconnect.model.person.Venue; @@ -81,6 +82,21 @@ public static Email parseEmail(String email) throws ParseException { return new Email(trimmedEmail); } + /** + * Parses a {@code String faculty} into an {@code Faculty}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code faculty} is invalid. + */ + public static Faculty parseFaculty(String faculty) throws ParseException { + requireNonNull(faculty); + String trimmedFaculty = faculty.trim(); + if (!Faculty.isValidFaculty(trimmedFaculty)) { + throw new ParseException(Faculty.MESSAGE_CONSTRAINTS); + } + return new Faculty(trimmedFaculty); + } + /** * Parses a {@code String venue} into an {@code Venue}. * Leading and trailing whitespaces will be trimmed. From 89fc0250ef563043908d9c3bb568b2114503e26d Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:33:50 +0800 Subject: [PATCH 06/49] Update Person to include Faculty --- .../java/staffconnect/model/person/Person.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/staffconnect/model/person/Person.java b/src/main/java/staffconnect/model/person/Person.java index 5c10209078e..a445c35b4a2 100644 --- a/src/main/java/staffconnect/model/person/Person.java +++ b/src/main/java/staffconnect/model/person/Person.java @@ -20,6 +20,7 @@ public class Person { private final Name name; private final Phone phone; private final Email email; + private final Faculty faculty; // Data fields private final Venue venue; @@ -29,11 +30,12 @@ public class Person { /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Venue venue, Module module, Set tags) { - requireAllNonNull(name, phone, email, venue, module, tags); + public Person(Name name, Phone phone, Email email, Faculty faculty, Venue venue, Module module, Set tags) { + requireAllNonNull(name, phone, email, faculty, venue, module, tags); this.name = name; this.phone = phone; this.email = email; + this.faculty = faculty; this.venue = venue; this.module = module; this.tags.addAll(tags); @@ -51,6 +53,10 @@ public Email getEmail() { return email; } + public Faculty getFaculty() { + return faculty; + } + public Venue getVenue() { return venue; } @@ -99,6 +105,7 @@ public boolean equals(Object other) { return name.equals(otherPerson.name) && phone.equals(otherPerson.phone) && email.equals(otherPerson.email) + && faculty.equals(otherPerson.faculty) && venue.equals(otherPerson.venue) && module.equals(otherPerson.module) && tags.equals(otherPerson.tags); @@ -107,7 +114,7 @@ public boolean equals(Object other) { @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, venue, module, tags); + return Objects.hash(name, phone, email, faculty, venue, module, tags); } @Override @@ -116,6 +123,7 @@ public String toString() { .add("name", name) .add("phone", phone) .add("email", email) + .add("faculty", faculty) .add("venue", venue) .add("module", module) .add("tags", tags) From b2d97343e70b0a2749fa6030d472e9bfae4ed516 Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:41:39 +0800 Subject: [PATCH 07/49] Update SampleDataUtil to include Faculty --- .../model/util/SampleDataUtil.java | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/main/java/staffconnect/model/util/SampleDataUtil.java b/src/main/java/staffconnect/model/util/SampleDataUtil.java index 1befd734f31..701df9b627e 100644 --- a/src/main/java/staffconnect/model/util/SampleDataUtil.java +++ b/src/main/java/staffconnect/model/util/SampleDataUtil.java @@ -8,6 +8,7 @@ import staffconnect.model.StaffBook; import staffconnect.model.person.Email; import staffconnect.model.person.Module; +import staffconnect.model.person.Faculty; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -19,25 +20,37 @@ */ public class SampleDataUtil { public static Person[] getSamplePersons() { - return new Person[] { - new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), - new Venue("Blk 30 Geylang Street 29, #06-40"), new Module("CS1101S"), - getTagSet("professor")), - new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Venue("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), new Module("CS1231S"), - getTagSet("tutor", "friends")), - new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Venue("Blk 11 Ang Mo Kio Street 74, #11-04"), new Module("CS2030S"), - getTagSet("professor")), - new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Venue("Blk 436 Serangoon Gardens Street 26, #16-43"), new Module("CS2040S"), - getTagSet("professor")), - new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Venue("Blk 47 Tampines Street 20, #17-35"), new Module("CS2100"), - getTagSet("tutor")), - new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Venue("Blk 45 Aljunied Street 85, #11-31"), new Module("CS2101"), - getTagSet("professor")) + return new Person[]{ + new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), + new Faculty("Computing"), + new Venue("Blk 30 Geylang Street 29, #06-40"), + new Module("CS1101S"), + getTagSet("professor")), + new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), + new Faculty("Computing"), + new Venue("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + new Module("CS1231S"), + getTagSet("tutor", "friends")), + new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), + new Faculty("Computing"), + new Venue("Blk 11 Ang Mo Kio Street 74, #11-04"), + new Module("CS2030S"), + getTagSet("professor")), + new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), + new Faculty("Computing"), + new Venue("Blk 436 Serangoon Gardens Street 26, #16-43"), + new Module("CS2040S"), + getTagSet("professor")), + new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), + new Faculty("Computing"), + new Venue("Blk 47 Tampines Street 20, #17-35"), + new Module("CS2100"), + getTagSet("tutor")), + new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), + new Faculty("Computing"), + new Venue("Blk 45 Aljunied Street 85, #11-31"), + new Module("CS2101"), + getTagSet("professor")) }; } From 3cd59cc87abbdab55478b8fc5329b23a1d40cb23 Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:52:25 +0800 Subject: [PATCH 08/49] Update JsonAdaptedPerson to include Faculty --- .../storage/JsonAdaptedPerson.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/staffconnect/storage/JsonAdaptedPerson.java b/src/main/java/staffconnect/storage/JsonAdaptedPerson.java index 600299c7a12..20bdb65b2a0 100644 --- a/src/main/java/staffconnect/storage/JsonAdaptedPerson.java +++ b/src/main/java/staffconnect/storage/JsonAdaptedPerson.java @@ -12,6 +12,7 @@ import staffconnect.commons.exceptions.IllegalValueException; import staffconnect.model.person.Email; import staffconnect.model.person.Module; +import staffconnect.model.person.Faculty; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -28,6 +29,7 @@ class JsonAdaptedPerson { private final String name; private final String phone; private final String email; + private final String faculty; private final String venue; private final String module; private final List tags = new ArrayList<>(); @@ -37,11 +39,13 @@ class JsonAdaptedPerson { */ @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, - @JsonProperty("email") String email, @JsonProperty("venue") String venue, - @JsonProperty("module") String module, @JsonProperty("tags") List tags) { + @JsonProperty("email") String email, @JsonProperty("faculty") String faculty, + @JsonProperty("venue") String venue, @JsonProperty("module") String module, + @JsonProperty("tags") List tags) { this.name = name; this.phone = phone; this.email = email; + this.faculty = faculty; this.venue = venue; this.module = module; if (tags != null) { @@ -56,6 +60,7 @@ public JsonAdaptedPerson(Person source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; + faculty = source.getFaculty().toString(); venue = source.getVenue().value; module = source.getModule().value; tags.addAll(source.getTags().stream() @@ -98,6 +103,15 @@ public Person toModelType() throws IllegalValueException { } final Email modelEmail = new Email(email); + if (faculty == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, + Faculty.class.getSimpleName())); + } + if (!Faculty.isValidFaculty(faculty)) { + throw new IllegalValueException(Faculty.MESSAGE_CONSTRAINTS); + } + final Faculty modelFaculty = new Faculty(faculty); + if (venue == null) { throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Venue.class.getSimpleName())); } @@ -115,7 +129,7 @@ public Person toModelType() throws IllegalValueException { final Module modelModule = new Module(module); final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelVenue, modelModule, modelTags); + return new Person(modelName, modelPhone, modelEmail, modelFaculty, modelVenue, modelModule, modelTags); } } From 15de86f379725a689076b05ef2a970853b599b32 Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 01:58:34 +0800 Subject: [PATCH 09/49] Make minor change to JsonAdaptedPerson.java --- src/main/java/staffconnect/storage/JsonAdaptedPerson.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/staffconnect/storage/JsonAdaptedPerson.java b/src/main/java/staffconnect/storage/JsonAdaptedPerson.java index 20bdb65b2a0..24653112577 100644 --- a/src/main/java/staffconnect/storage/JsonAdaptedPerson.java +++ b/src/main/java/staffconnect/storage/JsonAdaptedPerson.java @@ -60,7 +60,7 @@ public JsonAdaptedPerson(Person source) { name = source.getName().fullName; phone = source.getPhone().value; email = source.getEmail().value; - faculty = source.getFaculty().toString(); + faculty = source.getFaculty().value; venue = source.getVenue().value; module = source.getModule().value; tags.addAll(source.getTags().stream() From 52ece1a682d1838380fe68ad841f2dd6b22635cc Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 02:02:32 +0800 Subject: [PATCH 10/49] Update PersonCard to include Faculty --- src/main/java/staffconnect/ui/PersonCard.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/staffconnect/ui/PersonCard.java b/src/main/java/staffconnect/ui/PersonCard.java index f93f79e7476..c224d0b536c 100644 --- a/src/main/java/staffconnect/ui/PersonCard.java +++ b/src/main/java/staffconnect/ui/PersonCard.java @@ -7,6 +7,7 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import staffconnect.model.person.Faculty; import staffconnect.model.person.Person; /** @@ -37,6 +38,8 @@ public class PersonCard extends UiPart { @FXML private Label venue; @FXML + private Label faculty; + @FXML private Label module; @FXML private Label email; @@ -52,6 +55,7 @@ public PersonCard(Person person, int displayedIndex) { id.setText(displayedIndex + ". "); name.setText(person.getName().fullName); phone.setText(person.getPhone().value); + faculty.setText(person.getFaculty().value); venue.setText(person.getVenue().value); module.setText(person.getModule().value); email.setText(person.getEmail().value); From a43cd1a752ff7108b03eafff0d0738529cb3f938 Mon Sep 17 00:00:00 2001 From: JerryWang0000 Date: Fri, 15 Mar 2024 02:06:15 +0800 Subject: [PATCH 11/49] Update PersonListCard to include Faculty --- src/main/resources/view/PersonListCard.fxml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index 2101c6c5ed9..2eaa73653dc 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -29,6 +29,7 @@