diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index d5196a9734e..25d357ab2ad 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -170,7 +170,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, ic, dob, admissionDate, ward, tags, remark); + return CollectionUtil.isAnyNonNull(name, ic, dob, admissionDate, ward, tags); } public void setName(Name name) { @@ -253,9 +253,9 @@ public boolean equals(Object other) { public String toString() { return new ToStringBuilder(this) .add("name", name) - .add("tags", tags) - .add("ic", ic) .add("dob", dob) + .add("ic", ic) + .add("tags", tags) .add("admissionDate", admissionDate) .add("ward", ward) .add("remark", remark) diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index d86334091b4..e2611ce5e1c 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -6,6 +6,7 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_DOB; import static seedu.address.logic.parser.CliSyntax.PREFIX_IC; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import static seedu.address.logic.parser.CliSyntax.PREFIX_WARD; @@ -34,7 +35,7 @@ public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_DOB, PREFIX_WARD, PREFIX_IC, - PREFIX_ADMISSION_DATE, PREFIX_TAG); + PREFIX_ADMISSION_DATE, PREFIX_TAG, PREFIX_REMARK); Index index; @@ -67,6 +68,10 @@ public EditCommand parse(String args) throws ParseException { editPersonDescriptor.setWard(ParserUtil.parseWard(argMultimap.getValue(PREFIX_WARD).get())); } + if (argMultimap.getValue(PREFIX_REMARK).isPresent()) { + editPersonDescriptor.setRemark(ParserUtil.parseRemark(argMultimap.getValue(PREFIX_REMARK).get())); + } + if (!editPersonDescriptor.isAnyFieldEdited()) { throw new ParseException(EditCommand.MESSAGE_NOT_EDITED); } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index d545aa3a893..81f31a4f755 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -13,6 +13,7 @@ import seedu.address.model.person.Dob; import seedu.address.model.person.Ic; import seedu.address.model.person.Name; +import seedu.address.model.person.Remark; import seedu.address.model.person.Ward; import seedu.address.model.tag.Tag; @@ -141,4 +142,14 @@ public static Ward parseWard(String ward) throws ParseException { return new Ward(trimmedWard); } + /** + * Parses a {@code String remark} into a {@code Remark}. + * Leading and trailing whitespaces will be trimmed. + */ + public static Remark parseRemark(String remark) throws ParseException { + requireNonNull(remark); + String trimmedRemark = remark.trim(); + return new Remark(trimmedRemark); + } + } diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json index 8e869cd2d5f..1e07c002a83 100644 --- a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json @@ -5,12 +5,14 @@ "dob": "20/02/2000", "ic": "A1234567B", "admissionDate": "01/03/2024", - "ward":"A1" + "ward":"A1", + "remark":"" }, { "name": "Alice Pauline", "dob": "20/02/2000", "ic": "A1234567B", "admissionDate": "01/03/2024", - "ward":"A1" + "ward":"A1", + "remark":"" } ] } diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json index 33f9a5462d3..c5691908ae4 100644 --- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json +++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json @@ -7,7 +7,7 @@ "ic": "A1234567B", "admissionDate": "01/03/2024", "ward":"A1", - "remark":"This is a remark" + "remark":"This is a remark." }, { "name" : "Benson Meier", "tags" : [ "Dementia", "FallRisk" ], @@ -15,7 +15,7 @@ "ic": "A2345678B", "admissionDate": "01/02/2024", "ward": "B1", - "remark":"This is a remark" + "remark":"This is a remark." }, { "name" : "Carl Kurz", "tags" : [ ], @@ -23,7 +23,7 @@ "ic": "A3456789B", "admissionDate": "05/03/2024", "ward": "C1", - "remark":"This is a remark" + "remark":"This is a remark." }, { "name" : "Daniel Meier", "tags" : [ "HearingImpaired" ], @@ -31,7 +31,7 @@ "ic": "A5678901B", "admissionDate": "10/03/2024", "ward": "D1", - "remark":"This is a remark" + "remark":"This is a remark." }, { "name" : "Elle Meyer", "tags" : [ ], @@ -39,7 +39,7 @@ "ic": "A4756976B", "admissionDate": "05/02/2024", "ward": "E1", - "remark":"This is a remark" + "remark":"This is a remark." }, { "name" : "Fiona Kunz", "tags" : [ ], @@ -47,7 +47,7 @@ "ic": "A5739485B", "admissionDate": "11/03/2024", "ward": "F1", - "remark":"This is a remark" + "remark":"This is a remark." }, { "name" : "George Best", "tags" : [ ], @@ -55,6 +55,6 @@ "ic": "A0987654B", "admissionDate": "16/03/2024", "ward": "G1", - "remark":"This is a remark" + "remark":"This is a remark." } ] } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 65d2ef5c3e4..fd12731b4d3 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -41,7 +41,7 @@ public class CommandTestUtil { public static final String VALID_WARD_AMY = "A1"; public static final String VALID_WARD_BOB = "B1"; public static final String VALID_REMARK_AMY = ""; - public static final String VALID_REMARK_BOB = "This is a remark."; + public static final String VALID_REMARK_BOB = "Some remark."; // description + value public static final String NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY; diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java index b94c7c50c26..7cd5a55718b 100644 --- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java +++ b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java @@ -60,12 +60,13 @@ public void equals() { public void toStringMethod() { EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); String expected = EditPersonDescriptor.class.getCanonicalName() + "{name=" - + editPersonDescriptor.getName().orElse(null) + ", tags=" - + editPersonDescriptor.getDob().orElse(null) + ", ic=" + editPersonDescriptor.getTags().orElse(null) + ", dob=" + + editPersonDescriptor.getDob().orElse(null) + ", ic=" + + editPersonDescriptor.getName().orElse(null) + ", tags=" + editPersonDescriptor.getIc().orElse(null) + ", admissionDate=" + editPersonDescriptor.getAdmissionDate().orElse(null) + ", ward=" - + editPersonDescriptor.getWard().orElse(null) + "}"; + + editPersonDescriptor.getWard().orElse(null) + ", remark=" + + editPersonDescriptor.getRemark().orElse(null) + "}"; assertEquals(expected, editPersonDescriptor.toString()); } } diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index f50eb316392..c30b139140e 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -27,7 +27,6 @@ import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; import static seedu.address.testutil.TypicalPersons.AMY; -import static seedu.address.testutil.TypicalPersons.BOB; import org.junit.jupiter.api.Test; @@ -46,20 +45,20 @@ public class AddCommandParserTest { @Test public void parse_allFieldsPresent_success() { - Person expectedPerson = new PersonBuilder(BOB).withTags(VALID_TAG_DIABETES).build(); + Person expectedPerson = new PersonBuilder(AMY).withTags(VALID_TAG_DIABETES).build(); // whitespace only preamble - assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + TAG_DESC_DIABETES + DOB_DESC_BOB + IC_DESC_BOB - + ADMISSION_DATE_DESC_BOB + WARD_DESC_BOB, new AddCommand(expectedPerson)); + assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_AMY + TAG_DESC_DIABETES + DOB_DESC_AMY + IC_DESC_AMY + + ADMISSION_DATE_DESC_AMY + WARD_DESC_AMY, new AddCommand(expectedPerson)); // multiple tags - all accepted - Person expectedPersonMultipleTags = new PersonBuilder(BOB).withTags(VALID_TAG_DIABETES, VALID_TAG_FALL_RISK) + Person expectedPersonMultipleTags = new PersonBuilder(AMY).withTags(VALID_TAG_DIABETES, VALID_TAG_FALL_RISK) .build(); assertParseSuccess(parser, - NAME_DESC_BOB + TAG_DESC_FALL_RISK + TAG_DESC_DIABETES - + DOB_DESC_BOB + IC_DESC_BOB - + ADMISSION_DATE_DESC_BOB + WARD_DESC_BOB, + NAME_DESC_AMY + TAG_DESC_FALL_RISK + TAG_DESC_DIABETES + + DOB_DESC_AMY + IC_DESC_AMY + + ADMISSION_DATE_DESC_AMY + WARD_DESC_AMY, new AddCommand(expectedPersonMultipleTags)); } diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index a8dc5caff58..2903513b132 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -99,7 +99,8 @@ public void toStringMethod() { + ", dob=" + ALICE.getDob() + ", ic=" + ALICE.getIc() + ", admissionDate=" + ALICE.getAdmissionDate() - + ", ward=" + ALICE.getWard() + "}"; + + ", ward=" + ALICE.getWard() + + ", remark=" + ALICE.getRemark() + "}"; assertEquals(expected, ALICE.toString()); } } diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java index 4c29569f958..7caaa80a48e 100644 --- a/src/test/java/seedu/address/testutil/PersonUtil.java +++ b/src/test/java/seedu/address/testutil/PersonUtil.java @@ -62,6 +62,8 @@ public static String getEditPersonDescriptorDetails(EditPersonDescriptor descrip tags.forEach(s -> sb.append(PREFIX_TAG).append(s.tagName).append(" ")); } } + descriptor.getRemark().ifPresent(remark -> sb.append(PREFIX_REMARK) + .append(remark.value).append(" ")); return sb.toString(); } } diff --git a/src/test/java/seedu/address/testutil/TypicalPersons.java b/src/test/java/seedu/address/testutil/TypicalPersons.java index eb871f4d5ff..1cfffc95d6b 100644 --- a/src/test/java/seedu/address/testutil/TypicalPersons.java +++ b/src/test/java/seedu/address/testutil/TypicalPersons.java @@ -56,7 +56,7 @@ public class TypicalPersons { public static final Person BOB = new PersonBuilder().withName(VALID_NAME_BOB) .withTags(VALID_TAG_DIABETES, VALID_TAG_FALL_RISK) .withDob(VALID_DOB_BOB).withIc(VALID_IC_BOB).withAdmissionDate(VALID_ADMISSION_DATE_BOB) - .withWard(VALID_WARD_BOB).withWard(VALID_REMARK_BOB).build(); + .withWard(VALID_WARD_BOB).withRemark(VALID_REMARK_BOB).build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER