Skip to content

Commit

Permalink
Merge pull request #238 from Lava-Iris/edit-documentation
Browse files Browse the repository at this point in the history
Edit documentation
  • Loading branch information
gremmyz authored Apr 9, 2023
2 parents e46a93f + 10b5063 commit f8686b8
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 11 deletions.
32 changes: 31 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ The following sequence diagram shows how `add` works:

The `edit` command is used to change the information of an existing `Person` in ConnectUS with the information fields specified by the user, namely the `Name`, `Phone`, `Email`, `Address`, `Birthday`, `Social Media` (i.e. Telegram, Instagram, WhatsApp), and `Birthday` fields.

The format for the `edit` command can be found [here](https://ay2223s2-cs2103t-w15-1.github.io/tp/UserGuide.html#editing-a-person--edit).
The format for the `edit` command can be found [here](https://ay2223s2-cs2103t-w15-1.github.io/tp/UserGuide.html#45-editing-a-contact-edit).

<div style="page-break-after: always"></div>

Expand Down Expand Up @@ -578,14 +578,44 @@ The following sequence diagram shows how `delete-t` works:

**Overview:**

The `search` command is used to search ConnectUS for all `Person`s for whom the specified keyword matches the specified field information in the `Name`, `Phone`, `Email`, `Address`, `Birthday`, `Social Media` (i.e. Telegram, Instagram, WhatsApp), `Birthday` and `tag` (`Module`, `CCA`, `Major`, `Remarks`) fields. If no field is specified, the command searches ConnectUS for all `Person`s for whom the specified keyword matches any of the information fields.

The format for the `search` command can be found [here](https://ay2223s2-cs2103t-w15-1.github.io/tp/UserGuide.html#49-searching-for-contact-information-search).

**Feature Details:**

1. The user specifies keywords to search ConnectUS with.
2. At least one keyword must be provided. If no keyword is provided, an error is thrown. The user is prompted to re-enter the command correctly.
3. All fields provided must have a keyword associated. If an empty field is provided, an error is thrown. The user is prompted to re-enter the command correctly.
4. Every `Person` in the `Model` is tested against the specified keywords. If all the keywords with fields match the corresponding information fields, and the keywords without fields match at least one information field, the `Person` is displayed. If any of the keywords do not match, the `Person` is filtered out.

The following activity diagram shows the logic of searching for in the contact list.

![SearchCommandActivityDiagram](images/SearchCommandActivityDiagram.png)

The sequence of the `search` command is as follows:

1. The command `search INPUT` is entered by the user, where the `INPUT` is optional keywords without fields followed by keywords with fields (e.g. `search alex cca/chess`).
2. `Logic Manager` calls the `ConnectUsParser#parseCommand` with the given `INPUT`
3. `ConnectUsParser` parses the command word. creating an instance of `SearchCommandParser` to `parse` the `informationFields` via the respective `ParserUtil` functions.
4. `SearchCommandParser` creates the corresponding `FieldsContainKeywordsPredicate` object. This `FieldsContainKeywordsPredicate` object is taken as the input of a new `SearchCommand` object created by `SearchCommandParser`.
5. `Logic Manager` executes `SearchCommand#execute`, updating the filtered person list of the model using the `model#updateFilteredPersonList` with the `FieldsContainKeywordsPredicate` object used to create the `SearchCommand` as the argument.
6. The `FieldsContainKeywordsPredicate#test` matches each keyword with the information fields of the `Person` object being tested. If any keyword does not match, the `Person` object fails the test.
7. A `Command Result` is returned with the result of the execution.

The following sequence diagram shows how `search` works:
![SearchCommandSequenceDiagram](images/SearchCommandSequenceDiagram.png)

The following sequence diagram provides details on how the `informationFields` are being parsed by `ParserUtil`:
![SearchCommandParseInformationFieldsSequenceDiagram](images/SearchCommandParseInformationFieldsDiagram.png)

[↑ Back to top of section](#4-implementation)

[↑ Back to table of contents](#table-of-contents)

<div style="page-break-after: always"></div>


## 4.8 Upcoming Birthdays Command

**Overview:**
Expand Down
2 changes: 1 addition & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ Format: `search [KEYWORD]... [n/NAME_KEYWORD] [p/PHONE_KEYWORD] [e/EMAIL_KEYWORD

> For keywords without a specified field, finds all contacts whose information from any field contains the given keywords.<br>For keywords in a specified field, finds all contacts whose field contains given keyword.
There are 2 methods in which you can search for a contact.
There are 2 methods which you can use concurrently to search for a contact.

**Method 1:**

Expand Down
8 changes: 4 additions & 4 deletions docs/diagrams/AddCommandActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@startuml
!pragma useVerticalIf on
start
:User enters add command;
if () then ([else])
:User enters new command;
if () then ( [else])
:Error: Invalid command format;
stop
([Person name is provided and arguments are valid]) elseif () then ([else])
( [Person name is provided and arguments are valid]) elseif () then ( [else])
:Error: Person already exists;
stop
else ([Person does not exist in Contact List])
else ( [Person does not exist in Contact List])
endif
:add command successfully executes.;
stop
Expand Down
10 changes: 5 additions & 5 deletions docs/diagrams/EditCommandActivityDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
!pragma useVerticalIf on
start
:User enters edit command;
if () then ([else])
if () then ( [else])
:Error: Invalid index provided;
stop
([Positive index provided]) elseif () then ([else])
( [Positive index provided]) elseif () then ( [else])
:Error: Invalid command format;
stop
([at least one field to be edited is provided]) elseif () then ([else])
( [at least one field to be edited is provided]) elseif () then ( [else])
:Error: Invalid index provided;
stop
([Person index is in valid range of contact list])elseif () then ([else])
( [Person index is in valid range of contact list])elseif () then ( [else])
:Error: Person already exists in the contact list;
stop
else ([Edited Person does not share a name with any other Persons])
else ( [Edited Person does not share a name with any other Persons])
endif
:Edit command successfully executes.
Person is successfully edited.;
Expand Down
17 changes: 17 additions & 0 deletions docs/diagrams/SearchCommandActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@startuml
!pragma useVerticalIf on

:User enters search command;
if () then ( [else])
:Error: Invalid command provided;
stop
( [At least one keyword is provided]) elseif () then ( [else])
:Error: Invalid command format;
stop
else ( [Keyword is provided for every field mentioned])
endif
:Search command successfully executes.
Filtered list based on given keywords is displayed.;
stop

@enduml
26 changes: 26 additions & 0 deletions docs/diagrams/SearchCommandParseInformationFieldsDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@startuml
!include style.puml
mainframe **ref** Parse Information Fields

skinparam defaultFontSize 15
skinparam titleFontSize 15

box Logic LOGIC_COLOR_T1
participant ":SearchCommandParser" as SearchCommandParser LOGIC_COLOR
participant "FieldsContainKeywordsPredicate" as FieldsContainKeywordsPredicate LOGIC_COLOR
end box

activate SearchCommandParser

opt ifPreamblePresent
SearchCommandParser->FieldsContainKeywordsPredicate:setKeywords(keywords)
activate FieldsContainKeywordsPredicate
return
end
opt ifFieldPrefixPresent
SearchCommandParser->FieldsContainKeywordsPredicate:setField(fieldKeyword)
activate FieldsContainKeywordsPredicate
return
end

@enduml
65 changes: 65 additions & 0 deletions docs/diagrams/SearchCommandSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@startuml
!include style.puml

skinparam defaultFontSize 15
skinparam SequenceReferencebackgroundColor LightYellow

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":ConnectUsParser" as ConnectUsParser LOGIC_COLOR
participant ":SearchCommandParser" as SearchCommandParser LOGIC_COLOR
participant ":SearchCommand" as SearchCommand LOGIC_COLOR
participant ":CommandResult" as CommandResult LOGIC_COLOR
end box

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

[-> LogicManager : execute(input)
activate LogicManager

LogicManager -> ConnectUsParser : parseCommand(input)
activate ConnectUsParser

create SearchCommandParser
ConnectUsParser -> SearchCommandParser++
return

ConnectUsParser -> SearchCommandParser:parse(args)
activate SearchCommandParser

ref over SearchCommandParser
Search Parse Args
end

create FieldsContainKeywordsPredicate
SearchCommandParser -> FieldsContainKeywordsPredicate++
return e

create SearchCommand
SearchCommandParser -> SearchCommand++

return
return searchCommand
destroy SearchCommandParser
return searchCommand

LogicManager->SearchCommand : execute(model)
activate SearchCommand

SearchCommand -> Model : updateFilteredPersonList(fieldsContainKeywordsPredicate)
activate Model
return

create CommandResult
SearchCommand ->CommandResult++
return

return commandResult
return

@enduml

Binary file added docs/images/SearchCommandActivityDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/SearchCommandSequenceDiagram.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 f8686b8

Please sign in to comment.