Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[T7][W11-C2] #117

Open
wants to merge 142 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
f130dff
Update README.md to point to updated Build Status
burnflare Oct 1, 2016
cfb9b81
Delete address, email and phone class from model
rachx Oct 3, 2016
1150601
Remove Phone, Email and Address object from Person class
rachx Oct 3, 2016
9ce954f
Remove Phone, Email and Address dependencies from ReadOnlyPerson inte…
rachx Oct 3, 2016
69fd489
Remove phone, email and address from XmlAdaptedPerson class in storage
rachx Oct 3, 2016
6f30a25
Remove phone, email and address from Add Command in logic
rachx Oct 3, 2016
45ae644
Update Parser to remove pattern matching and grouping for phone, emai…
rachx Oct 3, 2016
2f451bf
Remove phone, address and email from Personcard class in UI
rachx Oct 3, 2016
068c64a
Remove phone, email and address objects from Logic Manager Test class…
rachx Oct 3, 2016
f4aa565
Remove phone, email and address from TestUtil and Person Card Handle
rachx Oct 3, 2016
b3a9a78
Remove phone, address and email from person list card fxml
rachx Oct 3, 2016
88a286d
Update ContactUs.md
burnflare Oct 5, 2016
8a0aaad
Update user guide
burnflare Oct 5, 2016
43c179a
Update AboutUs.md
burnflare Oct 5, 2016
3d02db8
Rename all AddressBook related classes to Agendum Todo list
burnflare Oct 5, 2016
f0af50b
Update AboutUs.md (#16)
burnflare Oct 6, 2016
3d78803
Add a line in about us and rotated image (#19)
rachx Oct 6, 2016
5b82dcf
Restore section in user guide (#14)
INCENDE Oct 6, 2016
1e29e9b
Update Developer Guide (#20)
INCENDE Oct 7, 2016
680d8b1
Merge remote-tracking branch 'upstream/master'
burnflare Oct 8, 2016
8bfae07
Update coveralls badge in README.md
burnflare Oct 8, 2016
3299e58
Add time and isCompleted attributes and corresponding getter and sett…
rachx Oct 8, 2016
16540c7
Fix typo in message name constraints
rachx Oct 8, 2016
33f1047
Update the model to support mark command, update TestTask.java and ad…
rachx Oct 8, 2016
ea360f3
Add Mark command and update XmlAdaptedTask to show if a task is compl…
rachx Oct 8, 2016
82b7029
Add rename task and unmark task command. Add supporting unmark, renam…
rachx Oct 8, 2016
977b53f
Update class header comments for delete/mark/unmark (replace it's wit…
rachx Oct 8, 2016
55598b0
Select incorrect command text when there is an error (UI modification)
rachx Oct 8, 2016
84c1d5b
Update rename_args regex, remove unnecessay updateFilteredListToShowA…
rachx Oct 8, 2016
23cb5e4
Add completion status to TestTask and TaskBuilder
rachx Oct 8, 2016
e727475
Update ReadOnlyTask isSameStateAs comparison
rachx Oct 9, 2016
3943394
remove trailing whitespaces
rachx Oct 9, 2016
c19bad5
Rename expectedAB to expectedTDL in LogicManagerTest
rachx Oct 9, 2016
c9ebffe
Update isCompleted, startDateTime and endDateTime in TestTask constru…
rachx Oct 9, 2016
33af622
Update ReadOnlyTask isSameStateAs to account for null in startDateTim…
rachx Oct 9, 2016
f57f43f
Add GUI RenameCommandTest stub
rachx Oct 9, 2016
de310a2
Add MarkCommandTest stub
rachx Oct 9, 2016
78ec3f6
Rename constant in unmark command
rachx Oct 9, 2016
f084ba7
Update unique task list (unmark task function) to replace the unmarke…
rachx Oct 9, 2016
9658269
Add logic test for mark and unmark command
rachx Oct 9, 2016
fe5e060
Add test for rename command in logic component
rachx Oct 9, 2016
27ffff4
Remove trailing whitespaces
rachx Oct 9, 2016
eb0398c
Update rename command result
rachx Oct 9, 2016
0061f96
update ui to reflect marked/unmarked task
rachx Oct 9, 2016
9d9b5ea
remove (done) in task card ui
rachx Oct 10, 2016
c9c31f4
Remove isNotCompleted() method
rachx Oct 10, 2016
d37c4bd
revert ui changes
rachx Oct 10, 2016
1d32110
Use optionals for start and end date time
rachx Oct 10, 2016
21e70ec
update schedule task to use optionals
rachx Oct 10, 2016
ca48531
Update docs (#44)
INCENDE Oct 11, 2016
80d8f4d
Remove `/` delimiter for add commands (#56)
burnflare Oct 13, 2016
9f2b405
Update documentation (#59)
INCENDE Oct 14, 2016
b78d20f
Update readme
Oct 14, 2016
6690f6a
Update developer guide
Oct 14, 2016
2e94296
Update diagrams
Oct 14, 2016
13eb743
Update readme
Oct 14, 2016
816ee94
Update readme
Oct 14, 2016
c61df14
Update readme
Oct 14, 2016
6c430a4
Replace rename task and schedule task in model with update task.
rachx Oct 15, 2016
1940c51
Update Developer Guide (#72)
INCENDE Oct 17, 2016
6cc2721
update xml adapted task to store time
rachx Oct 15, 2016
bc51304
Remove tags support in Agendum (#74)
burnflare Oct 18, 2016
a5ec10d
Support multiple tasks marking unmarking and deleting (#64)
rachx Oct 18, 2016
ba8f4c1
Update guides (#82)
rachx Oct 19, 2016
1218386
Extend add command with time support (#49)
burnflare Oct 19, 2016
93c7da7
Store Command - Custom Storage Location (#46)
INCENDE Oct 19, 2016
58671b0
Support undo command (#73)
rachx Oct 19, 2016
7cf8f6f
Major UI Updates (#43)
burnflare Oct 19, 2016
596b55c
Update user guide and developer guide individual sections (#97)
rachx Oct 22, 2016
cb14475
Clean up model class and update Logic Manager Test to deal with sorte…
rachx Oct 22, 2016
8eb1e38
Diagrams for storage component (#99)
INCENDE Oct 23, 2016
bbd243a
Update logic manager test add logging for model (#101)
rachx Oct 23, 2016
a2267db
Modify store command (#96)
INCENDE Oct 23, 2016
6ea4e73
Add Codacy to Readme
burnflare Oct 23, 2016
8cafa51
Fix the logic between result pop up and mainwindow (#108)
fanwgwg Oct 25, 2016
a20eaa3
Tag author rachael (#109)
rachx Oct 25, 2016
7b54e20
Command line history (#102)
fanwgwg Oct 25, 2016
2ac246c
Tag author weiguang (#110)
fanwgwg Oct 25, 2016
a439421
Tag methods with author @burnflare
burnflare Oct 25, 2016
614aa8c
Merge branch 'master' of github.com:CS2103AUG2016-W11-C2/main
burnflare Oct 25, 2016
09ce26c
Load command (#92)
INCENDE Oct 26, 2016
2312264
Modify prepareAdd in Parser (#95)
rachx Oct 26, 2016
2a87483
Add collate (#116)
rachx Oct 26, 2016
3b3470f
Update store command (#121)
INCENDE Oct 26, 2016
20430b7
Update .travis.yml
burnflare Oct 27, 2016
e0cd08f
Smart command suggestion (#113)
burnflare Oct 27, 2016
e3526da
Use reflection instead of hardcoding a list of commands (#127)
burnflare Oct 27, 2016
6d0d840
Midnight time bug (#125)
burnflare Oct 27, 2016
33bb4af
save last updated time
rachx Oct 24, 2016
43a7b70
add absolute sign
rachx Oct 26, 2016
2a65992
Sort test tasks, make task builder create tasks with the same time, c…
rachx Oct 27, 2016
97eb806
add missing bracket
rachx Oct 27, 2016
65041a8
Sort help window results (#133)
burnflare Oct 27, 2016
04f91b1
Remove clear command (#135)
burnflare Oct 28, 2016
816d879
Remove unnecessary files from repo (#141)
burnflare Oct 28, 2016
f325aa6
Change addressbooklevel-4 to Agendum (#143)
INCENDE Oct 28, 2016
08750b5
Reorganise files created by agendum (#144)
INCENDE Oct 28, 2016
72e8c38
Add tab key for auto complete (#146)
fanwgwg Oct 28, 2016
0b5b116
Update helpwindow (#147)
fanwgwg Oct 28, 2016
332d47c
fix codacy suggestions (#112)
rachx Oct 29, 2016
d1c97c0
Update UserGuide.md (#154)
burnflare Oct 29, 2016
8e85531
Reset previous to do list stack after loading a new file (#157)
rachx Oct 29, 2016
1b4b450
More codacy improvements (#165)
burnflare Oct 30, 2016
4b8c469
Remove select command (#168)
INCENDE Oct 30, 2016
7fead99
Improve codacy score (#170)
burnflare Oct 30, 2016
403ae6f
Remove url util related files (#172)
INCENDE Oct 30, 2016
2e3b451
add sample data (#171)
INCENDE Oct 30, 2016
3da801b
Our 0.3/0.4 ui (#128)
rachx Oct 30, 2016
7b30b2b
Somw ui enhancement (#173)
fanwgwg Oct 30, 2016
68b66bd
Update messages of all commands (#151)
rachx Oct 30, 2016
2ff3016
sort by task time only if uncompleted (#186)
rachx Oct 31, 2016
261074c
Tag @burnflrae code to address #175
burnflare Nov 1, 2016
7ca3a2f
Fix code based on feedback (#187)
INCENDE Nov 1, 2016
7359380
Update model (#188)
rachx Nov 1, 2016
b65d1bc
Add alias command (#139)
rachx Nov 1, 2016
168f26e
Addressing a0148031r comments (#191)
fanwgwg Nov 1, 2016
4481f72
Helpwindow integration (#190)
fanwgwg Nov 1, 2016
4101954
Task highlighting (#179)
fanwgwg Nov 1, 2016
fbf9984
Addressing tutor comments (#189)
burnflare Nov 2, 2016
e78468e
Update collate
burnflare Nov 2, 2016
46c5cd3
Merge branch 'master' of github.com:CS2103AUG2016-W11-C2/main
burnflare Nov 2, 2016
a999708
Fix codacy error level problems (#196)
INCENDE Nov 3, 2016
31cc8a9
Change config filepath for tests (#195)
INCENDE Nov 4, 2016
6752567
Ui enhancements (#194)
fanwgwg Nov 5, 2016
284de28
Improve test coverage - Add unit tests (#174)
INCENDE Nov 5, 2016
ceff169
Code refactoring for A0133367E (#198)
rachx Nov 6, 2016
cef6251
Google Calendar Integration (#192)
burnflare Nov 6, 2016
9faec8f
Project file cleanup (#207)
burnflare Nov 6, 2016
1de625d
Run collate scripts again
burnflare Nov 6, 2016
d212718
Some tests updates (#210)
fanwgwg Nov 6, 2016
09305c5
Emegency patch: Disable GCal tests (#213)
burnflare Nov 6, 2016
51a8032
@burnflare's collate changes (#216)
burnflare Nov 6, 2016
519a0b8
Improve coverage for Command classes (#209)
burnflare Nov 6, 2016
1c6265b
more minor refactoring (#211)
rachx Nov 6, 2016
529a4b8
Fix AddParser (#204)
burnflare Nov 6, 2016
0834fc1
Manual testing folder (#205)
INCENDE Nov 7, 2016
541f948
update add command format message (#218)
rachx Nov 7, 2016
6b22f47
Some refactoring for the ui code (#215)
fanwgwg Nov 7, 2016
185b135
Address GCal Flaky tests (#214)
burnflare Nov 7, 2016
fb0f9c1
Update docs (#149)
INCENDE Nov 7, 2016
a82a738
Final project collation (#219)
burnflare Nov 7, 2016
274e017
Fix test scripts (#221)
rachx Nov 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update model (#188)
* solution?

* rename messages

* update unique task list to throw duplicate task exception

* update to do list for exceptions

* handle duplicate task exceptions in mark/unmark commands, rename methods in model/managers, rename logging messages

* sort based on last updated time

* remove nanoseconds

* minor change to comments
rachx authored Nov 1, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7359380af6dd93891031b3c3bf3ccf084c5ab8a2
2 changes: 1 addition & 1 deletion src/main/java/seedu/agendum/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public class AddCommand extends Command {
+ "from 7pm to 9pm";

public static final String MESSAGE_SUCCESS = "Task added: %1$s";
public static final String MESSAGE_DUPLICATE_TASK = "This task already exists!";
public static final String MESSAGE_DUPLICATE_TASK = "Hey, the task already exists";

private Task toAdd = null;

5 changes: 5 additions & 0 deletions src/main/java/seedu/agendum/logic/commands/MarkCommand.java
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import seedu.agendum.commons.core.Messages;
import seedu.agendum.commons.core.UnmodifiableObservableList;
import seedu.agendum.model.task.ReadOnlyTask;
import seedu.agendum.model.task.UniqueTaskList.DuplicateTaskException;
import seedu.agendum.model.task.UniqueTaskList.TaskNotFoundException;

/**
@@ -25,6 +26,7 @@ public class MarkCommand extends Command {
+ "Example: " + COMMAND_WORD + " 1 3 5-6";

public static final String MESSAGE_MARK_TASK_SUCCESS = "Marked Task(s): %1$s";
public static final String MESSAGE_DUPLICATE = "Hey, the task already exists";

public ArrayList<Integer> targetIndexes;

@@ -56,6 +58,9 @@ public CommandResult execute() {
model.markTasks(tasksToMark);
} catch (TaskNotFoundException pnfe) {
assert false : "The target task cannot be missing";
} catch (DuplicateTaskException pnfe) {
model.restoreCurrentToDoListClone();
return new CommandResult(MESSAGE_DUPLICATE);
}

return new CommandResult(String.format(MESSAGE_MARK_TASK_SUCCESS,
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ public class RenameCommand extends Command {
+ "Example: " + COMMAND_WORD + " 2 Watch Star Trek";

public static final String MESSAGE_SUCCESS = "Task #%1$s renamed: %2$s";
public static final String MESSAGE_DUPLICATE_TASK = "This task already exists!";
public static final String MESSAGE_DUPLICATE_TASK = "Hey, the task already exists";

public int targetIndex = -1;
public Name newTaskName = null;
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public class UndoCommand extends Command {
@Override
public CommandResult execute() {
assert model != null;
if (model.restorePreviousToDoList()) {
if (model.restorePreviousToDoListClone()) {
return new CommandResult(MESSAGE_SUCCESS);
} else {
return new CommandResult(MESSAGE_FAILURE);
5 changes: 5 additions & 0 deletions src/main/java/seedu/agendum/logic/commands/UnmarkCommand.java
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import seedu.agendum.commons.core.Messages;
import seedu.agendum.commons.core.UnmodifiableObservableList;
import seedu.agendum.model.task.ReadOnlyTask;
import seedu.agendum.model.task.UniqueTaskList.DuplicateTaskException;
import seedu.agendum.model.task.UniqueTaskList.TaskNotFoundException;

/**
@@ -25,6 +26,7 @@ public class UnmarkCommand extends Command {
+ "Example: " + COMMAND_WORD + " 11-13 15";

public static final String MESSAGE_UNMARK_TASK_SUCCESS = "Unmarked Task(s): %1$s";
public static final String MESSAGE_DUPLICATE = "Hey, the task already exists";

public ArrayList<Integer> targetIndexes;

@@ -56,6 +58,9 @@ public CommandResult execute() {
model.unmarkTasks(tasksToUnmark);
} catch (TaskNotFoundException pnfe) {
assert false : "The target task cannot be missing";
} catch (DuplicateTaskException pnfe) {
model.restoreCurrentToDoListClone();
return new CommandResult(MESSAGE_DUPLICATE);
}

return new CommandResult(String.format(MESSAGE_UNMARK_TASK_SUCCESS,
18 changes: 14 additions & 4 deletions src/main/java/seedu/agendum/model/Model.java
Original file line number Diff line number Diff line change
@@ -30,13 +30,23 @@ void updateTask(ReadOnlyTask target, Task updatedTask)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException;

/** Marks the given task(s) as completed */
void markTasks(List<ReadOnlyTask> targets) throws UniqueTaskList.TaskNotFoundException;
void markTasks(List<ReadOnlyTask> targets)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException;

/** Unmarks the given task(s) */
void unmarkTasks(List<ReadOnlyTask> targets) throws UniqueTaskList.TaskNotFoundException;
void unmarkTasks(List<ReadOnlyTask> targets)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException;

/**
* Restores the previous (second latest) to do list saved in the event of an undo operation
* Returns true if successful; false if there are no earlier lists
*/
boolean restorePreviousToDoListClone();

/** Restores the previous to do list saved. Returns true if successful; false if no previous saved list*/
boolean restorePreviousToDoList();
/**
* Restores the current (latest) to do list saved in the event of exceptions
*/
void restoreCurrentToDoListClone();

/** Returns the filtered task list as an {@code UnmodifiableObservableList<ReadOnlyTask>} */
UnmodifiableObservableList<ReadOnlyTask> getFilteredTaskList();
64 changes: 42 additions & 22 deletions src/main/java/seedu/agendum/model/ModelManager.java
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ public ModelManager(ToDoList src, UserPrefs userPrefs) {
filteredTasks = new FilteredList<>(toDoList.getTasks());
sortedTasks = filteredTasks.sorted();
previousLists = new Stack<>();
backupNewToDoList();
backupCurrentToDoList();
}

public ModelManager() {
@@ -62,15 +62,15 @@ public ModelManager(ReadOnlyToDoList initialData) {
filteredTasks = new FilteredList<>(toDoList.getTasks());
sortedTasks = filteredTasks.sorted();
previousLists = new Stack<>();
backupNewToDoList();
backupCurrentToDoList();
}

//@@author A0133367E
@Override
public void resetData(ReadOnlyToDoList newData) {
toDoList.resetData(newData);
logger.fine("[MODEL] --- succesfully reset data of the to-do list");
backupNewToDoList();
logger.fine("[MODEL] --- successfully reset data of the to-do list");
backupCurrentToDoList();
indicateToDoListChanged();
}

@@ -104,16 +104,16 @@ public synchronized void deleteTasks(List<ReadOnlyTask> targets) throws TaskNotF
for (ReadOnlyTask target: targets) {
toDoList.removeTask(target);
}
backupNewToDoList();
logger.fine("[MODEL] --- succesfully deleted all specified targets from the to-do list");
backupCurrentToDoList();
logger.fine("[MODEL] --- successfully deleted all specified targets from the to-do list");
indicateToDoListChanged();
}

@Override
public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskException {
toDoList.addTask(task);
logger.fine("[MODEL] --- succesfully added the new task to the to-do list");
backupNewToDoList();
logger.fine("[MODEL] --- successfully added the new task to the to-do list");
backupCurrentToDoList();
updateFilteredListToShowAll();
indicateToDoListChanged();
}
@@ -122,53 +122,73 @@ public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskE
public synchronized void updateTask(ReadOnlyTask target, Task updatedTask)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException {
toDoList.updateTask(target, updatedTask);
logger.fine("[MODEL] --- succesfully updated the target task in the to-do list");
backupNewToDoList();
logger.fine("[MODEL] --- successfully updated the target task in the to-do list");
backupCurrentToDoList();
updateFilteredListToShowAll();
indicateToDoListChanged();
}

@Override
public synchronized void markTasks(List<ReadOnlyTask> targets) throws TaskNotFoundException {
public synchronized void markTasks(List<ReadOnlyTask> targets)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException {
for (ReadOnlyTask target: targets) {
toDoList.markTask(target);
}
logger.fine("[MODEL] --- succesfully marked all specified targets from the to-do list");
backupNewToDoList();
logger.fine("[MODEL] --- successfully marked all specified targets from the to-do list");
backupCurrentToDoList();
indicateToDoListChanged();
}

@Override
public synchronized void unmarkTasks(List<ReadOnlyTask> targets) throws TaskNotFoundException {
public synchronized void unmarkTasks(List<ReadOnlyTask> targets)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException {
for (ReadOnlyTask target: targets) {
toDoList.unmarkTask(target);
}
logger.fine("[MODEL] --- succesfully unmarked all specified targets from the to-do list");
backupNewToDoList();
logger.fine("[MODEL] --- successfully unmarked all specified targets from the to-do list");
backupCurrentToDoList();
indicateToDoListChanged();
}

/**
* This is to restore the previous (second latest) list saved
* in the event of an "undo" operation
*/
@Override
public synchronized boolean restorePreviousToDoList() {
public synchronized boolean restorePreviousToDoListClone() {
assert !previousLists.empty();

if (previousLists.size() == 1) {
return false;
} else {
previousLists.pop();
toDoList.resetData(previousLists.peek());
logger.fine("[MODEL] --- succesfully restored the previous the to-do list from this session");
logger.fine("[MODEL] --- successfully restored the previous the to-do list from this session");
indicateToDoListChanged();
return true;
}
}

/**
* This is to reverse any temporary changes to the to-do list
* that have not been saved to storage or stack of previous lists (in the event of exceptions)
*/
@Override
public synchronized void restoreCurrentToDoListClone() {
assert !previousLists.empty();

logger.fine("[MODEL] --- successfully restored the current to-do list"
+ " before exceptions/temporary changes");

toDoList.resetData(previousLists.peek());
}

private void backupNewToDoList() {
private void backupCurrentToDoList() {
ToDoList latestList = new ToDoList(this.getToDoList());
previousLists.push(latestList);
}

private void clearPreviousToDoLists() {
private void clearAllPreviousToDoLists() {
previousLists.clear();
}

@@ -273,8 +293,8 @@ public String toString() {
public void handleLoadDataCompleteEvent(LoadDataCompleteEvent event) {
this.toDoList.resetData(event.data);
indicateToDoListChanged();
clearPreviousToDoLists();
backupNewToDoList();
clearAllPreviousToDoLists();
backupCurrentToDoList();
logger.info("Loading completed - Todolist updated.");
}
}
30 changes: 18 additions & 12 deletions src/main/java/seedu/agendum/model/ToDoList.java
Original file line number Diff line number Diff line change
@@ -89,20 +89,26 @@ public boolean updateTask(ReadOnlyTask key, Task updatedTask)
return tasks.update(key, updatedTask);
}

public boolean markTask(ReadOnlyTask key) throws UniqueTaskList.TaskNotFoundException {
if (tasks.mark(key)) {
return true;
} else {
throw new UniqueTaskList.TaskNotFoundException();
}
/**
* Marks an existing task in the to-do list.
* @throws UniqueTaskList.DuplicateTaskException if a duplicate task would result after marking key.
* @throws UniqueTaskList.TaskNotFoundException if no such task (key) could be found in the list.
*/
public boolean markTask(ReadOnlyTask key)
throws UniqueTaskList.TaskNotFoundException,
UniqueTaskList.DuplicateTaskException {
return tasks.mark(key);
}

public boolean unmarkTask(ReadOnlyTask key) throws UniqueTaskList.TaskNotFoundException {
if (tasks.unmark(key)) {
return true;
} else {
throw new UniqueTaskList.TaskNotFoundException();
}
/**
* Unmarks an existing task in the to-do list.
* @throws UniqueTaskList.DuplicateTaskException if a duplicate task would result after unmarking key.
* @throws UniqueTaskList.TaskNotFoundException if no such task (key) could be found in the list.
*/
public boolean unmarkTask(ReadOnlyTask key)
throws UniqueTaskList.TaskNotFoundException,
UniqueTaskList.DuplicateTaskException {
return tasks.unmark(key);
}
//@@author

7 changes: 1 addition & 6 deletions src/main/java/seedu/agendum/model/task/Task.java
Original file line number Diff line number Diff line change
@@ -155,7 +155,7 @@ public void setLastUpdatedTime(LocalDateTime updatedTime) {
}

public void setLastUpdatedTimeToNow() {
this.lastUpdatedTime = LocalDateTime.now();
this.lastUpdatedTime = LocalDateTime.now().withNano(0);
}

// ================ Other methods ==============================
@@ -204,11 +204,6 @@ public int compareTaskTime(Task other) {
}

public int compareLastUpdatedTime(Task other) {
// to fix erratic behavior for logic manager test
long seconds = ChronoUnit.SECONDS.between(this.getLastUpdatedTime(), other.getLastUpdatedTime());
if (Math.abs(seconds) < 2) {
return 0;
}
return other.getLastUpdatedTime().compareTo(this.getLastUpdatedTime());
}

32 changes: 9 additions & 23 deletions src/main/java/seedu/agendum/model/task/UniqueTaskList.java
Original file line number Diff line number Diff line change
@@ -121,48 +121,34 @@ public boolean update(ReadOnlyTask toUpdate, Task updatedTask)
* Marks the equivalent task in the list.
*
* @throws TaskNotFoundException if no such task could be found in the list.
* @throws DuplicateTaskException if a duplicate will result from marking the task
*/
public boolean mark(ReadOnlyTask toMark) throws TaskNotFoundException {
public boolean mark(ReadOnlyTask toMark) throws TaskNotFoundException, DuplicateTaskException {
assert toMark != null;

final int taskIndex = internalList.indexOf(toMark);
final boolean taskFoundAndMarked = (taskIndex != -1);

if (!taskFoundAndMarked) {
logger.fine("[TASK LIST] --- Missing Task: " + toMark.getDetailedText());
throw new TaskNotFoundException();
}
logger.fine("[TASK LIST] --- Attempt to Mark Task: " + toMark.getDetailedText());

Task markedTask = new Task(toMark);
markedTask.markAsCompleted();
internalList.set(taskIndex, markedTask);

logger.fine("[TASK LIST] --- Marked Task: " + markedTask.getDetailedText());

boolean taskFoundAndMarked = update(toMark, markedTask);

return taskFoundAndMarked;
}

/**
* Unmarks the equivalent task in the list.
*
* @throws TaskNotFoundException if no such task could be found in the list.
* @throws DuplicateTaskException if a duplicate will result from unmarking the task
*/
public boolean unmark(ReadOnlyTask toUnmark) throws TaskNotFoundException {
public boolean unmark(ReadOnlyTask toUnmark) throws TaskNotFoundException, DuplicateTaskException {
assert toUnmark != null;

final int taskIndex = internalList.indexOf(toUnmark);
final boolean taskFoundAndUnmarked = (taskIndex != -1);

if (!taskFoundAndUnmarked) {
logger.fine("[TASK LIST] --- Missing Task: " + toUnmark.getDetailedText());
throw new TaskNotFoundException();
}
logger.fine("[TASK LIST] --- Attempt to Unmark Task: " + toUnmark.getDetailedText());

Task unmarkedTask = new Task(toUnmark);
unmarkedTask.markAsUncompleted();
internalList.set(taskIndex, unmarkedTask);

logger.fine("[TASK LIST] --- Unmarked Task: " + unmarkedTask.getDetailedText());
boolean taskFoundAndUnmarked = update(toUnmark, unmarkedTask);

return taskFoundAndUnmarked;
}