diff --git a/src/main/java/seedu/modulink/logic/commands/AddFavCommand.java b/src/main/java/seedu/modulink/logic/commands/AddFavCommand.java index 01157a49c7c..56738120832 100644 --- a/src/main/java/seedu/modulink/logic/commands/AddFavCommand.java +++ b/src/main/java/seedu/modulink/logic/commands/AddFavCommand.java @@ -2,6 +2,8 @@ import static seedu.modulink.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import java.util.function.Predicate; + import javafx.collections.ObservableList; import seedu.modulink.commons.core.Messages; import seedu.modulink.model.Model; @@ -20,6 +22,9 @@ public class AddFavCommand extends Command { + "Parameters: Student_ID \n" + "Example: " + COMMAND_WORD + " A1234567X"; + public static final String FAVOURITING_PROFILE_ERROR = + "You cannot add your own profile to your Favourites list."; + private final String studentId; public AddFavCommand(String studentId) { @@ -38,12 +43,17 @@ public CommandResult execute(Model model) { if (person.getStudentId().toString().equalsIgnoreCase(studentId)) { if (person.getIsFavourite()) { return new CommandResult(String.format(Messages.MESSAGE_PERSON_ALREADY_FAVOURITE)); + } else if (person.getIsMyProfile()) { + return new CommandResult(FAVOURITING_PROFILE_ERROR); } else { person.setFavouriteTrue(); noPersonFound = false; } } } + // included this so the list will be properly updated + Predicate updatePredicate = unused -> false; + model.updateFilteredPersonList(updatePredicate); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); if (noPersonFound) { diff --git a/src/main/java/seedu/modulink/logic/commands/RemFavCommand.java b/src/main/java/seedu/modulink/logic/commands/RemFavCommand.java index 55ca8826b28..bc53d21f260 100644 --- a/src/main/java/seedu/modulink/logic/commands/RemFavCommand.java +++ b/src/main/java/seedu/modulink/logic/commands/RemFavCommand.java @@ -2,11 +2,14 @@ import static seedu.modulink.model.Model.PREDICATE_SHOW_ALL_PERSONS; +import java.util.function.Predicate; + import javafx.collections.ObservableList; import seedu.modulink.commons.core.Messages; import seedu.modulink.model.Model; import seedu.modulink.model.person.Person; + /** * Removes person whose student ID matches the user input from favourites. * ID matching is case insensitive. @@ -42,6 +45,9 @@ public CommandResult execute(Model model) { } } } + // included this so the list will be properly updated + Predicate updatePredicate = unused -> false; + model.updateFilteredPersonList(updatePredicate); model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); if (noPersonFound) { return new CommandResult(Messages.MESSAGE_NO_SUCH_ID_FOUND); diff --git a/src/main/java/seedu/modulink/model/person/GitHubUsername.java b/src/main/java/seedu/modulink/model/person/GitHubUsername.java index 3449f381b2e..795927591b6 100644 --- a/src/main/java/seedu/modulink/model/person/GitHubUsername.java +++ b/src/main/java/seedu/modulink/model/person/GitHubUsername.java @@ -7,7 +7,7 @@ public class GitHubUsername { public static final String MESSAGE_CONSTRAINTS = "GitHub username should start with an alphanumeric character, " + "can only contain alphanumeric characters and hyphens, and must not contain any spaces."; - public static final String VALIDATION_REGEX = "^[A-Za-z0-9]+[A-Za-z0-9_]+$"; + public static final String VALIDATION_REGEX = "^[A-Za-z0-9]+[A-Za-z0-9_-]+$"; public final String value; /** diff --git a/src/main/java/seedu/modulink/model/person/ModuleContainsKeywordsPredicate.java b/src/main/java/seedu/modulink/model/person/ModuleContainsKeywordsPredicate.java index d6518cf6cf8..e0931301bc6 100644 --- a/src/main/java/seedu/modulink/model/person/ModuleContainsKeywordsPredicate.java +++ b/src/main/java/seedu/modulink/model/person/ModuleContainsKeywordsPredicate.java @@ -31,6 +31,9 @@ public ModuleContainsKeywordsPredicate(Set mods, Status status) { @Override public boolean test(Person person) { boolean doesMatchMod = false; + if (person.getIsMyProfile()) { + return false; + } for (Mod mod : person.getMods()) { for (Mod module : mods) { if (module.modName.equalsIgnoreCase(mod.modName)) { diff --git a/src/main/java/seedu/modulink/model/util/SampleDataUtil.java b/src/main/java/seedu/modulink/model/util/SampleDataUtil.java index 6715daa642e..704db35d511 100644 --- a/src/main/java/seedu/modulink/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/modulink/model/util/SampleDataUtil.java @@ -24,28 +24,60 @@ public static Person[] getSamplePersons() { return new Person[] { new Person(new Name("Alex Yeoh"), new StudentId("A1234567R"), new Phone("87438807"), new Email("alexyeoh@example.com"), new GitHubUsername("alex_yeoh_y"), - new TelegramHandle("alexyeoh"), true, - getTagSet("CS2103T have group", "CS2106", "CS2101 need member"), false), + new TelegramHandle("alexyeoh"), false, + getTagSet("CS2103T", "CS2106", "CS2101 need member"), false), + new Person(new Name("Zachary Lau"), new StudentId("A1234567H"), new Phone("96523487"), + new Email("zachlau@example.com"), new GitHubUsername("zachattach"), + new TelegramHandle("zacharrryyyy"), false, + getTagSet("CS2100", "CS2106", "CS2101 need group"), false), + new Person(new Name("Ng Jia Yuan"), new StudentId("A1234567N"), new Phone("98432567"), + new Email("ngjy@example.com"), new GitHubUsername("yuan"), + new TelegramHandle("yuan"), false, + getTagSet("CS5210 need group", "CS2106", "CS2100 need member"), false), + new Person(new Name("Charlton Tan"), new StudentId("A1234567L"), new Phone("97324615"), + new Email("charles@example.com"), new GitHubUsername("C-dollarsign"), + new TelegramHandle("followmyspotify"), false, + getTagSet("CS2101 need group", "IS1101"), false), + new Person(new Name("Ahmad bin Ali"), new StudentId("A1234567B"), new Phone("95238541"), + new Email("aba@example.com"), new GitHubUsername("alibinahmad"), + new TelegramHandle("diversity"), false, + getTagSet("CS2100", "CS2106", "CS2103T need group"), false), new Person(new Name("Bernice Yu"), new StudentId("A1234568X"), new Phone("99272758"), new Email("berniceyu@example.com"), new GitHubUsername(null), new TelegramHandle("berniceYuuu"), false, getTagSet("CS2100", "CS3230 need group", "CS4234 need member"), false), new Person(new Name("Charlotte Oliveiro"), new StudentId("A1234569Y"), new Phone("93210283"), new Email("charlotte@example.com"), new GitHubUsername("charlotte_oliveiro"), - new TelegramHandle("charlotte24"), true, + new TelegramHandle("charlotte24"), false, getTagSet("CS1101S", "CS3230 need member"), false), new Person(new Name("David Li"), new StudentId("A1234570Z"), new Phone("91031282"), new Email("lidavid@example.com"), new GitHubUsername("Davidli"), new TelegramHandle(null), false, - getTagSet("IS1103"), false), + getTagSet("CS2101"), false), new Person(new Name("Irfan Ibrahim"), new StudentId("A1234571R"), new Phone("92492021"), new Email("irfan@example.com"), new GitHubUsername("Irfanib"), new TelegramHandle("irfanibrahim"), false, - getTagSet("ST2334 need group", "GEA1000 need member"), false), + getTagSet("CS2101 need member", "ES2660 need group", "CS2103T"), false), new Person(new Name("Roy Balakrishnan"), new StudentId("A1234572X"), new Phone("92624417"), new Email("royb@example.com"), new GitHubUsername("Roybalakrishnan"), new TelegramHandle("heyitsroy"), false, - getTagSet("LAJ1000 need member", "GES1021", "MA2001"), false) + getTagSet("CS2100", "CS2103T", "CS2101 need group"), false), + new Person(new Name("Nicole Wong"), new StudentId("A1234567Q"), new Phone("96523546"), + new Email("niolewong@example.com"), new GitHubUsername("NicoleW"), + new TelegramHandle("yellowNicole"), false, + getTagSet("CS2101 need member", "MA2001"), false), + new Person(new Name("Jeremy Tan"), new StudentId("A1234567W"), new Phone("96875439"), + new Email("jTan2000@example.com"), new GitHubUsername("jTanremy"), + new TelegramHandle("jeret"), false, + getTagSet("CS2101", "CS1101S need member", "CS2103T"), false), + new Person(new Name("Aniq Nathaniel"), new StudentId("A1234567E"), new Phone("92584685"), + new Email("aniqNathan@example.com"), new GitHubUsername("NathAniq"), + new TelegramHandle("Aniqle4urThoughts"), false, + getTagSet("CS2101 need group", "CS4234", "CS2103T need group"), false), + new Person(new Name("Timmy Turner"), new StudentId("A1234567E"), new Phone("95483265"), + new Email("timmyturns@example.com"), new GitHubUsername("TimTam"), + new TelegramHandle(null), false, + getTagSet("ST2334 need group", "GEA1000 need member"), false) }; }