From 28f76e7a041d0d8c8922a229b771da1fdae32af5 Mon Sep 17 00:00:00 2001 From: Gian-Andrea Hutter Date: Mon, 5 Dec 2022 11:40:09 +0100 Subject: [PATCH] #23 documentation --- .../weather/WeatherGradenTaskPlanner.java | 46 +++++++++++++++++-- .../weather/WeatherService.java | 5 +- 2 files changed, 45 insertions(+), 6 deletions(-) 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 d36962a..ea9acfc 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherGradenTaskPlanner.java @@ -11,6 +11,10 @@ import java.io.IOException; import java.time.LocalDate; import java.util.List; +/** + * The WeatherGardenTaskPlanner creates Tasks based on weather events and the rain amount from the last days + * + */ public class WeatherGradenTaskPlanner { private final TaskList taskList; private final PlantList plantList; @@ -25,6 +29,12 @@ public class WeatherGradenTaskPlanner { weatherService = new WeatherService(); } + /** + * Method to refresh watering tasks and severe weather tasks + * @throws IOException If the database cannot be accessed + * @throws HardinessZoneNotSetException If the hardiness zone is not available + * @throws PlantNotFoundException if the plant is not available for the watering task + */ public void refreshTasks() throws IOException, HardinessZoneNotSetException, PlantNotFoundException { getSevereWeatherEvents(); getRainAmount(); @@ -46,7 +56,11 @@ public class WeatherGradenTaskPlanner { adjustWateringTask(rainAmount); } - public void createPreHailTask() throws IOException { + /** + * Method to create a PreHailTask + * @throws IOException If the database cannot be accessed + */ + private void createPreHailTask() throws IOException { Task preHailTask = new Task("Hail", "During a summer Thunderstorm it could hail heavily. THe Hail could damage the crops. To prevent damage cover the plants with a strong tarpaulin", @@ -55,21 +69,36 @@ public class WeatherGradenTaskPlanner { } - public void createPreFrostTask() throws IOException { + /** + * Method to create a PreFrosttask + * @throws IOException If the database cannot be accessed + */ + private void createPreFrostTask() throws IOException { Task preFrostTask = new Task("Frost", "The temperatur falls below zero degrees, cover especially the root with wool", dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L)); taskList.saveTask(preFrostTask); } - public void createPreSnowTask() throws IOException { + /** + * Method to create a PreSnowTask + * @throws IOException If the database cannot be accessed + */ + private void createPreSnowTask() throws IOException { Task preSnowTask = new Task("Snow", "The weather brings little snowfall. Cover your crops", dateSevereWeather.minusDays(1L),dateSevereWeather.plusDays(1L)); taskList.saveTask(preSnowTask); } - public void adjustWateringTask(int rainAmount) throws HardinessZoneNotSetException, IOException, PlantNotFoundException { + /** + * Method to adjust the water plant tasks + * @param rainAmount Amount of rain from the last 7 days + * @throws IOException If the database cannot be accessed + * @throws HardinessZoneNotSetException If the hardiness zone is not available + * @throws PlantNotFoundException if the plant is not available for the watering task + */ + private void adjustWateringTask(int rainAmount) throws HardinessZoneNotSetException, IOException, PlantNotFoundException { for (Crop crop : cropList.getCrops()) { Plant plant = plantList.getPlantById(HardinessZone.ZONE_8A,crop.getPlantId()).orElseThrow(PlantNotFoundException::new); @@ -80,7 +109,14 @@ public class WeatherGradenTaskPlanner { } } -// vom startdatum abhängig, + + /** + * Method to set next execution date of the water plant tasks + * @param cropTaskList List with tasks from crops + * @throws IOException If the database cannot be accessed + * @throws HardinessZoneNotSetException If the hardiness zone is not available + * @throws PlantNotFoundException if the plant is not available for the watering task + */ private void adjustNextExecutionOfWateringTasks(List cropTaskList){ for(Task task : cropTaskList){ if(task.getName().equals("water plant")){ diff --git a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java index 89fdf76..d189f11 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/backgroundtasks/weather/WeatherService.java @@ -1,5 +1,8 @@ package ch.zhaw.gartenverwaltung.backgroundtasks.weather; - +/** + * The WeatherService is a class to cause weather events for the WeatherGardenTaskPlanner + * + */ public class WeatherService { private static final int NO_RAIN = 0; private static final int LITTLE_RAIN = 15;