From 2ec37114de94b1222d3692065a4fd6d4847afcf7 Mon Sep 17 00:00:00 2001 From: giavaphi Date: Sun, 27 Nov 2022 21:56:12 +0100 Subject: [PATCH] quick fix task end date can not be null + test data --- .../TaskFormularController.java | 1 + .../gartenverwaltung/types/TaskTemplate.java | 2 +- .../ch/zhaw/gartenverwaltung/io/plantdb.json | 81 +++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/TaskFormularController.java b/src/main/java/ch/zhaw/gartenverwaltung/TaskFormularController.java index b4bb93b..6c46aba 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/TaskFormularController.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/TaskFormularController.java @@ -135,6 +135,7 @@ public class TaskFormularController implements Initializable { }); button.disableProperty().bind(start_datePicker.valueProperty().isNull() + .or(end_datePicker.valueProperty().isNull()) .or(taskName_field.textProperty().isEmpty()) .or(description_area.textProperty().isEmpty())); } diff --git a/src/main/java/ch/zhaw/gartenverwaltung/types/TaskTemplate.java b/src/main/java/ch/zhaw/gartenverwaltung/types/TaskTemplate.java index b2cb06f..9a3d57d 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/types/TaskTemplate.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/types/TaskTemplate.java @@ -42,7 +42,7 @@ public class TaskTemplate { } public Task generateTask(LocalDate realStartDate, long cropId) { - LocalDate endDate = relativeEndDate != null ? realStartDate.plusDays(relativeEndDate) : null; + LocalDate endDate = relativeEndDate != null ? realStartDate.plusDays(relativeEndDate) : realStartDate.plusDays(0); if (interval == null) { this.interval = 0; diff --git a/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json b/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json index fac9a5b..ec76a31 100644 --- a/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json +++ b/src/main/resources/ch/zhaw/gartenverwaltung/io/plantdb.json @@ -245,5 +245,86 @@ "measures": "less water" } ] + }, + { + "id": 3, + "name": "Test Potato", + "description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.", + "light": 6, + "spacing": "35", + "soil": "sandy", + "image": "potato.jpg", + "pests": [ + { + "name": "Rot", + "description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.", + "measures": "Less water." + } + ], + "lifecycle": [ + { + "startDate": "12-01", + "endDate": "12-02", + "type": "SOW", + "zone": "ZONE_8A", + "group": 0, + "wateringCycle": { + "litersPerSqM": 0, + "interval": null, + "notes": [] + }, + "taskTemplates": [ + { + "name": "Germinate", + "relativeStartDate": -3, + "relativeEndDate": 0, + "description": "Take an egg carton and fill it with soil. Put the seedling deep enough so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.", + "interval": null + } + ] + }, + { + "startDate": "12-03", + "endDate": "12-15", + "type": "PLANT", + "zone": "ZONE_8A", + "group": 0, + "wateringCycle": { + "litersPerSqM": 25, + "interval": 7, + "notes": [] + }, + "taskTemplates": [ + { + "name": "hilling", + "relativeStartDate": 0, + "relativeEndDate": 10, + "description": "When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.", + "interval": 3 + } + ] + }, + { + "startDate": "12-16", + "endDate": "12-18", + "type": "HARVEST", + "zone": "ZONE_8A", + "group": 0, + "wateringCycle": { + "litersPerSqM": 0, + "interval": null, + "notes": [] + }, + "taskTemplates": [ + { + "name": "Harvest", + "relativeStartDate": 0, + "relativeEndDate": 4, + "description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.", + "interval": null + } + ] + } + ] } ]