From 8ecc14db91e5b799fd311321d9dee15643c1307d Mon Sep 17 00:00:00 2001 From: schrom01 Date: Tue, 29 Nov 2022 12:19:45 +0100 Subject: [PATCH] Merged Notification Branch with Weather Branch --- .../backgroundtasks/BackgroundTasks.java | 9 ++++++++- .../weather/WeatherGradenTaskPlanner.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/BackgroundTasks.java b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/BackgroundTasks.java index bfa5571..33c58f6 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/BackgroundTasks.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/BackgroundTasks.java @@ -2,9 +2,11 @@ package ch.zhaw.gartenverwaltung.backgroundtasks; import ch.zhaw.gartenverwaltung.backgroundtasks.weather.WeatherGradenTaskPlanner; import ch.zhaw.gartenverwaltung.io.CropList; +import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException; import ch.zhaw.gartenverwaltung.io.PlantList; import ch.zhaw.gartenverwaltung.io.TaskList; import ch.zhaw.gartenverwaltung.models.Garden; +import ch.zhaw.gartenverwaltung.models.PlantNotFoundException; import javax.mail.MessagingException; import java.io.IOException; @@ -21,7 +23,12 @@ public class BackgroundTasks extends TimerTask { @Override public void run() { - // TODO uncomment: weatherGardenTaskPlaner.refreshTasks(); + try { + weatherGardenTaskPlaner.refreshTasks(); + } catch (IOException | HardinessZoneNotSetException | PlantNotFoundException e) { + e.printStackTrace(); + // TODO logger + } try { try { notifier.sendNotifications(); diff --git a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java index edf9d1e..16c327d 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java @@ -28,6 +28,7 @@ public class WeatherGradenTaskPlanner { public void refreshTasks() throws IOException, HardinessZoneNotSetException, PlantNotFoundException { getSevereWeatherEvents(); getRainAmount(); + System.out.println("refreshing Tasks"); } private void getSevereWeatherEvents() throws IOException { @@ -77,7 +78,6 @@ public class WeatherGradenTaskPlanner { for (Crop crop : cropList.getCrops()) { Plant plant = plantList.getPlantById(HardinessZone.ZONE_8A,crop.getPlantId()).orElseThrow(PlantNotFoundException::new); - // nur für aktuelle growthphase if(plant.wateringCycle().litersPerSqM() < rainAmount){ adjustNextExecutionOfWateringTask(taskList.getTaskList(LocalDate.now(), LocalDate.now().plusDays(7))); }