Skip to content

Commit 41ead77

Browse files
authored
Merge pull request #155
Update AddTag command sequence diagram
2 parents 6cb71cb + e79eb84 commit 41ead77

File tree

3 files changed

+99
-19
lines changed

3 files changed

+99
-19
lines changed
+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
@startuml
2+
!include style.puml
3+
skinparam ArrowFontStyle plain
4+
5+
box Logic LOGIC_COLOR_T1
6+
participant ":LogicManager" as LogicManager LOGIC_COLOR
7+
participant ":CampusConnectParser" as CampusConnectParser LOGIC_COLOR
8+
participant ":AddTagCommandParser" as AddTagCommandParser LOGIC_COLOR
9+
participant "a:AddTagCommand" as AddTagCommand LOGIC_COLOR
10+
participant "r:CommandResult" as CommandResult LOGIC_COLOR
11+
participant "m:Model" as Model MODEL_COLOR
12+
end box
13+
14+
[-> LogicManager : execute("addTag 2 t/mate")
15+
activate LogicManager
16+
17+
LogicManager -> CampusConnectParser : parseCommand("addTag 2 t/mate")
18+
activate CampusConnectParser
19+
20+
create AddTagCommandParser
21+
CampusConnectParser -> AddTagCommandParser
22+
activate AddTagCommandParser
23+
24+
AddTagCommandParser --> CampusConnectParser
25+
deactivate AddTagCommandParser
26+
27+
CampusConnectParser -> AddTagCommandParser: parse("2 t/mate")
28+
activate AddTagCommandParser
29+
30+
create AddTagCommand
31+
AddTagCommandParser -> AddTagCommand
32+
activate AddTagCommand
33+
34+
AddTagCommand --> AddTagCommandParser :
35+
deactivate AddTagCommand
36+
37+
AddTagCommandParser --> CampusConnectParser : addTagCommand
38+
AddTagCommandParser -[hidden]-> CampusConnectParser
39+
destroy AddTagCommandParser
40+
41+
CampusConnectParser --> LogicManager : addTagCommand
42+
deactivate CampusConnectParser
43+
44+
LogicManager -> AddTagCommand : execute(m)
45+
activate AddTagCommand
46+
47+
AddTagCommand -> Model : getFilteredPersonList()
48+
activate Model
49+
50+
Model --> AddTagCommand : lastShownList
51+
deactivate Model
52+
53+
AddTagCommand -> Model : get(index)
54+
activate Model
55+
56+
Model --> AddTagCommand : personToEdit
57+
deactivate Model
58+
59+
AddTagCommand -> AddTagCommand : createEditedPerson(personToEdit, addTagDescriptor)
60+
61+
AddTagCommand --> AddTagCommand : editedPerson
62+
63+
AddTagCommand -> Model : deletePerson(personToEdit)
64+
activate Model
65+
66+
Model --> AddTagCommand
67+
deactivate Model
68+
69+
AddTagCommand -> Model : insertPerson(editedPerson, index)
70+
activate Model
71+
72+
Model --> AddTagCommand
73+
deactivate Model
74+
75+
AddTagCommand -> Model : updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS)
76+
activate Model
77+
78+
Model --> AddTagCommand
79+
deactivate Model
80+
81+
create CommandResult
82+
AddTagCommand -> CommandResult
83+
activate CommandResult
84+
85+
CommandResult --> AddTagCommand : r
86+
deactivate CommandResult
87+
88+
AddTagCommand --> LogicManager
89+
deactivate AddTagCommand
90+
91+
[<-- LogicManager
92+
deactivate LogicManager
93+
@enduml

src/main/java/seedu/address/logic/commands/AddTagCommand.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public AddTagCommand(Index index, AddTagCommand.AddTagDescriptor addTagDescripto
5252

5353
@Override
5454
public CommandResult execute(Model model) throws CommandException {
55-
requireNonNull(model);
55+
assert model != null;
5656
List<Person> lastShownList = model.getFilteredPersonList();
5757

5858
if (index.getZeroBased() >= lastShownList.size()) {
@@ -77,9 +77,9 @@ public CommandResult execute(Model model) throws CommandException {
7777
private static Person createEditedPerson(Person personToEdit, AddTagCommand.AddTagDescriptor addTagDescriptor) {
7878
assert personToEdit != null;
7979

80-
Name updatedName = addTagDescriptor.getName().orElse(personToEdit.getName());
81-
Phone updatedPhone = addTagDescriptor.getPhone().orElse(personToEdit.getPhone());
82-
Email updatedEmail = addTagDescriptor.getEmail().orElse(personToEdit.getEmail());
80+
Name updatedName = personToEdit.getName();
81+
Phone updatedPhone = personToEdit.getPhone();
82+
Email updatedEmail = personToEdit.getEmail();
8383
Set<Tag> currentTags = personToEdit.getTags();
8484
Optional<Set<Tag>> optionalNewTags = addTagDescriptor.getTags();
8585
Set<Tag> updatedTags = new HashSet<Tag>();

src/main/java/seedu/address/logic/parser/AddTagCommandParser.java

+2-15
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import static java.util.Objects.requireNonNull;
44
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
5-
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
6-
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
7-
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
85
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
96

107
import java.util.Collection;
@@ -41,17 +38,7 @@ public AddTagCommand parse(String args) throws ParseException {
4138

4239
AddTagCommand.AddTagDescriptor addTagDescriptor = new AddTagCommand.AddTagDescriptor();
4340

44-
if (argMultimap.getValue(PREFIX_NAME).isPresent()) {
45-
addTagDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
46-
}
47-
if (argMultimap.getValue(PREFIX_PHONE).isPresent()) {
48-
addTagDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
49-
}
50-
if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
51-
addTagDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
52-
}
53-
54-
parseTagstoAdd(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(addTagDescriptor::setTags);
41+
parseTagsToAdd(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(addTagDescriptor::setTags);
5542

5643
return new AddTagCommand(index, addTagDescriptor);
5744
}
@@ -61,7 +48,7 @@ public AddTagCommand parse(String args) throws ParseException {
6148
* If {@code tags} contain only one element which is an empty string, it will be parsed into a
6249
* {@code Set<Tag>} containing zero tags.
6350
*/
64-
private Optional<Set<Tag>> parseTagstoAdd(Collection<String> tags) throws ParseException {
51+
private Optional<Set<Tag>> parseTagsToAdd(Collection<String> tags) throws ParseException {
6552
assert tags != null;
6653

6754
if (tags.isEmpty()) {

0 commit comments

Comments
 (0)