Skip to content

Commit

Permalink
Merge pull request #206 from larrywang0701/milestone-1.4
Browse files Browse the repository at this point in the history
Bug fix and add diagrams for list event
  • Loading branch information
Nixx162 authored Nov 13, 2023
2 parents 4c3797d + cdf7314 commit bd75c86
Show file tree
Hide file tree
Showing 15 changed files with 349 additions and 27 deletions.
28 changes: 25 additions & 3 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,20 @@ The following activity diagram summarizes what happens when the `DeleteNoteComma
This feature allows users to add and remove `Event` to any `Person` in the contact list. It provides an easy way for users to keep track of events with the contacts.

#### Overview: Event:
The adding and removing of `Event` begins with the parsing of the `AddEventCommand` and `DeleteEventCommand` using the `AddEventCommandParser` and `DeleteEventCommandParser` respectively.
The `AddEventCommand` and `DeleteEventCommand` will then be constructed and executed by the `Model`.
The adding, listing and removing of `Event` begins with the parsing of the `AddEventCommand`, `ListEventCommand` and `DeleteEventCommand` using the `AddEventCommandParser`, `ListEventCommandParser` and `DeleteEventCommandParser` respectively.
The `AddEventCommand`, `ListEventCommand` and `DeleteEventCommand` will then be constructed and executed by the `Model`.

The activity diagram below shows the action sequence of adding an `Event` to a contact.

<puml src="diagrams/event/EventSequenceDiagram.puml"/>
<puml src="diagrams/event/AddEventSequenceDiagram.puml"/>

The activity diagram below shows the action sequence of listing events by executing `list events` command.

<puml src="diagrams/event/ListEventsSequenceDiagram.puml"/>

The activity diagram below shows the action sequence of deleting an event by contact ID and event ID.

<puml src="diagrams/event/DeleteEventSequenceDiagram.puml"/>

<box type="info" seamless>

Expand Down Expand Up @@ -454,6 +462,20 @@ The following activity diagram summarizes what happens when `AddEventCommand` is

<puml src="diagrams/event/AddEventActivityDiagram.puml"/>

##### Implementing `ListEventCommand`
`ListEventCommand` extends from the abstract class `ListCommand`,
inheriting `list` as the primary command word and having `events` as its secondary command word.
It internally stores `filterStartTime`, `filterEndTime` (both can be null if filtering is not used) and `sortAscending` which are given by the [parser](#implementing-addeventcommandparser).

When the command is executed, it carries out the following operations:
1. Using the `filterStartTime` and `filterEndTime` to filter all events in the global event list, or set the filter to always returns `true` if both `filterStartTime` and `filterEndTime` is null (in order to show the full event list to the user)
2. Sort the filtered event list in ascending or descending order based on `sortAscending`
3. Lastly a `CommandResult` with the filtered-sorted event list in String and with `listEvent = true` to tell `MainWindow` to show the event list window.

The following activity diagram summarizes what happens when user executes `list events` from UI.

<puml src="diagrams/event/ListEventsActivityDiagram.puml"/>

##### Implementing `DeleteEventCommand`
`DeleteEventCommand` extends from the abstract class `DeleteCommand`,
inheriting `delete` as the primary command word and having `event` as its secondary command word.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ activate AddEventCommandParser
AddEventCommandParser -> AddCommandParser
deactivate AddEventCommandParser

AddCommandParser -> AddEventCommandParser : parse(commandText)
AddCommandParser -> AddEventCommandParser : parse(args)
activate AddEventCommandParser

create AddEventCommand
Expand All @@ -61,17 +61,22 @@ destroy AddCommandParser
AddressBookParser --> LogicManager
deactivate AddressBookParser

LogicManager -> AddEventCommand : execute()
LogicManager --> AddEventCommand : execute()
activate AddEventCommand

AddEventCommand -> Model: findPersonByUserFriendlyId(contactId)
AddEventCommand --> Model: findPersonByUserFriendlyId(contactId)
activate Model

Model -> AddEventCommand: person
Model --> AddEventCommand: person
deactivate Model

AddEventCommand --> Model: addEvent(toAdd, owner)
activate Model
AddEventCommand <-- Model
deactivate Model

create CommandResult
AddEventCommand -> CommandResult
AddEventCommand --> CommandResult
activate CommandResult

CommandResult --> AddEventCommand : commandResult
Expand Down
92 changes: 92 additions & 0 deletions docs/diagrams/event/DeleteEventSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
@startuml
!include ../style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":DeleteCommandParser" as DeleteCommandParser LOGIC_COLOR
participant ":DeleteEventCommandParser" as DeleteEventCommandParser LOGIC_COLOR
participant ":DeleteEventCommand" as DeleteEventCommand LOGIC_COLOR
participant "commandResult:CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box

[-> LogicManager : execute(commandText)
activate LogicManager

LogicManager -> AddressBookParser : parseCommand(commandText)
activate AddressBookParser

create DeleteCommandParser
AddressBookParser -> DeleteCommandParser
activate DeleteCommandParser

DeleteCommandParser --> AddressBookParser
deactivate DeleteCommandParser

AddressBookParser -> DeleteCommandParser : parse(commandText)
activate DeleteCommandParser

create DeleteEventCommandParser
DeleteCommandParser -> DeleteEventCommandParser
activate DeleteEventCommandParser

DeleteEventCommandParser -> DeleteCommandParser
deactivate DeleteEventCommandParser

DeleteCommandParser -> DeleteEventCommandParser : parse(args)
activate DeleteEventCommandParser

create DeleteEventCommand
DeleteEventCommandParser -> DeleteEventCommand
activate DeleteEventCommand

DeleteEventCommand --> DeleteEventCommandParser
deactivate DeleteEventCommand

DeleteEventCommandParser --> DeleteCommandParser
deactivate DeleteEventCommandParser
DeleteEventCommandParser -[hidden]-> DeleteCommandParser
destroy DeleteEventCommandParser

DeleteCommandParser --> AddressBookParser
deactivate DeleteCommandParser
DeleteCommandParser -[hidden]-> AddressBookParser
destroy DeleteCommandParser

AddressBookParser --> LogicManager
deactivate AddressBookParser

LogicManager -> DeleteEventCommand : execute()
activate DeleteEventCommand

DeleteEventCommand -> Model: findPersonByUserFriendlyId(contactId)
activate Model

Model -> DeleteEventCommand: person
deactivate Model

DeleteEventCommand --> Model : removeEventByID(eventID, owner)
activate Model
DeleteEventCommand <-- Model
deactivate Model

create CommandResult
DeleteEventCommand -> CommandResult
activate CommandResult

CommandResult --> DeleteEventCommand : commandResult
deactivate CommandResult

DeleteEventCommand --> LogicManager : commandResult
deactivate DeleteEventCommand
DeleteEventCommand -[hidden]-> LogicManager
destroy DeleteEventCommand

[<--LogicManager : commandResult
deactivate LogicManager
@enduml
28 changes: 28 additions & 0 deletions docs/diagrams/event/ListEventsActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@startuml
skin rose
skinparam ActivityFontSize 15
skinparam ArrowFontSize 12
start
:User executes list event command;

if () then ([both exist -st and -et argument or neither exists -st nor -et argument])
if () then ([exist -st argument])
if() then([valid start time and end time])
:Filter the event based on start and end time;
else ([else])
:Throw CommandException;
endif
else ([else])
endif
if () then ([exists -descending argument])
:Sort events in descending order;
else ([else])
:Sort events in ascending order;
endif
:Returns Result message;
:Open a new window to display the event list;
else ([else])
:Throw CommandException;
endif
stop
@enduml
116 changes: 116 additions & 0 deletions docs/diagrams/event/ListEventsSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
@startuml
!include ../style.puml
skinparam ArrowFontStyle plain

box UI UI_COLOR_T1
participant ":MainWindow" as MainWindow UI_COLOR
participant ":EventListWindow" as EventListWindow UI_COLOR
end box

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":ListCommandParser" as ListCommandParser LOGIC_COLOR
participant ":ListEventCommandParser" as ListEventCommandParser LOGIC_COLOR
participant ":ListEventCommand" as ListEventCommand LOGIC_COLOR
participant "commandResult:CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box

-> MainWindow : executeCommand(commandText)
activate MainWindow
MainWindow -> LogicManager : execute(commandText)
activate LogicManager

LogicManager -> AddressBookParser : parseCommand(commandText)
activate AddressBookParser

create ListCommandParser
AddressBookParser -> ListCommandParser
activate ListCommandParser

ListCommandParser --> AddressBookParser
deactivate ListCommandParser

AddressBookParser -> ListCommandParser : parse(commandText)
activate ListCommandParser

create ListEventCommandParser
ListCommandParser -> ListEventCommandParser
activate ListEventCommandParser

ListEventCommandParser -> ListCommandParser
deactivate ListEventCommandParser

ListCommandParser -> ListEventCommandParser : parse(args)
activate ListEventCommandParser

create ListEventCommand
ListEventCommandParser -> ListEventCommand
activate ListEventCommand

ListEventCommand --> ListEventCommandParser
deactivate ListEventCommand

ListEventCommandParser --> ListCommandParser
deactivate ListEventCommandParser
ListEventCommandParser -[hidden]-> ListCommandParser
destroy ListEventCommandParser

ListCommandParser --> AddressBookParser
deactivate ListCommandParser
ListCommandParser -[hidden]-> AddressBookParser
destroy ListCommandParser

AddressBookParser --> LogicManager
deactivate AddressBookParser

LogicManager -> ListEventCommand : execute()
activate ListEventCommand

ListEventCommand -> Model: updateFilteredEventList(predicate)
activate Model

Model -> ListEventCommand
deactivate Model

ListEventCommand -> Model: generateSortedFilteredEventList(comparator)
activate Model
ListEventCommand <- Model : sortedFilteredEventList
deactivate Model

create CommandResult
ListEventCommand -> CommandResult
activate CommandResult

CommandResult --> ListEventCommand : commandResult
deactivate CommandResult

ListEventCommand --> LogicManager : commandResult
deactivate ListEventCommand
ListEventCommand -[hidden]-> LogicManager
destroy ListEventCommand

MainWindow <-- LogicManager : commandResult
deactivate LogicManager
MainWindow --> MainWindow : handleEventList()
activate MainWindow
MainWindow --> LogicManager : getSortedFilteredEventList()
activate LogicManager
LogicManager --> Model : getSortedFilteredEventList()
activate Model
LogicManager <-- Model : sortedFilteredEventList
deactivate Model
MainWindow <-- LogicManager : sortedFilteredEventList
deactivate LogicManager
MainWindow --> EventListWindow : show(events)
activate EventListWindow
MainWindow <-- EventListWindow
deactivate EventListWindow
deactivate MainWindow
destroy CommandResult
[<--MainWindow
@enduml
12 changes: 4 additions & 8 deletions docs/team/larrywang0701.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
- #### Enhancements implemented
- Enhanced the logic of command parser to support secondary command word [#33](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/33)


- #### Contributions to the UG

- During drafting stage: Wrote the command formats for most of the commands in the user guide draft.
Expand All @@ -38,10 +37,11 @@

- Wrote the User Stories part in the DG [#10](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/10)
- Add details about secondary command parser in DG [#47](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/47/files#diff-1a95edf069a4136e9cb71bee758b0dc86996f6051f0d438ec2c424557de7160b)
- UML diagrams that I made: [#206](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/206)
<puml src="diagrams/event/ListEventsSequenceDiagram.puml"/>
<puml src="diagrams/event/ListEventsActivityDiagram.puml"/>
<puml src="diagrams/event/DeleteEventSequenceDiagram.puml"/>

- #### Contributions to team-based tasks

- to be added soon

- #### Review/mentoring contributions

Expand All @@ -50,7 +50,3 @@
- [#69](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/69)
- [#163](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/163)
- [#168](https://github.com/AY2324S1-CS2103T-W16-1/tp/pull/168)

- #### Contributions beyond the project team

- to be added soon
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of events */
ObservableList<Event> getFilteredEventList();

ObservableList<Event> getSortedFilteredEventList();

/**
* Returns the user prefs' address book file path.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public ObservableList<Event> getFilteredEventList() {
return model.getFilteredEventList();
}

@Override
public ObservableList<Event> getSortedFilteredEventList() {
return model.getSortedFilteredEventList();
}

@Override
public Path getAddressBookFilePath() {
return model.getAddressBookFilePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public CommandResult execute(Model model) throws CommandException {
result = MESSAGE_FILTERED;
}
result += this.sortAscending ? MESSAGE_ASCENDING : MESSAGE_DESCENDING;
List<Event> eventList = model.getSortedFilteredEventList((o1, o2) -> {
List<Event> eventList = model.generateSortedFilteredEventList((o1, o2) -> {
LocalDateTime startTime1 = o1.getStartTime();
LocalDateTime startTime2 = o2.getStartTime();
return (startTime1.isBefore(startTime2)
Expand Down
Loading

0 comments on commit bd75c86

Please sign in to comment.