Skip to content

Commit e46a93f

Browse files
authored
Merge pull request #230 from salty-flower/dg-addt/delt
Update DG for `add-t`/`delete-t`
2 parents 64f8d93 + bc074cd commit e46a93f

9 files changed

+236
-0
lines changed

docs/DeveloperGuide.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,37 @@ The following activity diagram shows the logic of the `help` command.
494494

495495
**Overview:**
496496

497+
The `add-t` command is used to add additional tags to an existing `Person` in ConnectUS specified by the user.
498+
499+
The format for the `add-t` command can be found [here](https://ay2223s2-cs2103t-w15-1.github.io/tp/UserGuide.html#46-adding-additional-tags-to-a-contact-add-t).
500+
501+
<div style="page-break-after: always"></div>
502+
497503
**Feature Details:**
498504

505+
1. The user specifies a person index that represents a `Person` to be edited, followed by the tag to be added.
506+
2. If a negative or zero index is provided, an error is thrown. The user is prompted to re-enter the command correctly.
507+
3. If the index is not in valid range of the contact list provided, an error is thrown. The user is prompted to re-enter the command correctly.
508+
4. The `Person` is cross-referenced in the `Model` to check if it already exists. If it does, then an error is raised as feedback to the user.
509+
5. If step 5 completes without exceptions, the new `Person` will be successfully edited and stored inside the contact list.
510+
511+
The following activity diagram shows the logic of the `add-t` command.
512+
513+
![AddTagToPersonCommandActivityDiagram](images/AddTagToPersonCommandActivityDiagram.png)
514+
515+
The sequence of the `add-t` command is as follows:
516+
517+
1. The command `add-t INPUT` is entered by the user, where the `INPUT` is an integer index followed by a tag to add (e.g. `add-t 1 r/friend`).
518+
2. `Logic Manager` calls the `ConnectUsParser#parseCommand` with the given `INPUT`
519+
3. `ConnectUsParser` parses the command word. creating an instance of `AddTagToPersonCommandParser` to `parse` the tags via the respective `ParserUtil` functions.
520+
4. `AddTagToPersonCommandParser` creates the corresponding `AddTagDescriptor` object. This `AddTagDescriptor` object is taken as the input of a new `AddTagToPersonCommand` object created by `AddTagToPersonCommandParser`.
521+
5. `Logic Manager` executes `AddTagToPersonCommand#execute`, creating a `Person` from the aforementioned`AddTagDescriptor` object and adding this `Person` to the model through `Model#setPerson`.
522+
6. `Model#updateFilteredPersonList` is called to update the list of `Person` objects.
523+
7. A `Command Result` is returned with the result of the execution.
524+
525+
The following sequence diagram shows how `add-t` works:
526+
527+
![AddTagToPersonCommandSequenceDiagram](images/AddTagToPersonCommandSequenceDiagram.png)
499528

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

@@ -507,8 +536,38 @@ The following activity diagram shows the logic of the `help` command.
507536

508537
**Overview:**
509538

539+
The `delete-t` command is used to delete individual tags from an existing `Person` in ConnectUS specified by the user.
540+
541+
The format for the `delete-t` command can be found [here](https://ay2223s2-cs2103t-w15-1.github.io/tp/UserGuide.html#47-deleting-tags-from-a-contact-delete-t).
542+
543+
<div style="page-break-after: always"></div>
544+
510545
**Feature Details:**
511546

547+
1. The user specifies a person index that represents a `Person` to be edited, followed by the tag index to be deleted.
548+
2. If a negative or zero index is provided, an error is thrown. The user is prompted to re-enter the command correctly.
549+
3. If the index is not in valid range of the contact list provided, an error is thrown. The user is prompted to re-enter the command correctly.
550+
4. The `Person` is cross-referenced in the `Model` to check if it already exists. If it does, then an error is raised as feedback to the user.
551+
5. If step 5 completes without exceptions, the tag of `Person` will be successfully deleted and this change will be stored inside the contact list.
552+
553+
The following activity diagram shows the logic of the `delete-t` command.
554+
555+
![DeleteTagFromPersonCommandActivityDiagram](images/DeleteTagFromPersonCommandActivityDiagram.png)
556+
557+
The sequence of the `delete-t` command is as follows:
558+
559+
1. The command `delete-t INPUT` is entered by the user, where the `INPUT` is an integer index followed by a tag index to delete (e.g. `delete-t 1 r/1`).
560+
2. `Logic Manager` calls the `ConnectUsParser#parseCommand` with the given `INPUT`
561+
3. `ConnectUsParser` parses the command word. creating an instance of `DeleteTagFromPersonCommandParser` to `parse` the tags via the respective `ParserUtil` functions.
562+
4. `DeleteTagFromPersonCommandParser` parses the corresponding tag indices. They are taken as the constructor arguments of a new `DeleteTagFromPersonCommand` object.
563+
5. `Logic Manager` executes `DeleteTagFromPersonCommand#execute`, creating a new `Person` with new tag lists from its parameters and replacing the original `Person` with this new `Person` in the model through `Model#setPerson`.
564+
6. `Model#updateFilteredPersonList` is called to update the list of `Person` objects.
565+
7. A `Command Result` is returned with the result of the execution.
566+
567+
The following sequence diagram shows how `delete-t` works:
568+
569+
![DeleteTagFromPersonCommandSequenceDiagram](images/DeleteTagFromPersonCommandSequenceDiagram.png)
570+
512571
[↑ Back to top of section](#4-implementation)
513572

514573
[↑ Back to table of contents](#table-of-contents)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@startuml
2+
!pragma useVerticalIf on
3+
start
4+
:User enters add-t command;
5+
if () then ([else])
6+
:Error: Invalid command format;
7+
stop
8+
([Person index is provided and valid]) elseif () then ([else])
9+
:Error: Invalid command format;
10+
stop
11+
else ([At least one tag is provided])
12+
endif
13+
:add-t command successfully executes.;
14+
stop
15+
16+
@enduml
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@startuml
2+
!include style.puml
3+
4+
skinparam defaultFontSize 40
5+
skinparam SequenceReferencebackgroundColor LightYellow
6+
7+
box Logic LOGIC_COLOR_T1
8+
participant ":LogicManager" as LogicManager LOGIC_COLOR
9+
participant ":ConnectUsParser" as ConnectUsParser LOGIC_COLOR
10+
participant ":AddTagToPersonCommandParser" as AddTagToPersonCommandParser LOGIC_COLOR
11+
participant ":AddTagToPersonCommand" as AddTagToPersonCommand LOGIC_COLOR
12+
participant ":CommandResult" as CommandResult LOGIC_COLOR
13+
end box
14+
15+
box Model MODEL_COLOR_T1
16+
participant ":AddTagDescriptor" as AddTagDescriptor MODEL_COLOR
17+
participant ":Person" as Person MODEL_COLOR
18+
participant ":Model" as Model MODEL_COLOR
19+
end box
20+
21+
[-> LogicManager : execute(input)
22+
activate LogicManager
23+
24+
LogicManager -> ConnectUsParser : parseCommand(input)
25+
activate ConnectUsParser
26+
27+
create AddTagToPersonCommandParser
28+
ConnectUsParser -> AddTagToPersonCommandParser++
29+
return
30+
31+
ConnectUsParser -> AddTagToPersonCommandParser : parse(args)
32+
activate AddTagToPersonCommandParser
33+
34+
create AddTagDescriptor
35+
AddTagToPersonCommandParser -> AddTagDescriptor++
36+
return addTagDescriptor
37+
38+
39+
create AddTagToPersonCommand
40+
AddTagToPersonCommandParser -> AddTagToPersonCommand++
41+
return
42+
43+
return addTagToPersonCommand
44+
destroy AddTagToPersonCommandParser
45+
46+
return addTagToPersonCommand
47+
48+
49+
LogicManager->AddTagToPersonCommand : execute(model)
50+
activate AddTagToPersonCommand
51+
52+
AddTagToPersonCommand -> Model : getFilteredPersonList()
53+
activate Model
54+
return
55+
56+
AddTagToPersonCommand -> AddTagToPersonCommand : createEditedPerson(personToEdit, addTagDescriptor)
57+
58+
AddTagToPersonCommand -> Model : setPerson(personToEdit, editedPerson)
59+
activate Model
60+
return
61+
62+
AddTagToPersonCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS)
63+
activate Model
64+
return
65+
66+
create CommandResult
67+
AddTagToPersonCommand ->CommandResult++
68+
return
69+
70+
return commandResult
71+
return
72+
73+
@enduml
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@startuml
2+
!pragma useVerticalIf on
3+
start
4+
:User enters delete-t command;
5+
if () then ([else])
6+
:Error: Invalid command format;
7+
stop
8+
([Person index is provided]) elseif () then ([else])
9+
:Error: Invalid command format;
10+
stop
11+
([All tag indices provided are valid]) elseif () then ([else])
12+
:Error: Invalid command format;
13+
stop
14+
else ([At least one tag index is provided])
15+
endif
16+
:delete-t command successfully executes.;
17+
stop
18+
19+
@enduml
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@startuml
2+
!include style.puml
3+
4+
skinparam defaultFontSize 40
5+
skinparam SequenceReferencebackgroundColor LightYellow
6+
7+
box Logic LOGIC_COLOR_T1
8+
participant ":LogicManager" as LogicManager LOGIC_COLOR
9+
participant ":ConnectUsParser" as ConnectUsParser LOGIC_COLOR
10+
participant ":DeleteTagFromPersonCommandParser" as DeleteTagFromPersonCommandParser LOGIC_COLOR
11+
participant ":DeleteTagFromPersonCommand" as DeleteTagFromPersonCommand LOGIC_COLOR
12+
participant ":CommandResult" as CommandResult LOGIC_COLOR
13+
end box
14+
15+
box Model MODEL_COLOR_T1
16+
participant ":Person" as Person MODEL_COLOR
17+
participant ":Model" as Model MODEL_COLOR
18+
end box
19+
20+
[-> LogicManager : execute(input)
21+
activate LogicManager
22+
23+
LogicManager -> ConnectUsParser : parseCommand(input)
24+
activate ConnectUsParser
25+
26+
create DeleteTagFromPersonCommandParser
27+
ConnectUsParser -> DeleteTagFromPersonCommandParser++
28+
return
29+
30+
ConnectUsParser -> DeleteTagFromPersonCommandParser : parse(args)
31+
activate DeleteTagFromPersonCommandParser
32+
33+
create DeleteTagFromPersonCommand
34+
DeleteTagFromPersonCommandParser -> DeleteTagFromPersonCommand++
35+
return
36+
37+
return DeleteTagFromPersonCommand
38+
destroy DeleteTagFromPersonCommandParser
39+
40+
return DeleteTagFromPersonCommand
41+
42+
43+
LogicManager->DeleteTagFromPersonCommand : execute(model)
44+
activate DeleteTagFromPersonCommand
45+
46+
DeleteTagFromPersonCommand -> Model : getFilteredPersonList()
47+
activate Model
48+
return
49+
50+
create Person
51+
DeleteTagFromPersonCommand -> Person++ : Person(personToEdit, editedRemarks, editedModules, editedCcas, editedMajors)
52+
return
53+
54+
DeleteTagFromPersonCommand -> Model : setPerson(personToEdit, editedPerson)
55+
activate Model
56+
return
57+
58+
DeleteTagFromPersonCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS)
59+
activate Model
60+
return
61+
62+
create CommandResult
63+
DeleteTagFromPersonCommand ->CommandResult++
64+
return
65+
66+
return commandResult
67+
return
68+
69+
@enduml
15.4 KB
Loading
176 KB
Loading
20.4 KB
Loading
172 KB
Loading

0 commit comments

Comments
 (0)