From d83dc2be91763439f8333f10ed24d5256fc5407d Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 02:37:11 +0800 Subject: [PATCH 01/27] Add Module data field to Person --- .../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 2256a57b1d8..d8f935b02f7 100644 --- a/src/main/java/staffconnect/model/person/Person.java +++ b/src/main/java/staffconnect/model/person/Person.java @@ -23,17 +23,19 @@ public class Person { // Data fields private final Address address; + private final Module module; 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) { - requireAllNonNull(name, phone, email, address, tags); + public Person(Name name, Phone phone, Email email, Address address, Module module, Set tags) { + requireAllNonNull(name, phone, email, address, module, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; + this.module = module; this.tags.addAll(tags); } @@ -53,6 +55,10 @@ public Address getAddress() { return address; } + public Module getModule() { + return module; + } + /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -94,13 +100,14 @@ public boolean equals(Object other) { && phone.equals(otherPerson.phone) && email.equals(otherPerson.email) && address.equals(otherPerson.address) + && module.equals(otherPerson.module) && tags.equals(otherPerson.tags); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, tags); + return Objects.hash(name, phone, email, address, module, tags); } @Override @@ -110,6 +117,7 @@ public String toString() { .add("phone", phone) .add("email", email) .add("address", address) + .add("module", module) .add("tags", tags) .toString(); } From f263d5abcbac5b31f7f478853ac05942389fecf1 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 02:43:27 +0800 Subject: [PATCH 02/27] Add Module data field to PersonBuilder --- .../staffconnect/testutil/PersonBuilder.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/test/java/staffconnect/testutil/PersonBuilder.java b/src/test/java/staffconnect/testutil/PersonBuilder.java index 4c3a8546f71..904d71d1f45 100644 --- a/src/test/java/staffconnect/testutil/PersonBuilder.java +++ b/src/test/java/staffconnect/testutil/PersonBuilder.java @@ -5,6 +5,7 @@ import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -20,11 +21,13 @@ public class PersonBuilder { public static final String DEFAULT_PHONE = "85355255"; public static final String DEFAULT_EMAIL = "amy@gmail.com"; public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111"; + public static final String DEFAULT_MODULE = "CS2103T"; private Name name; private Phone phone; private Email email; private Address address; + private Module module; private Set tags; /** @@ -35,6 +38,7 @@ public PersonBuilder() { phone = new Phone(DEFAULT_PHONE); email = new Email(DEFAULT_EMAIL); address = new Address(DEFAULT_ADDRESS); + module = new Module(DEFAULT_MODULE); tags = new HashSet<>(); } @@ -46,6 +50,7 @@ public PersonBuilder(Person personToCopy) { phone = personToCopy.getPhone(); email = personToCopy.getEmail(); address = personToCopy.getAddress(); + module = personToCopy.getModule(); tags = new HashSet<>(personToCopy.getTags()); } @@ -58,10 +63,18 @@ public PersonBuilder withName(String name) { } /** - * Parses the {@code tags} into a {@code Set} and set it to the {@code Person} that we are building. + * Sets the {@code Phone} of the {@code Person} that we are building. */ - public PersonBuilder withTags(String ... tags) { - this.tags = SampleDataUtil.getTagSet(tags); + public PersonBuilder withPhone(String phone) { + this.phone = new Phone(phone); + return this; + } + + /** + * Sets the {@code Email} of the {@code Person} that we are building. + */ + public PersonBuilder withEmail(String email) { + this.email = new Email(email); return this; } @@ -74,23 +87,23 @@ public PersonBuilder withAddress(String address) { } /** - * Sets the {@code Phone} of the {@code Person} that we are building. + * Sets the {@code Module} of the {@code Person} that we are building. */ - public PersonBuilder withPhone(String phone) { - this.phone = new Phone(phone); + public PersonBuilder withModule(String module) { + this.module = new Module(module); return this; } /** - * Sets the {@code Email} of the {@code Person} that we are building. + * Parses the {@code tags} into a {@code Set} and set it to the {@code Person} that we are building. */ - public PersonBuilder withEmail(String email) { - this.email = new Email(email); + public PersonBuilder withTags(String ... tags) { + this.tags = SampleDataUtil.getTagSet(tags); return this; } public Person build() { - return new Person(name, phone, email, address, tags); + return new Person(name, phone, email, address, module, tags); } } From a304dc41a04c31931b23217634c384b7fe2b2a32 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 02:57:47 +0800 Subject: [PATCH 03/27] Add Prefix "m/" for specifying module --- 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 4847f4b9ba6..021fe17745b 100644 --- a/src/main/java/staffconnect/logic/parser/CliSyntax.java +++ b/src/main/java/staffconnect/logic/parser/CliSyntax.java @@ -10,6 +10,7 @@ public class CliSyntax { public static final Prefix PREFIX_PHONE = new Prefix("p/"); public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); + public static final Prefix PREFIX_MODULE = new Prefix("m/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); } From 0412b4f4a46f7959ec571b44567b795020218625 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 03:08:46 +0800 Subject: [PATCH 04/27] Update comments for consistency --- src/test/java/staffconnect/model/person/ModuleTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/staffconnect/model/person/ModuleTest.java b/src/test/java/staffconnect/model/person/ModuleTest.java index dc1cf7613c3..8019238d68a 100644 --- a/src/test/java/staffconnect/model/person/ModuleTest.java +++ b/src/test/java/staffconnect/model/person/ModuleTest.java @@ -21,10 +21,10 @@ public void constructor_invalidModule_throwsIllegalArgumentException() { @Test public void isValidModule() { - // null phone number + // null module assertThrows(NullPointerException.class, () -> Module.isValidModule(null)); - // invalid phone numbers + // invalid module assertFalse(Module.isValidModule("")); // empty string assertFalse(Module.isValidModule(" ")); // spaces only assertFalse(Module.isValidModule("ABCD")); // letters only @@ -38,7 +38,7 @@ public void isValidModule() { assertFalse(Module.isValidModule("cs2103t")); // suffix not capitalised assertFalse(Module.isValidModule("cs2103T")); // prefix not capitalised - // valid phone numbers + // valid module assertTrue(Module.isValidModule("CS2103")); // 2 prefix, 4 letters without 1 optional suffix assertTrue(Module.isValidModule("CS2103T")); // 2 prefix, 4 letters with 1 optional suffix assertTrue(Module.isValidModule("GEN2050")); // 3 prefix, 4 letters without 1 optional suffix From b41f00cb4bc0d966e8cfec5f96566b6c6e3080f3 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 03:12:13 +0800 Subject: [PATCH 05/27] Update TypicalPersons with Module data field --- .../logic/commands/CommandTestUtil.java | 6 ++++ .../staffconnect/testutil/TypicalPersons.java | 28 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java index ec44f77e0c0..8e401b01860 100644 --- a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java +++ b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java @@ -4,6 +4,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -34,6 +35,8 @@ public class CommandTestUtil { public static final String VALID_EMAIL_BOB = "bob@example.com"; public static final String VALID_ADDRESS_AMY = "Block 312, Amy Street 1"; public static final String VALID_ADDRESS_BOB = "Block 123, Bobby Street 3"; + public static final String VALID_MODULE_AMY = "CS2103"; + public static final String VALID_MODULE_BOB = "CS2103T"; public static final String VALID_TAG_HUSBAND = "husband"; public static final String VALID_TAG_FRIEND = "friend"; @@ -45,6 +48,8 @@ public class CommandTestUtil { public static final String EMAIL_DESC_BOB = " " + PREFIX_EMAIL + VALID_EMAIL_BOB; public static final String ADDRESS_DESC_AMY = " " + PREFIX_ADDRESS + VALID_ADDRESS_AMY; public static final String ADDRESS_DESC_BOB = " " + PREFIX_ADDRESS + VALID_ADDRESS_BOB; + public static final String MODULE_DESC_AMY = " " + PREFIX_MODULE + VALID_MODULE_AMY; + public static final String MODULE_DESC_BOB = " " + PREFIX_MODULE + VALID_MODULE_BOB; public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND; public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND; @@ -52,6 +57,7 @@ public class CommandTestUtil { public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses + public static final String INVALID_MODULE_DESC = " " + PREFIX_MODULE; // empty string not allowed for modules public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags public static final String PREAMBLE_WHITESPACE = "\t \r \n"; diff --git a/src/test/java/staffconnect/testutil/TypicalPersons.java b/src/test/java/staffconnect/testutil/TypicalPersons.java index f6497f7c60b..3764884b2f6 100644 --- a/src/test/java/staffconnect/testutil/TypicalPersons.java +++ b/src/test/java/staffconnect/testutil/TypicalPersons.java @@ -4,6 +4,8 @@ import static staffconnect.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; import static staffconnect.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static staffconnect.logic.commands.CommandTestUtil.VALID_MODULE_AMY; +import static staffconnect.logic.commands.CommandTestUtil.VALID_MODULE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static staffconnect.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_PHONE_AMY; @@ -25,35 +27,37 @@ public class TypicalPersons { public static final Person ALICE = new PersonBuilder().withName("Alice Pauline") .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") - .withPhone("94351253") + .withPhone("94351253").withModule("CS1101S") .withTags("friends").build(); public static final Person BENSON = new PersonBuilder().withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") - .withEmail("johnd@example.com").withPhone("98765432") + .withEmail("johnd@example.com").withPhone("98765432").withModule("CS1231S") .withTags("owesMoney", "friends").build(); public static final Person CARL = new PersonBuilder().withName("Carl Kurz").withPhone("95352563") - .withEmail("heinz@example.com").withAddress("wall street").build(); + .withEmail("heinz@example.com").withAddress("wall street").withModule("CS2030S").build(); public static final Person DANIEL = new PersonBuilder().withName("Daniel Meier").withPhone("87652533") - .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); + .withEmail("cornelia@example.com").withAddress("10th street").withModule("CS2040S") + .withTags("friends").build(); public static final Person ELLE = new PersonBuilder().withName("Elle Meyer").withPhone("9482224") - .withEmail("werner@example.com").withAddress("michegan ave").build(); + .withEmail("werner@example.com").withAddress("michegan ave").withModule("CS2100").build(); public static final Person FIONA = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427") - .withEmail("lydia@example.com").withAddress("little tokyo").build(); + .withEmail("lydia@example.com").withAddress("little tokyo").withModule("CS2101").build(); public static final Person GEORGE = new PersonBuilder().withName("George Best").withPhone("9482442") - .withEmail("anna@example.com").withAddress("4th street").build(); + .withEmail("anna@example.com").withAddress("4th street").withModule("CS2102").build(); // Manually added public static final Person HOON = new PersonBuilder().withName("Hoon Meier").withPhone("8482424") - .withEmail("stefan@example.com").withAddress("little india").build(); + .withEmail("stefan@example.com").withAddress("little india").withModule("CS2103").build(); public static final Person IDA = new PersonBuilder().withName("Ida Mueller").withPhone("8482131") - .withEmail("hans@example.com").withAddress("chicago ave").build(); + .withEmail("hans@example.com").withAddress("chicago ave").withModule("CS2103T").build(); // Manually added - Person's details found in {@code CommandTestUtil} public static final Person AMY = new PersonBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); + .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withModule(VALID_MODULE_AMY) + .withTags(VALID_TAG_FRIEND).build(); public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) - .build(); + .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withModule(VALID_MODULE_BOB) + .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER From 37978b390a12d471f3771928694fb70942bef515 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 03:37:25 +0800 Subject: [PATCH 06/27] Update PersonTest with Module data field --- .../java/staffconnect/model/person/PersonTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/java/staffconnect/model/person/PersonTest.java b/src/test/java/staffconnect/model/person/PersonTest.java index a15144c6c2d..8a8b1575a28 100644 --- a/src/test/java/staffconnect/model/person/PersonTest.java +++ b/src/test/java/staffconnect/model/person/PersonTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static staffconnect.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static staffconnect.logic.commands.CommandTestUtil.VALID_MODULE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; @@ -34,7 +35,7 @@ public void isSamePerson() { // same name, all other attributes different -> returns true Person editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB) - .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).build(); + .withAddress(VALID_ADDRESS_BOB).withModule(VALID_MODULE_BOB).withTags(VALID_TAG_HUSBAND).build(); assertTrue(ALICE.isSamePerson(editedAlice)); // different name, all other attributes same -> returns false @@ -85,6 +86,10 @@ public void equals() { editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build(); assertFalse(ALICE.equals(editedAlice)); + // different module -> returns false + editedAlice = new PersonBuilder(ALICE).withModule(VALID_MODULE_BOB).build(); + assertFalse(ALICE.equals(editedAlice)); + // different tags -> returns false editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); assertFalse(ALICE.equals(editedAlice)); @@ -93,7 +98,8 @@ public void equals() { @Test public void toStringMethod() { String expected = Person.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone() - + ", email=" + ALICE.getEmail() + ", address=" + ALICE.getAddress() + ", tags=" + ALICE.getTags() + "}"; + + ", email=" + ALICE.getEmail() + ", address=" + ALICE.getAddress() + ", module=" + ALICE.getModule() + + ", tags=" + ALICE.getTags() + "}"; assertEquals(expected, ALICE.toString()); } } From c90eff7b7e67341377f3c890dfe0d60080620516 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 03:48:07 +0800 Subject: [PATCH 07/27] Add Module data field to JsonAdaptedPerson --- .../staffconnect/storage/JsonAdaptedPerson.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/staffconnect/storage/JsonAdaptedPerson.java b/src/main/java/staffconnect/storage/JsonAdaptedPerson.java index 0dde7c8df12..4815f2effb4 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.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -28,6 +29,7 @@ class JsonAdaptedPerson { private final String phone; private final String email; private final String address; + private final String module; private final List tags = new ArrayList<>(); /** @@ -36,11 +38,12 @@ class JsonAdaptedPerson { @JsonCreator public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @JsonProperty("email") String email, @JsonProperty("address") String address, - @JsonProperty("tags") List tags) { + @JsonProperty("module") String module, @JsonProperty("tags") List tags) { this.name = name; this.phone = phone; this.email = email; this.address = address; + this.module = module; if (tags != null) { this.tags.addAll(tags); } @@ -54,6 +57,7 @@ public JsonAdaptedPerson(Person source) { phone = source.getPhone().value; email = source.getEmail().value; address = source.getAddress().value; + module = source.getModule().value; tags.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); @@ -102,8 +106,16 @@ public Person toModelType() throws IllegalValueException { } final Address modelAddress = new Address(address); + if (module == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Module.class.getSimpleName())); + } + if (!Module.isValidModule(module)) { + throw new IllegalValueException(Module.MESSAGE_CONSTRAINTS); + } + final Module modelModule = new Module(module); + final Set modelTags = new HashSet<>(personTags); - return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags); + return new Person(modelName, modelPhone, modelEmail, modelAddress, modelModule, modelTags); } } From 5b2bb5c7aebf3092aae03edfbb0f9eb57337f3b6 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 03:48:23 +0800 Subject: [PATCH 08/27] Update JsonAdaptedPersonTest with Module data field --- .../storage/JsonAdaptedPersonTest.java | 52 +++++++++++++------ 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java b/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java index 0b386d4efb5..970b7a81467 100644 --- a/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java @@ -20,14 +20,16 @@ public class JsonAdaptedPersonTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; - private static final String INVALID_ADDRESS = " "; private static final String INVALID_EMAIL = "example.com"; + private static final String INVALID_ADDRESS = " "; + private static final String INVALID_MODULE = " "; private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); private static final String VALID_EMAIL = BENSON.getEmail().toString(); private static final String VALID_ADDRESS = BENSON.getAddress().toString(); + private static final String VALID_MODULE = BENSON.getModule().toString(); private static final List VALID_TAGS = BENSON.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList()); @@ -40,60 +42,80 @@ public void toModelType_validPersonDetails_returnsPerson() throws Exception { @Test public void toModelType_invalidName_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = Name.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullName_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidPhone_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullPhone_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, + VALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidEmail_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, + VALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = Email.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullEmail_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, + VALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_invalidAddress_throwsIllegalValueException() { - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + INVALID_ADDRESS, VALID_MODULE, VALID_TAGS); String expectedMessage = Address.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @Test public void toModelType_nullAddress_throwsIllegalValueException() { - JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_TAGS); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + null, VALID_MODULE, VALID_TAGS); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); + assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + } + + @Test + public void toModelType_invalidModule_throwsIllegalValueException() { + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, INVALID_MODULE, VALID_TAGS); + String expectedMessage = Address.MESSAGE_CONSTRAINTS; + assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + } + + @Test + public void toModelType_nullModule_throwsIllegalValueException() { + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, null, VALID_TAGS); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -102,8 +124,8 @@ public void toModelType_nullAddress_throwsIllegalValueException() { public void toModelType_invalidTags_throwsIllegalValueException() { List invalidTags = new ArrayList<>(VALID_TAGS); invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, invalidTags); + JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, + VALID_ADDRESS, VALID_MODULE, invalidTags); assertThrows(IllegalValueException.class, person::toModelType); } From 87a53143b31f6bf414568c4911c822e814dab141 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 04:17:29 +0800 Subject: [PATCH 09/27] Update Messages with Module data field --- 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 07598d04d10..c333c1c3fee 100644 --- a/src/main/java/staffconnect/logic/Messages.java +++ b/src/main/java/staffconnect/logic/Messages.java @@ -43,6 +43,8 @@ public static String format(Person person) { .append(person.getEmail()) .append("; Address: ") .append(person.getAddress()) + .append("; Module: ") + .append(person.getModule()) .append("; Tags: "); person.getTags().forEach(builder::append); return builder.toString(); From 9dc61f61ffca219accf00fd4e02d11b58d128450 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:03:46 +0800 Subject: [PATCH 10/27] Update ParserUtil with Module data field --- .../staffconnect/logic/parser/ParserUtil.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/staffconnect/logic/parser/ParserUtil.java b/src/main/java/staffconnect/logic/parser/ParserUtil.java index caa0239f860..82f048f7d93 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.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Phone; import staffconnect.model.tag.Tag; @@ -65,6 +66,21 @@ public static Phone parsePhone(String phone) throws ParseException { return new Phone(trimmedPhone); } + /** + * Parses a {@code String email} into an {@code Email}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws ParseException if the given {@code email} is invalid. + */ + public static Email parseEmail(String email) throws ParseException { + requireNonNull(email); + String trimmedEmail = email.trim(); + if (!Email.isValidEmail(trimmedEmail)) { + throw new ParseException(Email.MESSAGE_CONSTRAINTS); + } + return new Email(trimmedEmail); + } + /** * Parses a {@code String address} into an {@code Address}. * Leading and trailing whitespaces will be trimmed. @@ -81,18 +97,18 @@ public static Address parseAddress(String address) throws ParseException { } /** - * Parses a {@code String email} into an {@code Email}. + * Parses a {@code String module} into an {@code Module}. * Leading and trailing whitespaces will be trimmed. * - * @throws ParseException if the given {@code email} is invalid. + * @throws ParseException if the given {@code module} is invalid. */ - public static Email parseEmail(String email) throws ParseException { - requireNonNull(email); - String trimmedEmail = email.trim(); - if (!Email.isValidEmail(trimmedEmail)) { - throw new ParseException(Email.MESSAGE_CONSTRAINTS); + public static Module parseModule(String module) throws ParseException { + requireNonNull(module); + String trimmedModule = module.trim(); + if (!Address.isValidAddress(trimmedModule)) { + throw new ParseException(Address.MESSAGE_CONSTRAINTS); } - return new Email(trimmedEmail); + return new Module(trimmedModule); } /** From 505718986b57647d15a776e084ef2c515c01bcf5 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:04:33 +0800 Subject: [PATCH 11/27] Update AddCommandParser with Module data field --- .../logic/parser/AddCommandParser.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/staffconnect/logic/parser/AddCommandParser.java b/src/main/java/staffconnect/logic/parser/AddCommandParser.java index 4464682764b..b0baa4eff59 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_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -14,6 +15,7 @@ import staffconnect.logic.parser.exceptions.ParseException; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -30,22 +32,24 @@ public class AddCommandParser implements Parser { * @throws ParseException if the user input does not conform the expected format */ public AddCommand parse(String args) throws ParseException { - ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, + PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_MODULE, PREFIX_TAG); - if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) + if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, 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, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, 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()); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).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, address, tagList); + Person person = new Person(name, phone, email, address, module, tagList); return new AddCommand(person); } From 1cd75fb2bfed2935bbcd33d755c007c5e791661d Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:13:09 +0800 Subject: [PATCH 12/27] Update AddCommand with Module data field --- src/main/java/staffconnect/logic/commands/AddCommand.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/staffconnect/logic/commands/AddCommand.java b/src/main/java/staffconnect/logic/commands/AddCommand.java index 173b83d6d7d..0918d5aeb61 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_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; 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,12 +27,14 @@ public class AddCommand extends Command { + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_MODULE + "MODULE " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + + PREFIX_MODULE + "CS2103 " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; From e1b7b40c4ceb05ead42c4a7ee16c8f2d0a58ff63 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:14:20 +0800 Subject: [PATCH 13/27] Update EditCommand with Module data field --- .../logic/commands/EditCommand.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/staffconnect/logic/commands/EditCommand.java b/src/main/java/staffconnect/logic/commands/EditCommand.java index de8ece3efda..520c0ec1e44 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_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -23,6 +24,7 @@ import staffconnect.model.Model; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -43,6 +45,7 @@ public class EditCommand extends Command { + "[" + PREFIX_PHONE + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " + "[" + PREFIX_ADDRESS + "ADDRESS] " + + "[" + PREFIX_MODULE + "MODULE] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " @@ -99,9 +102,10 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); + Module updatedModule = editPersonDescriptor.getModule().orElse(personToEdit.getModule()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedModule, updatedTags); } @Override @@ -137,6 +141,7 @@ public static class EditPersonDescriptor { private Phone phone; private Email email; private Address address; + private Module module; private Set tags; public EditPersonDescriptor() {} @@ -150,6 +155,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setPhone(toCopy.phone); setEmail(toCopy.email); setAddress(toCopy.address); + setModule(toCopy.module); setTags(toCopy.tags); } @@ -157,7 +163,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, address, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, address, module, tags); } public void setName(Name name) { @@ -192,6 +198,14 @@ public Optional
getAddress() { return Optional.ofNullable(address); } + public void setModule(Module module) { + this.module = module; + } + + public Optional getModule() { + return Optional.ofNullable(module); + } + /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. @@ -225,6 +239,7 @@ public boolean equals(Object other) { && Objects.equals(phone, otherEditPersonDescriptor.phone) && Objects.equals(email, otherEditPersonDescriptor.email) && Objects.equals(address, otherEditPersonDescriptor.address) + && Objects.equals(module, otherEditPersonDescriptor.module) && Objects.equals(tags, otherEditPersonDescriptor.tags); } @@ -235,6 +250,7 @@ public String toString() { .add("phone", phone) .add("email", email) .add("address", address) + .add("module", module) .add("tags", tags) .toString(); } From cf968c945e60845b36a353e1cdcfa7eafcf6a0ba Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:15:40 +0800 Subject: [PATCH 14/27] Update PersonUtil with Module data field --- src/test/java/staffconnect/testutil/PersonUtil.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/staffconnect/testutil/PersonUtil.java b/src/test/java/staffconnect/testutil/PersonUtil.java index 784b7d4c6d8..3cc97a53aff 100644 --- a/src/test/java/staffconnect/testutil/PersonUtil.java +++ b/src/test/java/staffconnect/testutil/PersonUtil.java @@ -2,6 +2,7 @@ import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -34,6 +35,7 @@ public static String getPersonDetails(Person person) { sb.append(PREFIX_PHONE + person.getPhone().value + " "); sb.append(PREFIX_EMAIL + person.getEmail().value + " "); sb.append(PREFIX_ADDRESS + person.getAddress().value + " "); + sb.append(PREFIX_MODULE + person.getModule().value + " "); person.getTags().stream().forEach( s -> sb.append(PREFIX_TAG + s.tagName + " ") ); @@ -49,6 +51,7 @@ public static String getEditPersonDescriptorDetails(EditPersonDescriptor descrip descriptor.getPhone().ifPresent(phone -> sb.append(PREFIX_PHONE).append(phone.value).append(" ")); descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.value).append(" ")); descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" ")); + descriptor.getModule().ifPresent(module -> sb.append(PREFIX_MODULE).append(module.value).append(" ")); if (descriptor.getTags().isPresent()) { Set tags = descriptor.getTags().get(); if (tags.isEmpty()) { From 97b25d97a4c9ee4c0cb4cedc3c9d4a04fa440172 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:19:03 +0800 Subject: [PATCH 15/27] Update SampleDataUtil with Module data field --- .../model/util/SampleDataUtil.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/staffconnect/model/util/SampleDataUtil.java b/src/main/java/staffconnect/model/util/SampleDataUtil.java index df8f3de5d9a..599c8a1a22a 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.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -20,23 +21,23 @@ 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 Address("Blk 30 Geylang Street 29, #06-40"), - getTagSet("friends")), + new Address("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 Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - getTagSet("colleagues", "friends")), + new Address("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 Address("Blk 11 Ang Mo Kio Street 74, #11-04"), - getTagSet("neighbours")), + new Address("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 Address("Blk 436 Serangoon Gardens Street 26, #16-43"), - getTagSet("family")), + new Address("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 Address("Blk 47 Tampines Street 20, #17-35"), - getTagSet("classmates")), + new Address("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 Address("Blk 45 Aljunied Street 85, #11-31"), - getTagSet("colleagues")) + new Address("Blk 45 Aljunied Street 85, #11-31"), new Module("CS2101"), + getTagSet("professor")) }; } From e3fd17a45a37b835e30b7b6806e9077a4591bf27 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:23:40 +0800 Subject: [PATCH 16/27] Update EditPersonDescriptorBuilder with Module data field --- .../testutil/EditPersonDescriptorBuilder.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/staffconnect/testutil/EditPersonDescriptorBuilder.java b/src/test/java/staffconnect/testutil/EditPersonDescriptorBuilder.java index 2aa6c86ea64..f92530e9e42 100644 --- a/src/test/java/staffconnect/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/staffconnect/testutil/EditPersonDescriptorBuilder.java @@ -7,6 +7,7 @@ import staffconnect.logic.commands.EditCommand.EditPersonDescriptor; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -36,6 +37,7 @@ public EditPersonDescriptorBuilder(Person person) { descriptor.setPhone(person.getPhone()); descriptor.setEmail(person.getEmail()); descriptor.setAddress(person.getAddress()); + descriptor.setModule(person.getModule()); descriptor.setTags(person.getTags()); } @@ -71,6 +73,14 @@ public EditPersonDescriptorBuilder withAddress(String address) { return this; } + /** + * Sets the {@code Module} of the {@code EditPersonDescriptor} that we are building. + */ + public EditPersonDescriptorBuilder withModule(String module) { + descriptor.setModule(new Module(module)); + return this; + } + /** * Parses the {@code tags} into a {@code Set} and set it to the {@code EditPersonDescriptor} * that we are building. From 52837d7d34a3dca74fc2562031c817d8819e5ccb Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 05:24:44 +0800 Subject: [PATCH 17/27] Update EditPersonDescriptorTest with Module data field --- .../logic/commands/EditPersonDescriptorTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/staffconnect/logic/commands/EditPersonDescriptorTest.java b/src/test/java/staffconnect/logic/commands/EditPersonDescriptorTest.java index acd176bae8d..d453ee4313d 100644 --- a/src/test/java/staffconnect/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/staffconnect/logic/commands/EditPersonDescriptorTest.java @@ -7,6 +7,7 @@ import static staffconnect.logic.commands.CommandTestUtil.DESC_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static staffconnect.logic.commands.CommandTestUtil.VALID_MODULE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; @@ -52,6 +53,10 @@ public void equals() { editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withAddress(VALID_ADDRESS_BOB).build(); assertFalse(DESC_AMY.equals(editedAmy)); + // different module -> returns false + editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withModule(VALID_MODULE_BOB).build(); + assertFalse(DESC_AMY.equals(editedAmy)); + // different tags -> returns false editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build(); assertFalse(DESC_AMY.equals(editedAmy)); @@ -64,7 +69,8 @@ public void toStringMethod() { + editPersonDescriptor.getName().orElse(null) + ", phone=" + editPersonDescriptor.getPhone().orElse(null) + ", email=" + editPersonDescriptor.getEmail().orElse(null) + ", address=" - + editPersonDescriptor.getAddress().orElse(null) + ", tags=" + + editPersonDescriptor.getAddress().orElse(null) + ", module=" + + editPersonDescriptor.getModule().orElse(null) + ", tags=" + editPersonDescriptor.getTags().orElse(null) + "}"; assertEquals(expected, editPersonDescriptor.toString()); } From d07cf0ba96665890262e77791ed9329b97cb1517 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 20:14:20 +0800 Subject: [PATCH 18/27] Update ParserUtilTest with Module data field --- .../logic/parser/ParserUtilTest.java | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/src/test/java/staffconnect/logic/parser/ParserUtilTest.java b/src/test/java/staffconnect/logic/parser/ParserUtilTest.java index 58c3ef0219a..379feb320b1 100644 --- a/src/test/java/staffconnect/logic/parser/ParserUtilTest.java +++ b/src/test/java/staffconnect/logic/parser/ParserUtilTest.java @@ -16,6 +16,7 @@ import staffconnect.logic.parser.exceptions.ParseException; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Phone; import staffconnect.model.tag.Tag; @@ -24,13 +25,15 @@ public class ParserUtilTest { private static final String INVALID_NAME = "R@chel"; private static final String INVALID_PHONE = "+651234"; private static final String INVALID_ADDRESS = " "; + private static final String INVALID_MODULE = " "; private static final String INVALID_EMAIL = "example.com"; private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = "Rachel Walker"; private static final String VALID_PHONE = "123456"; - private static final String VALID_ADDRESS = "123 Main Street #0505"; private static final String VALID_EMAIL = "rachel@example.com"; + private static final String VALID_ADDRESS = "123 Main Street #0505"; + private static final String VALID_MODULE = "CS2103"; private static final String VALID_TAG_1 = "friend"; private static final String VALID_TAG_2 = "neighbour"; @@ -102,6 +105,29 @@ public void parsePhone_validValueWithWhitespace_returnsTrimmedPhone() throws Exc assertEquals(expectedPhone, ParserUtil.parsePhone(phoneWithWhitespace)); } + @Test + public void parseEmail_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail((String) null)); + } + + @Test + public void parseEmail_invalidValue_throwsParseException() { + assertThrows(ParseException.class, () -> ParserUtil.parseEmail(INVALID_EMAIL)); + } + + @Test + public void parseEmail_validValueWithoutWhitespace_returnsEmail() throws Exception { + Email expectedEmail = new Email(VALID_EMAIL); + assertEquals(expectedEmail, ParserUtil.parseEmail(VALID_EMAIL)); + } + + @Test + public void parseEmail_validValueWithWhitespace_returnsTrimmedEmail() throws Exception { + String emailWithWhitespace = WHITESPACE + VALID_EMAIL + WHITESPACE; + Email expectedEmail = new Email(VALID_EMAIL); + assertEquals(expectedEmail, ParserUtil.parseEmail(emailWithWhitespace)); + } + @Test public void parseAddress_null_throwsNullPointerException() { assertThrows(NullPointerException.class, () -> ParserUtil.parseAddress((String) null)); @@ -126,26 +152,26 @@ public void parseAddress_validValueWithWhitespace_returnsTrimmedAddress() throws } @Test - public void parseEmail_null_throwsNullPointerException() { - assertThrows(NullPointerException.class, () -> ParserUtil.parseEmail((String) null)); + public void parseModule_null_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> ParserUtil.parseModule((String) null)); } @Test - public void parseEmail_invalidValue_throwsParseException() { - assertThrows(ParseException.class, () -> ParserUtil.parseEmail(INVALID_EMAIL)); + public void parseModule_invalidValue_throwsParseException() { + assertThrows(ParseException.class, () -> ParserUtil.parseModule(INVALID_MODULE)); } @Test - public void parseEmail_validValueWithoutWhitespace_returnsEmail() throws Exception { - Email expectedEmail = new Email(VALID_EMAIL); - assertEquals(expectedEmail, ParserUtil.parseEmail(VALID_EMAIL)); + public void parseModule_validValueWithoutWhitespace_returnsModule() throws Exception { + Module expectedModule = new Module(VALID_MODULE); + assertEquals(expectedModule, ParserUtil.parseModule(VALID_MODULE)); } @Test - public void parseEmail_validValueWithWhitespace_returnsTrimmedEmail() throws Exception { - String emailWithWhitespace = WHITESPACE + VALID_EMAIL + WHITESPACE; - Email expectedEmail = new Email(VALID_EMAIL); - assertEquals(expectedEmail, ParserUtil.parseEmail(emailWithWhitespace)); + public void parseModule_validValueWithWhitespace_returnsTrimmedModule() throws Exception { + String moduleWithWhitespace = WHITESPACE + VALID_MODULE + WHITESPACE; + Module expectedModule = new Module(VALID_MODULE); + assertEquals(expectedModule, ParserUtil.parseModule(moduleWithWhitespace)); } @Test From a42113b151558d5f7cbeac462d2bd2795719d51d Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 20:21:15 +0800 Subject: [PATCH 19/27] Update JsonSerializableStaffBookTest data with Module data field --- .../duplicatePersonStaffBook.json | 4 +++- .../invalidPersonStaffBook.json | 3 ++- .../typicalPersonsStaffBook.json | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/data/JsonSerializableStaffBookTest/duplicatePersonStaffBook.json b/src/test/data/JsonSerializableStaffBookTest/duplicatePersonStaffBook.json index a7427fe7aa2..d6c1bb2737c 100644 --- a/src/test/data/JsonSerializableStaffBookTest/duplicatePersonStaffBook.json +++ b/src/test/data/JsonSerializableStaffBookTest/duplicatePersonStaffBook.json @@ -4,11 +4,13 @@ "phone": "94351253", "email": "alice@example.com", "address": "123, Jurong West Ave 6, #08-111", + "module": "CS1101S", "tags": [ "friends" ] }, { "name": "Alice Pauline", "phone": "94351253", "email": "pauline@example.com", - "address": "4th street" + "address": "4th street", + "module": "CS1231S" } ] } diff --git a/src/test/data/JsonSerializableStaffBookTest/invalidPersonStaffBook.json b/src/test/data/JsonSerializableStaffBookTest/invalidPersonStaffBook.json index ad3f135ae42..cb42b8671c9 100644 --- a/src/test/data/JsonSerializableStaffBookTest/invalidPersonStaffBook.json +++ b/src/test/data/JsonSerializableStaffBookTest/invalidPersonStaffBook.json @@ -3,6 +3,7 @@ "name": "Hans Muster", "phone": "9482424", "email": "invalid@email!3e", - "address": "4th street" + "address": "4th street", + "module": "CS2030S" } ] } diff --git a/src/test/data/JsonSerializableStaffBookTest/typicalPersonsStaffBook.json b/src/test/data/JsonSerializableStaffBookTest/typicalPersonsStaffBook.json index 72262099d35..772e26a4f24 100644 --- a/src/test/data/JsonSerializableStaffBookTest/typicalPersonsStaffBook.json +++ b/src/test/data/JsonSerializableStaffBookTest/typicalPersonsStaffBook.json @@ -5,42 +5,49 @@ "phone" : "94351253", "email" : "alice@example.com", "address" : "123, Jurong West Ave 6, #08-111", + "module": "CS1101S", "tags" : [ "friends" ] }, { "name" : "Benson Meier", "phone" : "98765432", "email" : "johnd@example.com", "address" : "311, Clementi Ave 2, #02-25", + "module": "CS1231S", "tags" : [ "owesMoney", "friends" ] }, { "name" : "Carl Kurz", "phone" : "95352563", "email" : "heinz@example.com", "address" : "wall street", + "module": "CS2030S", "tags" : [ ] }, { "name" : "Daniel Meier", "phone" : "87652533", "email" : "cornelia@example.com", "address" : "10th street", + "module": "CS2040S", "tags" : [ "friends" ] }, { "name" : "Elle Meyer", "phone" : "9482224", "email" : "werner@example.com", "address" : "michegan ave", + "module": "CS2100", "tags" : [ ] }, { "name" : "Fiona Kunz", "phone" : "9482427", "email" : "lydia@example.com", "address" : "little tokyo", + "module": "CS2101", "tags" : [ ] }, { "name" : "George Best", "phone" : "9482442", "email" : "anna@example.com", "address" : "4th street", + "module": "CS2102", "tags" : [ ] } ] } From ffb5e318f1a273d890ce7a5af26f2cfa96a7fd50 Mon Sep 17 00:00:00 2001 From: tsulim Date: Wed, 13 Mar 2024 20:23:30 +0800 Subject: [PATCH 20/27] Fix error in JsonAdaptedPersonTest --- .../java/staffconnect/storage/JsonAdaptedPersonTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java b/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java index 970b7a81467..11c0d3ef7c7 100644 --- a/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/staffconnect/storage/JsonAdaptedPersonTest.java @@ -14,6 +14,7 @@ import staffconnect.commons.exceptions.IllegalValueException; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Phone; @@ -108,7 +109,7 @@ public void toModelType_nullAddress_throwsIllegalValueException() { public void toModelType_invalidModule_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, INVALID_MODULE, VALID_TAGS); - String expectedMessage = Address.MESSAGE_CONSTRAINTS; + String expectedMessage = Module.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -116,7 +117,7 @@ public void toModelType_invalidModule_throwsIllegalValueException() { public void toModelType_nullModule_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, null, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); + String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Module.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } From 919faf350e7b1c0d8396466399bacd33d17f3b6a Mon Sep 17 00:00:00 2001 From: tsulim Date: Thu, 14 Mar 2024 00:18:35 +0800 Subject: [PATCH 21/27] Update JsonStaffBookStorageTest data with Module data field --- .../invalidAndValidPersonStaffBook.json | 6 ++++-- .../JsonStaffBookStorageTest/invalidPersonStaffBook.json | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonStaffBook.json b/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonStaffBook.json index 6a4d2b7181c..a33c6e674d5 100644 --- a/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonStaffBook.json +++ b/src/test/data/JsonStaffBookStorageTest/invalidAndValidPersonStaffBook.json @@ -3,11 +3,13 @@ "name": "Valid Person", "phone": "9482424", "email": "hans@example.com", - "address": "4th street" + "address": "4th street", + "module": "CS1101S" }, { "name": "Person With Invalid Phone Field", "phone": "948asdf2424", "email": "hans@example.com", - "address": "4th street" + "address": "4th street", + "module": "CS1101S" } ] } diff --git a/src/test/data/JsonStaffBookStorageTest/invalidPersonStaffBook.json b/src/test/data/JsonStaffBookStorageTest/invalidPersonStaffBook.json index ccd21f7d1a9..5ba8b36f46d 100644 --- a/src/test/data/JsonStaffBookStorageTest/invalidPersonStaffBook.json +++ b/src/test/data/JsonStaffBookStorageTest/invalidPersonStaffBook.json @@ -3,6 +3,7 @@ "name": "Person with invalid name field: Ha!ns Mu@ster", "phone": "9482424", "email": "hans@example.com", - "address": "4th street" + "address": "4th street", + "module": "CS1101S" } ] } From c7549b245e707633b1dc00af3f40e99cc689dc74 Mon Sep 17 00:00:00 2001 From: tsulim Date: Thu, 14 Mar 2024 00:22:42 +0800 Subject: [PATCH 22/27] Update AddCommandParserTest with Module data field --- .../staffconnect/logic/parser/ParserUtil.java | 2 +- .../logic/parser/AddCommandParserTest.java | 89 ++++++++++++++----- 2 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/main/java/staffconnect/logic/parser/ParserUtil.java b/src/main/java/staffconnect/logic/parser/ParserUtil.java index 82f048f7d93..02f4d6e472b 100644 --- a/src/main/java/staffconnect/logic/parser/ParserUtil.java +++ b/src/main/java/staffconnect/logic/parser/ParserUtil.java @@ -106,7 +106,7 @@ public static Module parseModule(String module) throws ParseException { requireNonNull(module); String trimmedModule = module.trim(); if (!Address.isValidAddress(trimmedModule)) { - throw new ParseException(Address.MESSAGE_CONSTRAINTS); + throw new ParseException(Module.MESSAGE_CONSTRAINTS); } return new Module(trimmedModule); } diff --git a/src/test/java/staffconnect/logic/parser/AddCommandParserTest.java b/src/test/java/staffconnect/logic/parser/AddCommandParserTest.java index 3fbefa58dee..b241a45c5ac 100644 --- a/src/test/java/staffconnect/logic/parser/AddCommandParserTest.java +++ b/src/test/java/staffconnect/logic/parser/AddCommandParserTest.java @@ -7,9 +7,12 @@ import static staffconnect.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; import static staffconnect.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; +import static staffconnect.logic.commands.CommandTestUtil.INVALID_MODULE_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_TAG_DESC; +import static staffconnect.logic.commands.CommandTestUtil.MODULE_DESC_AMY; +import static staffconnect.logic.commands.CommandTestUtil.MODULE_DESC_BOB; import static staffconnect.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static staffconnect.logic.commands.CommandTestUtil.NAME_DESC_BOB; import static staffconnect.logic.commands.CommandTestUtil.PHONE_DESC_AMY; @@ -20,12 +23,14 @@ import static staffconnect.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; import static staffconnect.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; +import static staffconnect.logic.commands.CommandTestUtil.VALID_MODULE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_NAME_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static staffconnect.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static staffconnect.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CommandParserTestUtil.assertParseFailure; @@ -39,6 +44,7 @@ import staffconnect.logic.commands.AddCommand; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Person; import staffconnect.model.person.Phone; @@ -54,21 +60,22 @@ public void parse_allFieldsPresent_success() { // whitespace only preamble assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_FRIEND, new AddCommand(expectedPerson)); // multiple tags - all accepted Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND) .build(); assertParseSuccess(parser, - NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + + MODULE_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, new AddCommand(expectedPersonMultipleTags)); } @Test public void parse_repeatedNonTagValue_failure() { String validExpectedPersonString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_FRIEND; + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_FRIEND; // multiple names assertParseFailure(parser, NAME_DESC_AMY + validExpectedPersonString, @@ -86,11 +93,16 @@ public void parse_repeatedNonTagValue_failure() { assertParseFailure(parser, ADDRESS_DESC_AMY + validExpectedPersonString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_ADDRESS)); + // multiple modules + assertParseFailure(parser, MODULE_DESC_AMY + validExpectedPersonString, + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_MODULE)); + // multiple fields repeated assertParseFailure(parser, - validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + ADDRESS_DESC_AMY - + validExpectedPersonString, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_ADDRESS, PREFIX_EMAIL, PREFIX_PHONE)); + validExpectedPersonString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + + ADDRESS_DESC_AMY + MODULE_DESC_AMY + validExpectedPersonString, + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_ADDRESS, + PREFIX_EMAIL, PREFIX_PHONE, PREFIX_MODULE)); // invalid value followed by valid value @@ -110,6 +122,10 @@ public void parse_repeatedNonTagValue_failure() { assertParseFailure(parser, INVALID_ADDRESS_DESC + validExpectedPersonString, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_ADDRESS)); + // invalid module + assertParseFailure(parser, INVALID_MODULE_DESC + validExpectedPersonString, + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_MODULE)); + // valid value followed by invalid value // invalid name @@ -127,13 +143,17 @@ public void parse_repeatedNonTagValue_failure() { // invalid address assertParseFailure(parser, validExpectedPersonString + INVALID_ADDRESS_DESC, Messages.getErrorMessageForDuplicatePrefixes(PREFIX_ADDRESS)); + + // invalid module + assertParseFailure(parser, validExpectedPersonString + INVALID_MODULE_DESC, + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_MODULE)); } @Test public void parse_optionalFieldsMissing_success() { // zero tags Person expectedPerson = new PersonBuilder(AMY).withTags().build(); - assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, + assertParseSuccess(parser, NAME_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + MODULE_DESC_AMY, new AddCommand(expectedPerson)); } @@ -142,55 +162,76 @@ public void parse_compulsoryFieldMissing_failure() { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); // missing name prefix - assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + MODULE_DESC_BOB, expectedMessage); // missing phone prefix - assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + MODULE_DESC_BOB, expectedMessage); // missing email prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + + ADDRESS_DESC_BOB + MODULE_DESC_BOB, expectedMessage); // missing address prefix - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB, + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + VALID_ADDRESS_BOB + MODULE_DESC_BOB, + expectedMessage); + + // missing module prefix + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + VALID_MODULE_BOB, expectedMessage); // all prefixes missing - assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB, + assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + + VALID_ADDRESS_BOB + VALID_MODULE_BOB, expectedMessage); } @Test public void parse_invalidValue_failure() { // invalid name - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + Name.MESSAGE_CONSTRAINTS); // invalid phone - assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + Phone.MESSAGE_CONSTRAINTS); // invalid email - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + Email.MESSAGE_CONSTRAINTS); // invalid address - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC - + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + INVALID_ADDRESS_DESC + MODULE_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + Address.MESSAGE_CONSTRAINTS); + + // invalid module + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + INVALID_MODULE_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + Module.MESSAGE_CONSTRAINTS); // invalid tag - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB - + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_CONSTRAINTS); + assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, + Tag.MESSAGE_CONSTRAINTS); // two invalid values, only first invalid value reported - assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC, + assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + + INVALID_ADDRESS_DESC + MODULE_DESC_BOB, Name.MESSAGE_CONSTRAINTS); // non-empty preamble assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB - + ADDRESS_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, + + ADDRESS_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } } From ed17a1da67bfdc7908e13e5184f81d8138e2c08e Mon Sep 17 00:00:00 2001 From: tsulim Date: Thu, 14 Mar 2024 00:23:46 +0800 Subject: [PATCH 23/27] Update LogicManagerTest with Module data field --- src/test/java/staffconnect/logic/LogicManagerTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/staffconnect/logic/LogicManagerTest.java b/src/test/java/staffconnect/logic/LogicManagerTest.java index 35c0b0fb985..45c58a662fe 100644 --- a/src/test/java/staffconnect/logic/LogicManagerTest.java +++ b/src/test/java/staffconnect/logic/LogicManagerTest.java @@ -5,6 +5,7 @@ import static staffconnect.logic.Messages.MESSAGE_UNKNOWN_COMMAND; import static staffconnect.logic.commands.CommandTestUtil.ADDRESS_DESC_AMY; import static staffconnect.logic.commands.CommandTestUtil.EMAIL_DESC_AMY; +import static staffconnect.logic.commands.CommandTestUtil.MODULE_DESC_AMY; import static staffconnect.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static staffconnect.logic.commands.CommandTestUtil.PHONE_DESC_AMY; import static staffconnect.testutil.Assert.assertThrows; @@ -166,7 +167,7 @@ public void saveStaffBook(ReadOnlyStaffBook staffBook, Path filePath) // Triggers the saveStaffBook method by executing an add command String addCommand = AddCommand.COMMAND_WORD + NAME_DESC_AMY + PHONE_DESC_AMY - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY; + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + MODULE_DESC_AMY; Person expectedPerson = new PersonBuilder(AMY).withTags().build(); ModelManager expectedModel = new ModelManager(); expectedModel.addPerson(expectedPerson); From 958f1d403653b8f414be20068ebd9e2a9d2fa930 Mon Sep 17 00:00:00 2001 From: tsulim Date: Thu, 14 Mar 2024 00:32:26 +0800 Subject: [PATCH 24/27] Update EditCommandParser with Module data field --- .../staffconnect/logic/parser/EditCommandParser.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/staffconnect/logic/parser/EditCommandParser.java b/src/main/java/staffconnect/logic/parser/EditCommandParser.java index 7281c65eacc..f403e356394 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_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_NAME; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; @@ -32,7 +33,8 @@ 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, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, PREFIX_MODULE, PREFIX_TAG); Index index; @@ -42,7 +44,8 @@ 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, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, PREFIX_MODULE); EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); @@ -58,6 +61,9 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) { editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get())); } + if (argMultimap.getValue(PREFIX_MODULE).isPresent()) { + editPersonDescriptor.setModule(ParserUtil.parseModule(argMultimap.getValue(PREFIX_MODULE).get())); + } parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags); if (!editPersonDescriptor.isAnyFieldEdited()) { From c14398e0e300c330fce85485fd461dfb34a50115 Mon Sep 17 00:00:00 2001 From: tsulim Date: Thu, 14 Mar 2024 00:32:47 +0800 Subject: [PATCH 25/27] Update EditCommandParserTest with Module data field --- .../logic/commands/CommandTestUtil.java | 4 +-- .../logic/parser/EditCommandParserTest.java | 36 ++++++++++++++----- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java index 8e401b01860..f088638e327 100644 --- a/src/test/java/staffconnect/logic/commands/CommandTestUtil.java +++ b/src/test/java/staffconnect/logic/commands/CommandTestUtil.java @@ -69,10 +69,10 @@ public class CommandTestUtil { static { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withTags(VALID_TAG_FRIEND).build(); + .withModule(VALID_MODULE_AMY).withTags(VALID_TAG_FRIEND).build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) - .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); + .withModule(VALID_MODULE_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); } /** diff --git a/src/test/java/staffconnect/logic/parser/EditCommandParserTest.java b/src/test/java/staffconnect/logic/parser/EditCommandParserTest.java index b1822865efd..205109aabdf 100644 --- a/src/test/java/staffconnect/logic/parser/EditCommandParserTest.java +++ b/src/test/java/staffconnect/logic/parser/EditCommandParserTest.java @@ -7,9 +7,12 @@ import static staffconnect.logic.commands.CommandTestUtil.EMAIL_DESC_BOB; import static staffconnect.logic.commands.CommandTestUtil.INVALID_ADDRESS_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC; +import static staffconnect.logic.commands.CommandTestUtil.INVALID_MODULE_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_NAME_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_PHONE_DESC; import static staffconnect.logic.commands.CommandTestUtil.INVALID_TAG_DESC; +import static staffconnect.logic.commands.CommandTestUtil.MODULE_DESC_AMY; +import static staffconnect.logic.commands.CommandTestUtil.MODULE_DESC_BOB; import static staffconnect.logic.commands.CommandTestUtil.NAME_DESC_AMY; import static staffconnect.logic.commands.CommandTestUtil.PHONE_DESC_AMY; import static staffconnect.logic.commands.CommandTestUtil.PHONE_DESC_BOB; @@ -17,6 +20,7 @@ import static staffconnect.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; import static staffconnect.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY; import static staffconnect.logic.commands.CommandTestUtil.VALID_EMAIL_AMY; +import static staffconnect.logic.commands.CommandTestUtil.VALID_MODULE_AMY; import static staffconnect.logic.commands.CommandTestUtil.VALID_NAME_AMY; import static staffconnect.logic.commands.CommandTestUtil.VALID_PHONE_AMY; import static staffconnect.logic.commands.CommandTestUtil.VALID_PHONE_BOB; @@ -24,6 +28,7 @@ import static staffconnect.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static staffconnect.logic.parser.CliSyntax.PREFIX_ADDRESS; import static staffconnect.logic.parser.CliSyntax.PREFIX_EMAIL; +import static staffconnect.logic.parser.CliSyntax.PREFIX_MODULE; import static staffconnect.logic.parser.CliSyntax.PREFIX_PHONE; import static staffconnect.logic.parser.CliSyntax.PREFIX_TAG; import static staffconnect.logic.parser.CommandParserTestUtil.assertParseFailure; @@ -40,6 +45,7 @@ import staffconnect.logic.commands.EditCommand.EditPersonDescriptor; import staffconnect.model.person.Address; import staffconnect.model.person.Email; +import staffconnect.model.person.Module; import staffconnect.model.person.Name; import staffconnect.model.person.Phone; import staffconnect.model.tag.Tag; @@ -87,6 +93,7 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS); // invalid phone assertParseFailure(parser, "1" + INVALID_EMAIL_DESC, Email.MESSAGE_CONSTRAINTS); // invalid email assertParseFailure(parser, "1" + INVALID_ADDRESS_DESC, Address.MESSAGE_CONSTRAINTS); // invalid address + assertParseFailure(parser, "1" + INVALID_MODULE_DESC, Module.MESSAGE_CONSTRAINTS); // invalid module assertParseFailure(parser, "1" + INVALID_TAG_DESC, Tag.MESSAGE_CONSTRAINTS); // invalid tag // invalid phone followed by valid email @@ -99,7 +106,8 @@ public void parse_invalidValue_failure() { assertParseFailure(parser, "1" + TAG_EMPTY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND, Tag.MESSAGE_CONSTRAINTS); // multiple invalid values, but only the first invalid value is captured - assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY + VALID_PHONE_AMY, + assertParseFailure(parser, "1" + INVALID_NAME_DESC + INVALID_EMAIL_DESC + + VALID_ADDRESS_AMY + VALID_PHONE_AMY + VALID_MODULE_AMY, Name.MESSAGE_CONSTRAINTS); } @@ -107,11 +115,11 @@ public void parse_invalidValue_failure() { public void parse_allFieldsSpecified_success() { Index targetIndex = INDEX_SECOND_PERSON; String userInput = targetIndex.getOneBased() + PHONE_DESC_BOB + TAG_DESC_HUSBAND - + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND; + + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + MODULE_DESC_AMY + TAG_DESC_FRIEND; EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) - .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); + .withModule(VALID_MODULE_AMY).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); EditCommand expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); @@ -156,6 +164,12 @@ public void parse_oneFieldSpecified_success() { expectedCommand = new EditCommand(targetIndex, descriptor); assertParseSuccess(parser, userInput, expectedCommand); + // module + userInput = targetIndex.getOneBased() + MODULE_DESC_AMY; + descriptor = new EditPersonDescriptorBuilder().withModule(VALID_MODULE_AMY).build(); + expectedCommand = new EditCommand(targetIndex, descriptor); + assertParseSuccess(parser, userInput, expectedCommand); + // tags userInput = targetIndex.getOneBased() + TAG_DESC_FRIEND; descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_FRIEND).build(); @@ -181,18 +195,22 @@ public void parse_multipleRepeatedFields_failure() { // mulltiple valid fields repeated userInput = targetIndex.getOneBased() + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY - + TAG_DESC_FRIEND + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_FRIEND - + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND; + + MODULE_DESC_AMY + TAG_DESC_FRIEND + PHONE_DESC_AMY + ADDRESS_DESC_AMY + + EMAIL_DESC_AMY + MODULE_DESC_AMY + TAG_DESC_FRIEND + PHONE_DESC_BOB + + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + MODULE_DESC_BOB + TAG_DESC_HUSBAND; assertParseFailure(parser, userInput, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, PREFIX_MODULE)); // multiple invalid values - userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + INVALID_EMAIL_DESC - + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + INVALID_EMAIL_DESC; + userInput = targetIndex.getOneBased() + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + + INVALID_EMAIL_DESC + INVALID_MODULE_DESC + INVALID_PHONE_DESC + INVALID_ADDRESS_DESC + + INVALID_EMAIL_DESC + INVALID_MODULE_DESC; assertParseFailure(parser, userInput, - Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS)); + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_ADDRESS, PREFIX_MODULE)); } @Test From f5e863050d1c2aa8e6d8e1e49988efb436c01f68 Mon Sep 17 00:00:00 2001 From: tsulim Date: Thu, 14 Mar 2024 01:24:44 +0800 Subject: [PATCH 26/27] Update ui with module data field --- src/main/java/staffconnect/ui/PersonCard.java | 3 +++ src/main/resources/view/PersonListCard.fxml | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/staffconnect/ui/PersonCard.java b/src/main/java/staffconnect/ui/PersonCard.java index 0abadaa1092..f93f79e7476 100644 --- a/src/main/java/staffconnect/ui/PersonCard.java +++ b/src/main/java/staffconnect/ui/PersonCard.java @@ -37,6 +37,8 @@ public class PersonCard extends UiPart { @FXML private Label venue; @FXML + private Label module; + @FXML private Label email; @FXML private FlowPane tags; @@ -51,6 +53,7 @@ public PersonCard(Person person, int displayedIndex) { name.setText(person.getName().fullName); phone.setText(person.getPhone().value); venue.setText(person.getVenue().value); + module.setText(person.getModule().value); email.setText(person.getEmail().value); person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index c75735e6b23..2101c6c5ed9 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -30,6 +30,7 @@