Merge remote-tracking branch 'origin/feature_taskList_m2' into feature_gardenplan-model_M2
This commit is contained in:
commit
521f3ae025
|
@ -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