Merged Notification Branch with Weather Branch
This commit is contained in:
		
							parent
							
								
									c16f99aabc
								
							
						
					
					
						commit
						8ecc14db91
					
				| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)));
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue