#23 add Task generation watertask

This commit is contained in:
Gian-Andrea Hutter 2022-11-27 23:42:29 +01:00
parent 4072308ae6
commit 233ce6b088
3 changed files with 10 additions and 8 deletions

View File

@ -1,12 +1,7 @@
package ch.zhaw.gartenverwaltung.bootstrap; package ch.zhaw.gartenverwaltung.bootstrap;
import ch.zhaw.gartenverwaltung.HelloApplication; import ch.zhaw.gartenverwaltung.HelloApplication;
import ch.zhaw.gartenverwaltung.io.CropList; import ch.zhaw.gartenverwaltung.io.*;
import ch.zhaw.gartenverwaltung.io.JsonCropList;
import ch.zhaw.gartenverwaltung.io.JsonPlantList;
import ch.zhaw.gartenverwaltung.io.JsonTaskList;
import ch.zhaw.gartenverwaltung.io.PlantList;
import ch.zhaw.gartenverwaltung.io.TaskList;
import ch.zhaw.gartenverwaltung.models.Garden; import ch.zhaw.gartenverwaltung.models.Garden;
import ch.zhaw.gartenverwaltung.models.GardenSchedule; import ch.zhaw.gartenverwaltung.models.GardenSchedule;
import ch.zhaw.gartenverwaltung.models.PlantListModel; import ch.zhaw.gartenverwaltung.models.PlantListModel;
@ -37,6 +32,7 @@ public class AppLoader {
private final TaskList taskList = new JsonTaskList(); private final TaskList taskList = new JsonTaskList();
private final GardenSchedule gardenSchedule = new GardenSchedule(taskList, plantList); private final GardenSchedule gardenSchedule = new GardenSchedule(taskList, plantList);
private final WeatherGradenTaskPlanner weatherGradenTaskPlanner = new WeatherGradenTaskPlanner(taskList,plantList,cropList);
private final Garden garden = new Garden(gardenSchedule, cropList); private final Garden garden = new Garden(gardenSchedule, cropList);

View File

@ -52,9 +52,14 @@ public class GardenSchedule {
for (GrowthPhase growthPhase : plant.lifecycleForGroup(growPhaseGroup)) { for (GrowthPhase growthPhase : plant.lifecycleForGroup(growPhaseGroup)) {
for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) { for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) {
addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L))); addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L)));
//TODO add wateringtask
}
//TODO add wateringtask
if(growthPhase.wateringCycle() != null){
addTask(new Task("watering Task", "pour water over the plant circa : "+ growthPhase.wateringCycle().litersPerSqM() +" per square meter",
growthPhase.startDate().atYear(LocalDate.now().getYear()), growthPhase.endDate().atYear(LocalDate.now().getYear()),
growthPhase.wateringCycle().interval(), crop.getCropId().orElse(0L)));
} }
//growthPhase.wateringCycle()
} }
} }

View File

@ -39,6 +39,7 @@ public class Task {
nextExecution = startDate; nextExecution = startDate;
this.cropId = cropId; this.cropId = cropId;
} }
/** /**
* Constructor for weather events * Constructor for weather events
*/ */