Skip to content

Commit

Permalink
Merge pull request #92 from jiakai-17/jiakai/store-task-status
Browse files Browse the repository at this point in the history
feat: Load and Store Task statuses
  • Loading branch information
freshcabbage123 authored Oct 20, 2023
2 parents 3e4212f + 905fd91 commit 449b758
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 127 deletions.
18 changes: 14 additions & 4 deletions src/main/java/seedu/address/storage/JsonAdaptedTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.task.Note;
import seedu.address.model.task.Status;
import seedu.address.model.task.Task;
import seedu.address.model.task.Title;

Expand All @@ -17,22 +18,27 @@ class JsonAdaptedTask {

private final String title;
private final String note;
private final boolean isDone;

/**
* Constructs a {@code JsonAdaptedTask} with the given task details.
*/
@JsonCreator
public JsonAdaptedTask(@JsonProperty("title") String title, @JsonProperty("note") String note) {
public JsonAdaptedTask(@JsonProperty("title") String title,
@JsonProperty("note") String note,
@JsonProperty("isDone") boolean isDone) {
this.title = title;
this.note = note;
this.isDone = isDone;
}

/**
* Converts a given {@code Task} into this class for Jackson use.
*/
public JsonAdaptedTask(Task source) {
title = source.getTitle().value;
note = source.getNote().value;
title = source.getTitle().toString();
note = source.getNote().toString();
isDone = source.getStatus().equals(Status.STATUS_DONE);
}

/**
Expand All @@ -57,6 +63,10 @@ public Task toModelType() throws IllegalValueException {
}
final Note modelNote = new Note(note);

return new Task(modelTitle, modelNote);
if (isDone) {
return new Task(modelTitle, modelNote, Status.STATUS_DONE);
}

return new Task(modelTitle, modelNote, Status.STATUS_NOT_DONE);
}
}
1 change: 0 additions & 1 deletion src/test/data/ConfigUtilTest/EmptyConfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{

}
6 changes: 3 additions & 3 deletions src/test/data/ConfigUtilTest/ExtraValuesConfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"logLevel" : "INFO",
"userPrefsFilePath" : "preferences.json",
"extra" : "extra value"
"logLevel": "INFO",
"userPrefsFilePath": "preferences.json",
"extra": "extra value"
}
4 changes: 2 additions & 2 deletions src/test/data/ConfigUtilTest/TypicalConfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"logLevel" : "INFO",
"userPrefsFilePath" : "preferences.json"
"logLevel": "INFO",
"userPrefsFilePath": "preferences.json"
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{
"persons": [ {
"name": "Valid Person",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
}, {
"name": "Person With Invalid Phone Field",
"phone": "948asdf2424",
"email": "[email protected]",
"address": "4th street"
} ],
"persons": [
{
"name": "Valid Person",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
},
{
"name": "Person With Invalid Phone Field",
"phone": "948asdf2424",
"email": "[email protected]",
"address": "4th street"
}
],
"tasks": []
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"persons": [ {
"name": "Person with invalid name field: Ha!ns Mu@ster",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
} ],
"persons": [
{
"name": "Person with invalid name field: Ha!ns Mu@ster",
"phone": "9482424",
"email": "[email protected]",
"address": "4th street"
}
],
"tasks": []
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
{
"persons": [ {
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"tags": [ "friends" ]
}, {
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "4th street"
} ],
"persons": [
{
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"tags": [
"friends"
]
},
{
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "4th street"
}
],
"tasks": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
"tasks": [
{
"title": "Prepare Agenda",
"note": "To book venue"
"note": "To book venue",
"isDone": true
},
{
"title": "Prepare Agenda",
"note": "To book venue"
"note": "To book venue",
"isDone": false
}
]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"persons": [ {
"name": "Hans Muster",
"phone": "9482424",
"email": "invalid@email!3e",
"address": "4th street"
} ],
"tasks" : []
"persons": [
{
"name": "Hans Muster",
"phone": "9482424",
"email": "invalid@email!3e",
"address": "4th street"
}
],
"tasks": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"tasks": [
{
"title": " Note the whitespace!",
"description": "Remember to throw error"
"description": "Remember to throw error",
"isDone": false
}
]
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,62 @@
{
"_comment": "AddressBook save file which contains the same Person values as in TypicalPersons#getTypicalAddressBook()",
"persons" : [ {
"name" : "Alice Pauline",
"phone" : "94351253",
"email" : "[email protected]",
"address" : "123, Jurong West Ave 6, #08-111",
"tags" : [ "friends" ]
}, {
"name" : "Benson Meier",
"phone" : "98765432",
"email" : "[email protected]",
"address" : "311, Clementi Ave 2, #02-25",
"tags" : [ "owesMoney", "friends" ]
}, {
"name" : "Carl Kurz",
"phone" : "95352563",
"email" : "[email protected]",
"address" : "wall street",
"tags" : [ ]
}, {
"name" : "Daniel Meier",
"phone" : "87652533",
"email" : "[email protected]",
"address" : "10th street",
"tags" : [ "friends" ]
}, {
"name" : "Elle Meyer",
"phone" : "9482224",
"email" : "[email protected]",
"address" : "michegan ave",
"tags" : [ ]
}, {
"name" : "Fiona Kunz",
"phone" : "9482427",
"email" : "[email protected]",
"address" : "little tokyo",
"tags" : [ ]
}, {
"name" : "George Best",
"phone" : "9482442",
"email" : "[email protected]",
"address" : "4th street",
"tags" : [ ]
} ],
"tasks" : []
"persons": [
{
"name": "Alice Pauline",
"phone": "94351253",
"email": "[email protected]",
"address": "123, Jurong West Ave 6, #08-111",
"tags": [
"friends"
]
},
{
"name": "Benson Meier",
"phone": "98765432",
"email": "[email protected]",
"address": "311, Clementi Ave 2, #02-25",
"tags": [
"owesMoney",
"friends"
]
},
{
"name": "Carl Kurz",
"phone": "95352563",
"email": "[email protected]",
"address": "wall street",
"tags": []
},
{
"name": "Daniel Meier",
"phone": "87652533",
"email": "[email protected]",
"address": "10th street",
"tags": [
"friends"
]
},
{
"name": "Elle Meyer",
"phone": "9482224",
"email": "[email protected]",
"address": "michegan ave",
"tags": []
},
{
"name": "Fiona Kunz",
"phone": "9482427",
"email": "[email protected]",
"address": "little tokyo",
"tags": []
},
{
"name": "George Best",
"phone": "9482442",
"email": "[email protected]",
"address": "4th street",
"tags": []
}
],
"tasks": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,48 @@
"tasks": [
{
"title": "Prepare Agenda",
"note": "To book venue"
"note": "To book venue",
"isDone": false
},
{
"title": "Prepare Budget",
"note": "For CS2102"
"note": "For CS2102",
"isDone": true
},
{
"title": "Book Catering",
"note": "For CS2101"
"note": "For CS2101",
"isDone": false
},
{
"title": "Send Budget and Draft",
"note": "For CS2100"
"note": "For CS2100",
"isDone": false
},
{
"title": "Book Entertainment",
"note": "For CS1101"
"note": "For CS1101",
"isDone": true
},
{
"title": "Prepare Funding",
"note": "For MA2001"
"note": "For MA2001",
"isDone": true
},
{
"title": "Prepare Guestlist",
"note": "For CS2103T"
"note": "For CS2103T",
"isDone": true
},
{
"title": "Ensure Hospitality",
"note": "For CS2103T"
"note": "For CS2103T",
"isDone": true
},
{
"title": "Send Invitations and Guestlist",
"note": "For CS2103T"
"note": "For CS2103T",
"isDone": false
}
]
}
1 change: 0 additions & 1 deletion src/test/data/JsonUserPrefsStorageTest/EmptyUserPrefs.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{

}
18 changes: 9 additions & 9 deletions src/test/data/JsonUserPrefsStorageTest/ExtraValuesUserPref.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"guiSettings" : {
"windowWidth" : 1000.0,
"windowHeight" : 500.0,
"extra" : "some value ",
"windowCoordinates" : {
"x" : 300,
"y" : 100,
"z" : 99
"guiSettings": {
"windowWidth": 1000.0,
"windowHeight": 500.0,
"extra": "some value ",
"windowCoordinates": {
"x": 300,
"y": 100,
"z": 99
}
},
"addressBookFilePath" : "addressbook.json"
"addressBookFilePath": "addressbook.json"
}
Loading

0 comments on commit 449b758

Please sign in to comment.