Skip to content

Commit

Permalink
Merge pull request AY2324S1-CS2103-F13-4#52 from Fallman2/branch-Upda…
Browse files Browse the repository at this point in the history
…teDG

Update DG for Fiilter and DeleteEvent commands
  • Loading branch information
nicrandomlee authored Oct 26, 2023
2 parents 6cbda32 + 0810cfe commit 8c76081
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,66 @@ _{more aspects and alternatives to be added}_

_{Explain here how the data archiving feature will be implemented}_

### Contact Filtering

#### Implementation

The filtering function executed by `FilterCommand` is facilitated by the `PersonFilter` class.
which itself is similar to the `EditPersonDescriptor` class found in `EditCommand.java`. It stores the fields by which
the contacts are to be filtered and creates a predicate to facilitate the filtering. Notably, it implements the
following operation:

* `PersonFilter#matchesFilter(Person)` - Compares the values of the attributes of the `Person` to the strings stored as
attributes in the `PersonFilter` object. This method is later used as a lambda method to filter the contact list.

Given below is an example of how the filter function works at each step.

Step 1. The user executes `filter n/Bob t/CS` to filter contacts to see only people with "Bob" in their name and have at
least 1 tag with "CS" in it. The input is passed to `UniMateParser` which then parses it with the `FilterCommandParser`.

Step 2. The `FilterCommandParser` parses the input and creates a corresponding `PersonFilter` object with null for all
parameters. It then sets all specified attributes of the created `PersonFilter` while leaving unspecified fields as
null. The `FilterCommandParser` finally returns a newly created `FilterCommand` with the PersonFilter used in the
constructor.

Step 3. `FilterCommand#execute` is called. In this method, `model#updateFilteredPersonList` is called with
`PersonFilter#matchesFilter` being used as the predicate. This updates the GUI and populates the filtered list with
only `Person` objects that match the filter.

Step 4. The number of people displayed is returned as a `CommandResult`.

### Deleting Events

### Implementation

The deletion of events is facilitated by the `model::deleteEventAt` method and the `model::findEventAt` method. The
former method deletes the event stored in the `Calendar` object which itself is an attribute of the `Model` object by
calling a similar method `Calendar::deleteEventAt`. These methods take in a `LocalDateTime` object and finds the method
within the `Calendar` object, then in the case of `model::deleteEventAt`, deletes the event. Given below is an example
usage scenario of the command.

Step 1. The user launches the application and creates an event.

Step 2. The user executes `deleteEvent 2023-12-09 12:00` command to delete the event at that time. The `deleteEvent`
command calls `Model#findEventAt(LocalDateTime)` to find an event at the specified date and time. This event is then stored as a
variable `toDelete`.

**Note**: If no event is found at the specified date and time at any point of the command execution, an
`EventNotFoundException` is thrown which causes an error message to be displayed.

Step 3. The command then calls `Model#deleteEventAt(LocalDateTime)`. This method calls similar methods of
`Calendar#deleteEventAt(LocalDateTime)` which calls `AllDaysEventListManager#deleteEventAt(LocalDateTime)`.

Step 4. The `AllDaysEventListManager` checks for an event at the specified date and time again, then checks for all days
for which the event lasts for. Then, for each day, the event is removed from the `SingleDayEventList`.

Step 5. The deleted event which was previously stored in as a variable is displayed in the `CommandResult` to show the
user which command was deleted.

**Design considerations**

* The design of the `deleteEvent` command is dependent on the structure of the `Calendar` object. Should the structure
of how the event objects are stored change, a new implementation will be required for the command.

--------------------------------------------------------------------------------------------------------------------

Expand Down

0 comments on commit 8c76081

Please sign in to comment.