added Method planTasksForCrop
This commit is contained in:
parent
25057d34f0
commit
007fc81b22
|
@ -1,7 +1,12 @@
|
|||
package ch.zhaw.gartenverwaltung.taskList;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
|
||||
import ch.zhaw.gartenverwaltung.io.JsonTaskDatabase;
|
||||
import ch.zhaw.gartenverwaltung.io.PlantDatabase;
|
||||
import ch.zhaw.gartenverwaltung.io.TaskDatabase;
|
||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||
import ch.zhaw.gartenverwaltung.types.Task;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -12,23 +17,30 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class TaskListModel {
|
||||
private TaskDatabase taskDatabase;
|
||||
private PlantDatabase plantDatabase;
|
||||
|
||||
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
|
||||
|
||||
|
||||
|
||||
public TaskListModel(){
|
||||
taskDatabase = new JsonTaskDatabase();
|
||||
}
|
||||
|
||||
public TaskListModel(TaskDatabase taskDatabase) {
|
||||
public TaskListModel(TaskDatabase taskDatabase, PlantDatabase plantDatabase) {
|
||||
this.taskDatabase = taskDatabase;
|
||||
this.plantDatabase = plantDatabase;
|
||||
}
|
||||
|
||||
public void addTask(Task task) throws IOException {
|
||||
taskDatabase.saveTask(task);
|
||||
}
|
||||
|
||||
public void planTasksForCrop(Crop crop) throws HardinessZoneNotSetException, IOException {
|
||||
Plant plant = plantDatabase.getPlantById(HardinessZone.ZONE_8A, crop.getPlantId()).orElseThrow();
|
||||
// TODO new exception
|
||||
// TODO HArdiness Zone
|
||||
return;
|
||||
}
|
||||
|
||||
public void removeTask(Task task) throws IOException {
|
||||
taskDatabase.removeTask(task);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue