forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from alyssaongyx/add-course-search
Add localcourse and partnercourse search
- Loading branch information
Showing
86 changed files
with
947 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...logic/commands/LocalCourseAddCommand.java → ...ds/localcourse/LocalCourseAddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ss/logic/commands/LocalCourseCommand.java → ...mands/localcourse/LocalCourseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ic/commands/LocalCourseDeleteCommand.java → ...localcourse/LocalCourseDeleteCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ogic/commands/LocalCourseListCommand.java → ...s/localcourse/LocalCourseListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/main/java/seedu/address/logic/commands/localcourse/LocalCourseSearchCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package seedu.address.logic.commands.localcourse; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.Objects; | ||
|
||
import seedu.address.commons.util.ToStringBuilder; | ||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.CommandResult; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.SeplendidModel; | ||
import seedu.address.model.localcourse.LocalCourseAttribute; | ||
import seedu.address.model.localcourse.LocalCourseContainsKeywordsPredicate; | ||
import seedu.address.seplendidui.UiUtil; | ||
|
||
/** | ||
* Finds and lists all localcourses in SEPlendid whose name contains any of the argument keywords. | ||
* Keyword matching is case-insensitive. | ||
*/ | ||
public class LocalCourseSearchCommand extends LocalCourseCommand { | ||
public static final String ACTION_WORD = "search"; // Use "search" as the command word | ||
|
||
public static final String MESSAGE_SUCCESS = "Local courses searched: %1$s"; | ||
|
||
|
||
public static final String LOCALCOURSE_SEARCH_MESSAGE_USAGE = COMMAND_WORD | ||
+ " : Search local courses by attributes - localcode and localname and localdescription"; | ||
|
||
private final LocalCourseAttribute attribute; | ||
|
||
private final LocalCourseContainsKeywordsPredicate predicate; | ||
|
||
private String query; | ||
|
||
/** | ||
* Creates a LocalCourseSearchCommand to sort the local course list based on the code predicate. | ||
* @param codePredicate Predicate use for search | ||
*/ | ||
public LocalCourseSearchCommand(LocalCourseAttribute attribute, | ||
LocalCourseContainsKeywordsPredicate predicate, | ||
String query) { | ||
this.attribute = attribute; | ||
this.predicate = predicate; | ||
this.query = query; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(SeplendidModel model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
model.searchLocalCourses(attribute, predicate); | ||
|
||
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(model.getFilteredLocalCourseList())), | ||
UiUtil.ListViewModel.LOCAL_COURSE_LIST); | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
throw new CommandException("TBD: this is a stub and should be removed after morph."); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
if (!(other instanceof LocalCourseSearchCommand)) { | ||
return false; | ||
} | ||
|
||
LocalCourseSearchCommand otherLocalCourseSearchCommand = (LocalCourseSearchCommand) other; | ||
return attribute == otherLocalCourseSearchCommand.attribute | ||
&& Objects.equals(predicate, otherLocalCourseSearchCommand.predicate) | ||
&& Objects.equals(query, otherLocalCourseSearchCommand.query); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this) | ||
.add("attribute", attribute) | ||
.add("predicate", predicate) | ||
.add("query", query) | ||
.toString(); | ||
} | ||
} | ||
|
3 changes: 2 additions & 1 deletion
3
...ogic/commands/LocalCourseSortCommand.java → ...s/localcourse/LocalCourseSortCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ess/logic/commands/MappingAddCommand.java → ...c/commands/mapping/MappingAddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ddress/logic/commands/MappingCommand.java → ...ogic/commands/mapping/MappingCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ss/logic/commands/MappingListCommand.java → .../commands/mapping/MappingListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../logic/commands/MappingSearchCommand.java → ...ommands/mapping/MappingSearchCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ddress/logic/commands/NoteAddCommand.java → ...s/logic/commands/note/NoteAddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...u/address/logic/commands/NoteCommand.java → ...ress/logic/commands/note/NoteCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ess/logic/commands/NoteDeleteCommand.java → ...ogic/commands/note/NoteDeleteCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...dress/logic/commands/NoteListCommand.java → .../logic/commands/note/NoteListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ess/logic/commands/NoteSearchCommand.java → ...ogic/commands/note/NoteSearchCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ddress/logic/commands/NoteTagCommand.java → ...s/logic/commands/note/NoteTagCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ess/logic/commands/NoteUpdateCommand.java → ...ogic/commands/note/NoteUpdateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...gic/commands/PartnerCourseAddCommand.java → ...artnercourse/PartnerCourseAddCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../logic/commands/PartnerCourseCommand.java → ...s/partnercourse/PartnerCourseCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ic/commands/PartnerCourseListCommand.java → ...rtnercourse/PartnerCourseListCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.