Skip to content

Commit

Permalink
Merge pull request #283 from sethteo/update-dg
Browse files Browse the repository at this point in the history
Update dg
  • Loading branch information
sethteo authored Apr 14, 2024
2 parents c7f17c4 + 658c8bb commit 7dc5130
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ title: Developer Guide
- 4.1.1. [Add Meeting feature](#add-meeting-feature)
- 4.1.2. [Edit Meeting feature](#edit-meeting-feature)
- 4.1.3. [Delete Meeting feature](#delete-meeting-feature)
- 4.1.4. [View Client feature](#view-client-feature)
- 4.2. [Release v1.3](#release-v13)
- 4.2.1 [Filter feature](#filter-feature)
5. [Appendix: Requirements](#appendix-requirements)
Expand Down Expand Up @@ -357,6 +358,53 @@ The following activity diagram summarises what happens when a user executes the
* More error-prone as the user needs to provide the date and time.
* Users have to type more to enter the date and time.

### View Client feature

#### Implementation

**The `ViewClientCommand` is implemented as such:**

- `LogicManager`'s execute method is called with the command string which then calls the `parseCommand()` method of `AddressBookParser`
- `AddressBookParser` then creates a `ViewCommandParser` which parses the user input and
returns a `ViewClientCommand`
- The created `ViewClientCommand` is then executed by the `LogicManager`
- `ViewClientCommand` filters through the list of `Person` based on the index provided by the user.
- `ViewClientCommand` creates a `CommandResult` object and returns it to `LogicManager`
- `LogicManager` then passes `CommandResult` to `UI` who then displays the new `Person` as well as the person's `Meetings`

**The `ViewCommandParser` is implemented as such:**

- Takes in a `String` input from the user
- Splits the given `String` based on the prefixes.
- If one or more prefixes are missing, throws `ParseException`
- Parser then checks if an empty string was provided
- If yes, throws `ParseException`
- Parser then checks if the prefix `c` is given
- If no, throws `ParseException`
- If no exception was thrown, the index corresponding to the `Person` is used to create a `ViewClientCommand` object

The following activity diagram summarises what happens when a user executes the `ViewClientCommand` command:

<img src="images/ViewClientActivityDiagram.png" width="700"/>

The following sequence diagram summarises what happens when a user executes the `ViewClientCommand` command:

<img src="images/ViewClientCommand.png" width="700"/>

<div markdown="span" class="alert alert-info">:information_source: **Note:** The lifelines for
`ViewCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifelines reach the end of the diagram.
</div>


#### Design considerations:

**Aspect: How ViewClientCommand executes:**

* **Alternative 1 (current choice):** Views the client based on the given index as well as a prefix `c`
- Pros:
* Easier to implement.
* Built in OOP fashion with a parent `ViewCommand` class, this allows us to expand to other `View` methods such as `ViewMeeting` in the future

### Release v1.3

### Filter feature
Expand Down
21 changes: 21 additions & 0 deletions docs/diagrams/ViewClientActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@startuml
skin rose
skinparam ActivityFontSize 15
skinparam ArrowFontSize 12
start
:User executes ViewClient command;

if () then ([No 'c' prefix])
-Error: Invalid command format
stop
else ([Valid prefix])
if () then ([invalid index])
-Error: The person index [invalid index] provided is invalid!
stop
else([valid index])
:Display client with specified index;
:Display client with specified index;
stop

endif
@enduml
92 changes: 92 additions & 0 deletions docs/diagrams/ViewClientCommand.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 ":ViewCommandParser" as ViewCommandParser LOGIC_COLOR
participant "v:ViewClientCommand" as ViewClientCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
participant "predicate:MeetingBelongingToClientPredicate" as MeetingBelongingToClientPredicate LOGIC_COLOR
end box

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

[-> LogicManager : execute("view c 1")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("view c 1")
activate AddressBookParser

create ViewCommandParser
AddressBookParser -> ViewCommandParser
activate ViewCommandParser

ViewCommandParser --> AddressBookParser
deactivate ViewCommandParser

AddressBookParser -> ViewCommandParser : parse("c 1")
activate ViewCommandParser

create ViewClientCommand
ViewCommandParser -> ViewClientCommand
activate ViewClientCommand

ViewClientCommand --> ViewCommandParser : v
deactivate ViewClientCommand

ViewCommandParser --> AddressBookParser : v
deactivate ViewCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
ViewCommandParser -[hidden]-> AddressBookParser
destroy ViewCommandParser

AddressBookParser --> LogicManager : v
deactivate AddressBookParser

LogicManager -> ViewClientCommand : execute()
activate ViewClientCommand

ViewClientCommand -> ModelManager : getFilteredPersonList()
activate ModelManager

ModelManager --> ViewClientCommand : lastShownList
deactivate ModelManager

ViewClientCommand -> ModelManager : updateFilteredPersonList(p -> p.equals(lastShownList.get(1)))
activate ModelManager

ModelManager --> ViewClientCommand
deactivate ModelManager

create MeetingBelongingToClientPredicate
ViewClientCommand -> MeetingBelongingToClientPredicate : new MeetingBelongingToClientPredicate(lastShownList.get(1))
activate MeetingBelongingToClientPredicate

MeetingBelongingToClientPredicate --> ViewClientCommand : predicate
deactivate MeetingBelongingToClientPredicate

ViewClientCommand -> ModelManager : updateFilteredMeetingList(predicate)
activate ModelManager

ModelManager --> ViewClientCommand
deactivate ModelManager

create CommandResult
ViewClientCommand -> CommandResult
activate CommandResult

CommandResult --> ViewClientCommand : r
deactivate CommandResult

ViewClientCommand --> LogicManager : r
deactivate ViewClientCommand
'Hidden arrow to position the destroy marker below the end of the activation bar.
ViewCommandParser -[hidden]-> LogicManager

[<-- LogicManager : r
deactivate LogicManager
@enduml
Binary file added docs/images/ViewClientActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ViewClientCommand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7dc5130

Please sign in to comment.