From fa2ae5512da834bd4f83420d3ef178d973353df7 Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 11:42:52 +0800 Subject: [PATCH 01/11] Update filter command such that it cannot accept 2 or more prefixes --- .../logic/parser/FilterCommandParser.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java index 06fa7c4b6f7..8722f50bbbb 100644 --- a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java @@ -1,9 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_COURSE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.*; import java.util.Arrays; import java.util.List; @@ -27,6 +25,7 @@ public class FilterCommandParser implements Parser { public FilterCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_MODULE, PREFIX_COURSE); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_MODULE, PREFIX_COURSE); validateArguments(argMultimap); if (argMultimap.getValue(PREFIX_NAME).isPresent()) { @@ -42,12 +41,27 @@ public FilterCommand parse(String args) throws ParseException { private void validateArguments(ArgumentMultimap argMultimap) throws ParseException { if (!argMultimap.getPreamble().isEmpty() - || argMultimap.getValue(PREFIX_NAME).isPresent() - && argMultimap.getValue(PREFIX_NAME).get().isEmpty() - || argMultimap.getValue(PREFIX_MODULE).isPresent() - && argMultimap.getValue(PREFIX_MODULE).get().isEmpty() - || argMultimap.getValue(PREFIX_COURSE).isPresent() - && argMultimap.getValue(PREFIX_COURSE).get().isEmpty()) { + || (argMultimap.getValue(PREFIX_NAME).isPresent() + && argMultimap.getValue(PREFIX_NAME).get().isEmpty()) + || (argMultimap.getValue(PREFIX_MODULE).isPresent() + && argMultimap.getValue(PREFIX_MODULE).get().isEmpty()) + || (argMultimap.getValue(PREFIX_COURSE).isPresent() + && argMultimap.getValue(PREFIX_COURSE).get().isEmpty())) { + throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE)); + } + + int prefixCount = 0; + if (argMultimap.getValue(PREFIX_NAME).isPresent()) { + prefixCount++; + } + if (argMultimap.getValue(PREFIX_MODULE).isPresent()) { + prefixCount++; + } + if (argMultimap.getValue(PREFIX_COURSE).isPresent()) { + prefixCount++; + } + + if (prefixCount > 1) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE)); } } From bca1e520b05611bc1f4e9675085f0f7baba15a9c Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 11:43:17 +0800 Subject: [PATCH 02/11] Update tests for filter according to new behaviour --- .../address/logic/parser/FilterCommandParserTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/seedu/address/logic/parser/FilterCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FilterCommandParserTest.java index cb81b5cf775..dcb0a1b5e7a 100644 --- a/src/test/java/seedu/address/logic/parser/FilterCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/FilterCommandParserTest.java @@ -1,6 +1,7 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; @@ -9,6 +10,7 @@ import org.junit.jupiter.api.Test; +import seedu.address.logic.Messages; import seedu.address.logic.commands.FilterCommand; import seedu.address.model.person.NameContainsKeywordsPredicate; @@ -48,4 +50,12 @@ public void parse_invalidArgs_throwsParseException() { assertParseFailure(parser, " x/alice", String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE)); } + + @Test + public void parse_multiplePrefixes_throwsParseException() { + assertParseFailure(parser, " n/alice m/CS2103", + String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE)); + assertParseFailure(parser, " n/alex n/alice", + Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME)); + } } From c699939dadac9b5b780029c96bfd3c4e29547545 Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 12:29:25 +0800 Subject: [PATCH 03/11] Update UG --- docs/UserGuide.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 9cd7c6c71a9..8c574bf2a8e 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -26,6 +26,7 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c - [Listing students by certain attributes : `filter`](#listing-students-by-certain-attributes-filter) - [Adding a module to a student: `module`](#adding-a-module-to-a-student-module) - [Deleting a person : `delete`](#deleting-a-person-delete) + - [Finding a person: `find`](#finding-a-person--find) - [Clearing all entries : `clear`](#clearing-all-entries-clear) - [Exiting the program : `exit`](#exiting-the-program-exit) 3. [FAQ](#faq) @@ -239,6 +240,15 @@ Examples: * `filter n/alex david` returns `Alex Yeoh`, `David Li` ![result for 'find alex david'](images/filterAlexDavidResult.png) +
+ + + +**Note:** After using `filter`, only the persons displayed in the filtered list can be edited or deleted, and persons not shown in this truncated list cannot be modified. + +To return to display the full list of persons, use `list` command. + + ### Adding a module to a student: `module` @@ -277,7 +287,7 @@ Format: `find ID` * Finds student with the specified `ID`. Examples: -* `find 12345678` will find student contact with `ID: 12345678` and display their details. +* `find 12345678` will find student contact with `ID: 12345678` and display their details ### Clearing all entries : `clear` From 9f85df399543a938194707b0b8d9053f723aa687 Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 12:29:42 +0800 Subject: [PATCH 04/11] Update deletecommand message usage --- src/main/java/seedu/address/logic/commands/DeleteCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 4be12c252e3..2304298a825 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -25,9 +25,9 @@ public class DeleteCommand extends Command { + "Parameters: " + "ID\n" + "or: " - + "ID MODULE_KEYWORD" + + "ID MODULE_KEYWORD\n" + "Example: " + COMMAND_WORD + " " - + "12345678" + + "12345678\n" + "or: " + COMMAND_WORD + " " + "12345678 m/CS2103T"; From 5719b812857cdff2ffa333dfae629adaae7f8fdb Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 22:54:10 +0800 Subject: [PATCH 05/11] Update error message: delete and find command --- src/main/java/seedu/address/logic/Messages.java | 4 ++-- src/main/java/seedu/address/logic/commands/DeleteCommand.java | 3 ++- src/main/java/seedu/address/logic/commands/FindCommand.java | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index eb0220ac86d..6c315814f94 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -14,8 +14,8 @@ public class Messages { public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command"; public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s"; - public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid"; - public static final String MESSAGE_INVALID_PERSON_DISPLAYED_STUDENTID = "The person studentID provided is invalid"; + public static final String MESSAGE_INVALID_PERSON_DISPLAYED_STUDENTID = + "No student with this Student ID is currently being displayed"; public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; public static final String MESSAGE_DUPLICATE_FIELDS = "Multiple values specified for the following single-valued field(s): "; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 2304298a825..658acb38988 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -34,7 +34,8 @@ public class DeleteCommand extends Command { public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Student: %1$s"; public static final String MESSAGE_DELETE_MODULE_SUCCESS = "Deleted Module: %1$s"; - public static final String MESSAGE_PERSON_NOT_FOUND = "No student is found with Student ID: %1$s"; + public static final String MESSAGE_PERSON_NOT_FOUND = + "No student with Student ID: %1$s is currently being displayed"; public static final String MESSAGE_MODULE_NOT_FOUND = "No module is found for this student: %1$s"; private final StudentId studentId; private final Module module; diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 51590108c68..f2343115282 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -26,7 +26,8 @@ public class FindCommand extends Command { + "12345678"; public static final String MESSAGE_FIND_PERSON_SUCCESS = "Found Student: %1$s"; - public static final String MESSAGE_PERSON_NOT_FOUND = "No student is found with Student ID: %1$s"; + public static final String MESSAGE_PERSON_NOT_FOUND = + "No student with Student ID: %1$s is currently being displayed"; private final StudentId studentId; /** From 9943a26c11cfcef45985f96858804616f64e00c0 Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 22:54:37 +0800 Subject: [PATCH 06/11] Fix address can take random characters --- src/main/java/seedu/address/model/person/Address.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index 7a2b7be5c34..c04c4c6027f 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -9,13 +9,15 @@ */ public class Address { - public static final String MESSAGE_CONSTRAINTS = "Addresses can take any values, and it should not be blank"; + public static final String MESSAGE_CONSTRAINTS = + "Addresses can only take any alphabets, numbers, or these following characters\n" + + " # , - and it should not be blank"; /* * The first character of the address must not be a whitespace, * otherwise " " (a blank string) becomes a valid input. */ - public static final String VALIDATION_REGEX = "[^\\s].*"; + public static final String VALIDATION_REGEX = "^[A-Za-z0-9#,'-]+.*$"; public final String value; From 003c6d39ee76c5d1a899ff7406d3240587c183af Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 23:04:47 +0800 Subject: [PATCH 07/11] Update parser logic --- .../address/logic/parser/FilterCommandParser.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java index 8722f50bbbb..194b2aac71c 100644 --- a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.List; +import java.util.stream.Stream; import seedu.address.logic.commands.FilterCommand; import seedu.address.logic.parser.exceptions.ParseException; @@ -50,16 +51,9 @@ private void validateArguments(ArgumentMultimap argMultimap) throws ParseExcepti throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE)); } - int prefixCount = 0; - if (argMultimap.getValue(PREFIX_NAME).isPresent()) { - prefixCount++; - } - if (argMultimap.getValue(PREFIX_MODULE).isPresent()) { - prefixCount++; - } - if (argMultimap.getValue(PREFIX_COURSE).isPresent()) { - prefixCount++; - } + long prefixCount = Stream.of(PREFIX_NAME, PREFIX_MODULE, PREFIX_COURSE) + .filter(prefix -> argMultimap.getValue(prefix).isPresent()) + .count(); if (prefixCount > 1) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, FilterCommand.MESSAGE_USAGE)); From 141770b5cf9b083230fea11b3f35db12ec71ad0c Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 23:06:02 +0800 Subject: [PATCH 08/11] Update UG --- docs/UserGuide.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 8c574bf2a8e..581bd7d95a9 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -108,6 +108,9 @@ EduContacts is a **desktop app for Educators in Tertiary Institution to manage c **Notes about the command format:**
+* All command words should be in lowercase. + + * Words in `UPPER_CASE` are the parameters to be supplied by the user.
e.g. in `add n/NAME`, `NAME` is a parameter which can be used as `add n/John Doe`. From c4ed14a6a8a207a348f9094c1b1cd04208646828 Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Wed, 6 Nov 2024 23:46:06 +0800 Subject: [PATCH 09/11] Add assertion --- .../java/seedu/address/logic/parser/FilterCommandParser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java index 194b2aac71c..838e9b6e5ce 100644 --- a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java @@ -61,16 +61,19 @@ private void validateArguments(ArgumentMultimap argMultimap) throws ParseExcepti } private FilterCommand createFilterCommandByName(ArgumentMultimap argMultimap) { + assert argMultimap.getValue(PREFIX_NAME).isPresent() : "PREFIX_NAME should be present"; List nameKeywords = Arrays.asList(argMultimap.getValue(PREFIX_NAME).get().split("\\s+")); return new FilterCommand(new NameContainsKeywordsPredicate(nameKeywords)); } private FilterCommand createFilterCommandByModule(ArgumentMultimap argMultimap) { + assert argMultimap.getValue(PREFIX_MODULE).isPresent() : "PREFIX_MODULE should be present"; String moduleKeyword = argMultimap.getValue(PREFIX_MODULE).get(); return new FilterCommand(new ModuleContainsKeywordsPredicate(moduleKeyword)); } private FilterCommand createFilterCommandByCourse(ArgumentMultimap argMultimap) { + assert argMultimap.getValue(PREFIX_COURSE).isPresent() : "PREFIX_COURSE should be present"; List courseKeywords = Arrays.asList(argMultimap.getValue(PREFIX_COURSE).get().split("\\s+")); return new FilterCommand(new CourseContainsKeywordsPredicate(courseKeywords)); } From cb31e977fa7966c1ef8569c6ba57db69473d785b Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Thu, 7 Nov 2024 08:36:48 +0800 Subject: [PATCH 10/11] Fix checkstyle issue --- .../java/seedu/address/logic/parser/FilterCommandParser.java | 4 +++- src/main/java/seedu/address/model/person/Address.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java index 838e9b6e5ce..ddd55433bf4 100644 --- a/src/main/java/seedu/address/logic/parser/FilterCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/FilterCommandParser.java @@ -1,7 +1,9 @@ package seedu.address.logic.parser; import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.*; +import static seedu.address.logic.parser.CliSyntax.PREFIX_COURSE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index c04c4c6027f..e94c14ebd4b 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -10,8 +10,8 @@ public class Address { public static final String MESSAGE_CONSTRAINTS = - "Addresses can only take any alphabets, numbers, or these following characters\n" + - " # , - and it should not be blank"; + "Addresses can only take any alphabets, numbers, or these following characters\n" + + " # , - and it should not be blank"; /* * The first character of the address must not be a whitespace, From d7c59e4ef61a1ed8a15378d9781bab48af0a1329 Mon Sep 17 00:00:00 2001 From: jessica2828 Date: Thu, 7 Nov 2024 09:09:44 +0800 Subject: [PATCH 11/11] Edit address message constraints --- src/main/java/seedu/address/model/person/Address.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java index e94c14ebd4b..71320bbee3b 100644 --- a/src/main/java/seedu/address/model/person/Address.java +++ b/src/main/java/seedu/address/model/person/Address.java @@ -11,7 +11,7 @@ public class Address { public static final String MESSAGE_CONSTRAINTS = "Addresses can only take any alphabets, numbers, or these following characters\n" - + " # , - and it should not be blank"; + + " # , - ' and it should not be blank"; /* * The first character of the address must not be a whitespace,