From a12cbb544a3ca977da7667715c340c7ba80000df Mon Sep 17 00:00:00 2001 From: Alexander Setyawan Date: Thu, 11 Apr 2024 01:00:41 +0800 Subject: [PATCH 1/4] Fix NRIC case sensitivity issues --- .../java/seedu/address/logic/commands/ClusterCommand.java | 3 +-- .../java/seedu/address/logic/commands/UpdateCommand.java | 2 +- .../seedu/address/logic/parser/AddVisitCommandParser.java | 2 +- .../java/seedu/address/logic/parser/CreateCommandParser.java | 2 +- .../seedu/address/logic/parser/DeleteInfoCommandParser.java | 2 +- src/main/java/seedu/address/logic/parser/ParserUtil.java | 2 +- .../java/seedu/address/logic/parser/UpdateCommandParser.java | 5 +++-- src/main/java/seedu/address/model/person/Nric.java | 3 +-- 8 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/ClusterCommand.java b/src/main/java/seedu/address/logic/commands/ClusterCommand.java index 6e50c5b5f2a..49c2275b33f 100644 --- a/src/main/java/seedu/address/logic/commands/ClusterCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClusterCommand.java @@ -19,8 +19,7 @@ public class ClusterCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ":\nDetects if there is a cluster of the size given," + " at the location given, of the disease given, and shows the details of all there with the disease." - + "by the respective NRIC in the displayed person list. " - + "Existing values will be overwritten by the input values.\n" + + "by the respective NRIC in the displayed person list.\n" + "Parameters: [CLUSTER SIZE] " + "[" + PREFIX_ADDRESS + "LOCATION] " + "[" + PREFIX_DIAGNOSIS + "DISEASE]\n" diff --git a/src/main/java/seedu/address/logic/commands/UpdateCommand.java b/src/main/java/seedu/address/logic/commands/UpdateCommand.java index 502033a6fe1..8404ccd13a9 100644 --- a/src/main/java/seedu/address/logic/commands/UpdateCommand.java +++ b/src/main/java/seedu/address/logic/commands/UpdateCommand.java @@ -82,7 +82,7 @@ public class UpdateCommand extends Command { public static final String MESSAGE_UPDATE_PERSON_SUCCESS = "Updated Person ->\n%1$s"; public static final String MESSAGE_NOT_UPDATED = "At least one field to update must be provided."; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; - public static final String MESSAGE_NRIC_NOT_UPDATED = "NRIC cannot be updated."; + // public static final String MESSAGE_NRIC_NOT_UPDATED = "NRIC cannot be updated."; (unsure if allowed) private final Nric nric; private final UpdatePersonDescriptor updatePersonDescriptor; diff --git a/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java b/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java index cf0f14888d6..5d53dd45fdb 100644 --- a/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java @@ -41,7 +41,7 @@ public AddVisitCommand parse(String args) throws ParseException { argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NRIC, PREFIX_DATEOFVISIT, PREFIX_SYMPTOM, PREFIX_DIAGNOSIS, PREFIX_STATUS); - Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get()); + Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get().toUpperCase()); DateOfVisit dov = ParserUtil.parseDateOfVisit(argMultimap.getValue(PREFIX_DATEOFVISIT).get()); Symptom symptom = ParserUtil.parseSymptom(argMultimap.getValue(PREFIX_SYMPTOM).get()); Diagnosis diagnosis = ParserUtil.parseDiagnosis(argMultimap.getValue(PREFIX_DIAGNOSIS).get()); diff --git a/src/main/java/seedu/address/logic/parser/CreateCommandParser.java b/src/main/java/seedu/address/logic/parser/CreateCommandParser.java index a927f95102f..abb35a2ec8e 100644 --- a/src/main/java/seedu/address/logic/parser/CreateCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/CreateCommandParser.java @@ -56,7 +56,7 @@ public CreateCommand parse(String args) throws ParseException { argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NRIC, PREFIX_NAME, PREFIX_PHONE, PREFIX_ADDRESS, PREFIX_DATEOFBIRTH, PREFIX_SEX, PREFIX_STATUS); - Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get()); + Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get().toUpperCase()); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); diff --git a/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java index a6a4693c777..617c5490d9d 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java @@ -57,7 +57,7 @@ public DeleteInfoCommand parse(String args) throws ParseException { //Check for NRIC Nric nric; try { - nric = ParserUtil.parseNric(argMultimap.getPreamble()); + nric = ParserUtil.parseNric(argMultimap.getPreamble().toUpperCase()); } catch (ParseException pe) { throw new ParseException( String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteInfoCommand.MESSAGE_USAGE), pe); diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index a99b7e45705..1faa567fc91 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -62,7 +62,7 @@ public static Nric parseNric(String nric) throws ParseException { if (!Nric.isValidNric(trimmedNric)) { throw new ParseException(Nric.MESSAGE_CONSTRAINTS); } - return new Nric(trimmedNric); + return new Nric(trimmedNric.toUpperCase()); } /** diff --git a/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java b/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java index ca165fd005a..4f18810bd54 100644 --- a/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java @@ -63,10 +63,11 @@ public UpdateCommand parse(String args) throws ParseException { UpdatePersonDescriptor updatePersonDescriptor = new UpdatePersonDescriptor(); updatePersonDescriptor.setNric(nric); - //Un-updatable field + + /* unsure if allowed if (argMultimap.getValue(PREFIX_NRIC).isPresent()) { throw new ParseException(UpdateCommand.MESSAGE_NRIC_NOT_UPDATED); - } + } */ // Mandatory fields if (argMultimap.getValue(PREFIX_NAME).isPresent()) { diff --git a/src/main/java/seedu/address/model/person/Nric.java b/src/main/java/seedu/address/model/person/Nric.java index dde1598cf85..09387b24c76 100644 --- a/src/main/java/seedu/address/model/person/Nric.java +++ b/src/main/java/seedu/address/model/person/Nric.java @@ -12,7 +12,7 @@ public class Nric { public static final String MESSAGE_CONSTRAINTS = "NRIC number should contain a prefix of S or T, followed by 7 digits, and end with a letter. " - + "There should not be blank."; + + "There should not be blanks."; /** * The first character of the address must not be a whitespace, @@ -30,7 +30,6 @@ public class Nric { public Nric(String nric) { requireNonNull(nric); checkArgument(isValidNric(nric), MESSAGE_CONSTRAINTS); - //TODO: is this a bug? this.nric = nric.toUpperCase(); } From 6f026470648417aaa4bf0e65b617073e90a3adbd Mon Sep 17 00:00:00 2001 From: Alexander Setyawan Date: Thu, 11 Apr 2024 01:46:52 +0800 Subject: [PATCH 2/4] Fix find command bug --- .../logic/parser/AddVisitCommandParser.java | 2 +- .../logic/parser/CreateCommandParser.java | 2 +- .../logic/parser/DeleteCommandParser.java | 2 +- .../logic/parser/DeleteInfoCommandParser.java | 2 +- .../logic/parser/FindCommandParser.java | 26 ++++++++++++++++--- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java b/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java index 5d53dd45fdb..cf0f14888d6 100644 --- a/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddVisitCommandParser.java @@ -41,7 +41,7 @@ public AddVisitCommand parse(String args) throws ParseException { argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NRIC, PREFIX_DATEOFVISIT, PREFIX_SYMPTOM, PREFIX_DIAGNOSIS, PREFIX_STATUS); - Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get().toUpperCase()); + Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get()); DateOfVisit dov = ParserUtil.parseDateOfVisit(argMultimap.getValue(PREFIX_DATEOFVISIT).get()); Symptom symptom = ParserUtil.parseSymptom(argMultimap.getValue(PREFIX_SYMPTOM).get()); Diagnosis diagnosis = ParserUtil.parseDiagnosis(argMultimap.getValue(PREFIX_DIAGNOSIS).get()); diff --git a/src/main/java/seedu/address/logic/parser/CreateCommandParser.java b/src/main/java/seedu/address/logic/parser/CreateCommandParser.java index abb35a2ec8e..a927f95102f 100644 --- a/src/main/java/seedu/address/logic/parser/CreateCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/CreateCommandParser.java @@ -56,7 +56,7 @@ public CreateCommand parse(String args) throws ParseException { argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NRIC, PREFIX_NAME, PREFIX_PHONE, PREFIX_ADDRESS, PREFIX_DATEOFBIRTH, PREFIX_SEX, PREFIX_STATUS); - Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get().toUpperCase()); + Nric nric = ParserUtil.parseNric(argMultimap.getValue(PREFIX_NRIC).get()); Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()); diff --git a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java index 3776c046f67..b51ed42d7e2 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java @@ -18,7 +18,7 @@ public class DeleteCommandParser implements Parser { */ public DeleteCommand parse(String args) throws ParseException { try { - Nric nric = ParserUtil.parseNric(args.toUpperCase()); + Nric nric = ParserUtil.parseNric(args); return new DeleteCommand(nric); } catch (ParseException pe) { throw new ParseException( diff --git a/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java index 617c5490d9d..a6a4693c777 100644 --- a/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/DeleteInfoCommandParser.java @@ -57,7 +57,7 @@ public DeleteInfoCommand parse(String args) throws ParseException { //Check for NRIC Nric nric; try { - nric = ParserUtil.parseNric(argMultimap.getPreamble().toUpperCase()); + nric = ParserUtil.parseNric(argMultimap.getPreamble()); } catch (ParseException pe) { throw new ParseException( String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteInfoCommand.MESSAGE_USAGE), pe); diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java index 06c201772d6..6b6502358f4 100644 --- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java @@ -32,23 +32,41 @@ public FindCommand parse(String args) throws ParseException { } if (trimmedArgs.startsWith(PREFIX_NAME.getPrefix())) { - String[] nameKeywords = trimmedArgs.substring(2).trim().split("\\s+"); - List list = Arrays.asList(nameKeywords); + String nameKeywords = trimmedArgs.substring(2); + if (nameKeywords.isEmpty()) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); + } + List list = Arrays.asList(nameKeywords.trim().split("\\s+")); return new FindCommand(new NameContainsKeywordsPredicate(list)); } else if (trimmedArgs.startsWith(PREFIX_ADDRESS.getPrefix())) { - String[] addressKeywords = trimmedArgs.substring(2).trim().split(","); + String doubleTrimmedArgs = trimmedArgs.substring(2); + if (doubleTrimmedArgs.isEmpty()) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); + } + + String[] addressKeywords = doubleTrimmedArgs.trim().split(","); int len = addressKeywords.length; for (int i = 0; i < len; i++) { addressKeywords[i] = addressKeywords[i].trim(); } + List list = Arrays.asList(addressKeywords); return new FindCommand(new AddressContainsKeywordsPredicate(list)); } else if (trimmedArgs.startsWith(PREFIX_CONDITION.getPrefix())) { - String[] conditionKeywords = trimmedArgs.substring(4).trim().split(","); + String doubleTrimmedArgs = trimmedArgs.substring(4); + if (doubleTrimmedArgs.isEmpty()) { + throw new ParseException( + String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE)); + } + + String[] conditionKeywords = doubleTrimmedArgs.trim().split(","); int len = conditionKeywords.length; for (int i = 0; i < len; i++) { conditionKeywords[i] = conditionKeywords[i].trim(); } + List list = Arrays.asList(conditionKeywords); return new FindCommand(new ConditionContainsKeywordsPredicate(list)); } else { From 70b181813962169dd6281516b38a5697b6549c8f Mon Sep 17 00:00:00 2001 From: Alexander Setyawan Date: Thu, 11 Apr 2024 17:10:47 +0800 Subject: [PATCH 3/4] Fix cluster command message --- src/main/java/seedu/address/logic/commands/ClusterCommand.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/ClusterCommand.java b/src/main/java/seedu/address/logic/commands/ClusterCommand.java index 49c2275b33f..219ecf177ea 100644 --- a/src/main/java/seedu/address/logic/commands/ClusterCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClusterCommand.java @@ -18,8 +18,7 @@ public class ClusterCommand extends Command { public static final String COMMAND_WORD = "cluster"; public static final String MESSAGE_USAGE = COMMAND_WORD + ":\nDetects if there is a cluster of the size given," - + " at the location given, of the disease given, and shows the details of all there with the disease." - + "by the respective NRIC in the displayed person list.\n" + + " at the location given, of the disease given, and shows the details of all there with the disease.\n" + "Parameters: [CLUSTER SIZE] " + "[" + PREFIX_ADDRESS + "LOCATION] " + "[" + PREFIX_DIAGNOSIS + "DISEASE]\n" From 6b8170119d9f65b00e5d8ebd1ac827d061a07101 Mon Sep 17 00:00:00 2001 From: Alexander Setyawan Date: Thu, 11 Apr 2024 17:15:09 +0800 Subject: [PATCH 4/4] Undo illegal edits to update command --- .../java/seedu/address/logic/commands/UpdateCommand.java | 1 - .../java/seedu/address/logic/parser/UpdateCommandParser.java | 5 ----- 2 files changed, 6 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/UpdateCommand.java b/src/main/java/seedu/address/logic/commands/UpdateCommand.java index 8404ccd13a9..72dec8b0349 100644 --- a/src/main/java/seedu/address/logic/commands/UpdateCommand.java +++ b/src/main/java/seedu/address/logic/commands/UpdateCommand.java @@ -82,7 +82,6 @@ public class UpdateCommand extends Command { public static final String MESSAGE_UPDATE_PERSON_SUCCESS = "Updated Person ->\n%1$s"; public static final String MESSAGE_NOT_UPDATED = "At least one field to update must be provided."; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; - // public static final String MESSAGE_NRIC_NOT_UPDATED = "NRIC cannot be updated."; (unsure if allowed) private final Nric nric; private final UpdatePersonDescriptor updatePersonDescriptor; diff --git a/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java b/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java index 4f18810bd54..f134eaefc20 100644 --- a/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/UpdateCommandParser.java @@ -64,11 +64,6 @@ public UpdateCommand parse(String args) throws ParseException { UpdatePersonDescriptor updatePersonDescriptor = new UpdatePersonDescriptor(); updatePersonDescriptor.setNric(nric); - /* unsure if allowed - if (argMultimap.getValue(PREFIX_NRIC).isPresent()) { - throw new ParseException(UpdateCommand.MESSAGE_NRIC_NOT_UPDATED); - } */ - // Mandatory fields if (argMultimap.getValue(PREFIX_NAME).isPresent()) { updatePersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));