From 35346828ee3632c67033dc95a72d06cda9754ff0 Mon Sep 17 00:00:00 2001 From: gohyeeloon Date: Thu, 8 Oct 2020 12:59:48 +0800 Subject: [PATCH] Update Logic class to accomodate Meeting --- src/main/java/seedu/address/logic/Logic.java | 17 +++++++++++++++++ .../seedu/address/logic/LogicManager.java | 17 +++++++++++++++++ src/main/java/seedu/address/model/Model.java | 9 +++++++++ .../seedu/address/model/ModelManager.java | 19 +++++++++++++++++++ .../logic/commands/AddCommandTest.java | 10 ++++++++++ 5 files changed, 72 insertions(+) diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 92cd8fa605a..0cdf22f774e 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -8,6 +8,8 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyMeetingBook; +import seedu.address.model.meeting.Meeting; import seedu.address.model.person.Person; /** @@ -33,6 +35,21 @@ public interface Logic { /** Returns an unmodifiable view of the filtered list of persons */ ObservableList getFilteredPersonList(); + /** + * Returns the user prefs' meeting book file path. + */ + Path getMeetingBookFilePath(); + + /** + * Returns the MeetingBook. + * + * @see seedu.address.model.Model#getMeetingBook() + */ + ReadOnlyMeetingBook getMeetingBook(); + + /** Returns an unmodifiable view of the filtered list of meetings */ + ObservableList getFilteredMeetingList(); + /** * Returns the user prefs' address book file path. */ diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index 661ed8c1a6d..9cf927265cb 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -15,6 +15,8 @@ import seedu.address.logic.parser.exceptions.ParseException; import seedu.address.model.Model; import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyMeetingBook; +import seedu.address.model.meeting.Meeting; import seedu.address.model.person.Person; import seedu.address.storage.Storage; @@ -75,6 +77,21 @@ public ObservableList getFilteredPersonList() { return model.getFilteredPersonList(); } + @Override + public Path getMeetingBookFilePath() { + return model.getMeetingBookFilePath(); + } + + @Override + public ReadOnlyMeetingBook getMeetingBook() { + return model.getMeetingBook(); + } + + @Override + public ObservableList getFilteredMeetingList() { + return model.getFilteredMeetingList(); + } + @Override public Path getAddressBookFilePath() { return model.getAddressBookFilePath(); diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 0f53ad8d14c..6f2a6ca74c6 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -113,4 +113,13 @@ public interface Model { boolean hasMeeting(Meeting meeting); void addMeeting(Meeting meeting); + + /** Returns an unmodifiable view of the filtered meeting list */ + ObservableList getFilteredMeetingList(); + + /** + * Updates the filter of the filtered meeting list to filter by the given {@code predicate}. + * @throws NullPointerException if {@code predicate} is null. + */ + void updateFilteredMeetingList(Predicate predicate); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 9b6620b246f..dc5ff81324d 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -25,6 +25,7 @@ public class ModelManager implements Model { private final MeetingBook meetingBook; private final UserPrefs userPrefs; private final FilteredList filteredPersons; + private final FilteredList filteredMeetings; /** * Initializes a ModelManager with the given addressBook and userPrefs. @@ -41,6 +42,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyMeetingBook meeting this.meetingBook = new MeetingBook(meetingBook); this.userPrefs = new UserPrefs(userPrefs); filteredPersons = new FilteredList<>(this.addressBook.getPersonList()); + filteredMeetings = new FilteredList<>(this.meetingBook.getMeetingList()); } public ModelManager() { @@ -175,6 +177,23 @@ public void updateFilteredPersonList(Predicate predicate) { filteredPersons.setPredicate(predicate); } + //=========== Filtered Person List Accessors ============================================================= + + /** + * Returns an unmodifiable view of the list of {@code Person} backed by the internal list of + * {@code versionedAddressBook} + */ + @Override + public ObservableList getFilteredMeetingList() { + return filteredMeetings; + } + + @Override + public void updateFilteredMeetingList(Predicate predicate) { + requireNonNull(predicate); + filteredMeetings.setPredicate(predicate); + } + @Override public boolean equals(Object obj) { // short circuit if same object diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 152c89a1810..3eeee42944c 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -185,6 +185,16 @@ public Path getMeetingBookFilePath() { public void setMeetingBookFilePath(Path meetingBookFilePath) { throw new AssertionError("This method should not be called."); } + + @Override + public ObservableList getFilteredMeetingList() { + throw new AssertionError("This method should not be called."); + } + + @Override + public void updateFilteredMeetingList(Predicate predicate) { + throw new AssertionError("This method should not be called."); + } } /**