6
6
import seedu .address .commons .core .index .Index ;
7
7
import seedu .address .logic .commands .CommandResult ;
8
8
import seedu .address .logic .executors .exceptions .ExecuteException ;
9
- import seedu .address .model .person .Note ;
10
9
import seedu .address .model .person .Person ;
11
10
12
11
/**
13
12
* Executor for a PersonNoteCommand.
14
13
*/
15
14
public class PersonNoteExecutor extends PersonExecutor {
16
- public static final String MESSAGE_ADD_NOTE_SUCCESS = "Added note to Person: %1$s" ;
17
- public static final String MESSAGE_DELETE_NOTE_SUCCESS = "Removed note from Person: %1$s" ;
15
+ public static final String MESSAGE_OPEN_NOTE_SUCCESS = "Opened note to Person: %1$s" ;
18
16
19
- private final Note note ;
20
17
21
18
/**
22
19
* Constructor for a PersonNoteExecutor instance.
23
20
*
24
21
* @param index Index of the person to add a note to.
25
- * @param note Note to be added to the person.
22
+ *
26
23
*/
27
- public PersonNoteExecutor (Index index , Note note ) {
24
+ public PersonNoteExecutor (Index index ) {
28
25
super (index );
29
- requireAllNonNull (index , note );
30
- this .note = note ;
26
+ requireAllNonNull (index );
31
27
}
32
28
33
29
@ Override
34
30
public CommandResult execute () throws ExecuteException {
35
31
Person storedPerson = super .getPerson ();
36
32
Person editedPerson = new Person (
37
- storedPerson .getName (), storedPerson .getPhone (), storedPerson .getEmail (), note , storedPerson .getTags ());
33
+ storedPerson .getName (), storedPerson .getPhone (), storedPerson .getEmail (),
34
+ storedPerson .getNote (), storedPerson .getTags ());
38
35
39
36
model .setPerson (storedPerson , editedPerson );
40
37
model .updateFilteredPersonList (PREDICATE_SHOW_ALL_PERSONS );
41
38
42
- return new CommandResult (generateSuccessMessage (editedPerson ));
39
+ return new CommandResult (generateSuccessMessage (editedPerson ), false , true , editedPerson , false );
43
40
}
44
41
45
42
/**
46
43
* Generates a command execution success message based on whether
47
- * the note is added to or removed from
44
+ * the note is added.
48
45
* {@code personToEdit}.
49
46
*/
50
47
private String generateSuccessMessage (Person personToEdit ) {
51
- String message = !note .value .isEmpty () ? MESSAGE_ADD_NOTE_SUCCESS : MESSAGE_DELETE_NOTE_SUCCESS ;
52
- return String .format (message , personToEdit );
48
+ return String .format (MESSAGE_OPEN_NOTE_SUCCESS , personToEdit );
53
49
}
54
50
55
51
@ Override
@@ -67,6 +63,6 @@ public boolean equals(Object other) {
67
63
PersonNoteExecutor e = (PersonNoteExecutor ) other ;
68
64
69
65
// state check
70
- return super .equals (other ) && note . equals ( e . note ) ;
66
+ return super .equals (other );
71
67
}
72
68
}
0 commit comments