From ffc7f5174efd8877553110d91df4e26b894ac77a Mon Sep 17 00:00:00 2001 From: David Guler Date: Mon, 21 Nov 2022 09:15:29 +0100 Subject: [PATCH] fix: Properly saving tasks Tasks were not properly saved by the JsonTaskList, resulting in the newly created tasks being discarded immediately. Fixed by putting them into the taskMap in saveTask() --- .../gartenverwaltung/io/JsonTaskList.java | 1 + .../ch/zhaw/gartenverwaltung/io/plantdb.json | 6 +- .../ch/zhaw/gartenverwaltung/io/taskdb.json | 74 +++++++++---------- 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/io/JsonTaskList.java b/src/main/java/ch/zhaw/gartenverwaltung/io/JsonTaskList.java index 404489e..0920c34 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/io/JsonTaskList.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/io/JsonTaskList.java @@ -106,6 +106,7 @@ public class JsonTaskList implements TaskList { if(task.getId() == 0) { task.withId(idProvider.incrementAndGet()); } + taskMap.put(task.getId(), task); writeTaskListToFile(); } diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json b/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json index 5440e42..8cacaeb 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json +++ b/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json @@ -184,15 +184,14 @@ "litersPerSqM": 15, "interval": 4, "notes": [ - ] }, "taskTemplates": [ { - "name": "hilling", + "name": "Plant Sets", "relativeStartDate": 0, "relativeEndDate": 0, - "description": "Mound up the soil around the plant until just the top few leaves show above the soil. ", + "description": "Plant the sets about 5cm deep into the soil.", "interval": null, "isOptional": false } @@ -232,7 +231,6 @@ "litersPerSqM": 0, "interval": null, "notes": [ - ] }, "taskTemplates": [ diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/io/taskdb.json b/src/main/resources/ch/zhaw/gartenverwaltung/io/taskdb.json index ff69563..6d40011 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/io/taskdb.json +++ b/src/main/resources/ch/zhaw/gartenverwaltung/io/taskdb.json @@ -1,56 +1,56 @@ [ { - "id" : 1, - "name" : "sow plant", - "description": "Plant the seeds, crops in de bed.", - "startDate" : "2022-05-01", - "endDate" : "2022-05-01", - "interval" : 0, - "cropId" : 0 + "id": 1, + "name": "sow plant", + "description": "Plant the seeds, crops in de bed.", + "startDate": "2022-05-01", + "endDate": "2022-05-01", + "interval": 0, + "cropId": 0 }, { - "id" : 2, - "name" : "water plant", + "id": 2, + "name": "water plant", "description": "water the plant, so that the soil is wet around the plant.", - "startDate" : "2022-05-01", - "endDate" : "2022-09-01", - "interval" : 2, - "cropId" : 0 + "startDate": "2022-05-01", + "endDate": "2022-09-01", + "interval": 2, + "cropId": 0 }, { - "id" : 3, - "name" : "fertilize plant", + "id": 3, + "name": "fertilize plant", "description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture", - "startDate" : "2022-06-01", - "endDate" : "2022-08-01", - "interval" : 28, - "cropId" : 0 + "startDate": "2022-06-01", + "endDate": "2022-08-01", + "interval": 28, + "cropId": 0 }, { - "id" : 4, - "name" : "covering plant", + "id": 4, + "name": "covering plant", "description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage", - "startDate" : "2022-07-01", - "endDate" : "2022-07-01", - "interval" : 0, - "cropId" : 0 + "startDate": "2022-07-01", + "endDate": "2022-07-01", + "interval": 0, + "cropId": 0 }, { - "id" : 5, - "name" : "look after plant", + "id": 5, + "name": "look after plant", "description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil", - "startDate" : "2022-05-01", - "endDate" : "2022-09-01", - "interval" : 5, - "cropId" : 0 + "startDate": "2022-05-01", + "endDate": "2022-09-01", + "interval": 5, + "cropId": 0 }, { - "id" : 6, - "name" : "harvest plant", + "id": 6, + "name": "harvest plant", "description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ", - "startDate" : "2022-09-01", - "endDate" : "2022-09-01", - "interval" : 0, - "cropId" : 0 + "startDate": "2022-09-01", + "endDate": "2022-09-01", + "interval": 0, + "cropId": 0 } ] \ No newline at end of file