Merge remote-tracking branch 'origin/feature_taskList_m2' into feature_gardenplan-model_M2
# Conflicts: # src/main/resources/ch/zhaw/gartenverwaltung/io/taskdb.json
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package ch.zhaw.gartenverwaltung.io;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||
import ch.zhaw.gartenverwaltung.types.Task;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
|
||||
@@ -57,6 +58,16 @@ public class JsonTaskDatabase implements TaskDatabase{
|
||||
return taskMap.values().stream().filter(task -> task.isInTimePeriode(start, end)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getTaskForCrop(Crop crop) {
|
||||
return null; //TODO implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTasksForCrop(Crop crop) {
|
||||
// TODO implement
|
||||
}
|
||||
|
||||
/**
|
||||
* If no data is currently loaded, data is loaded from {@link #dataSource}.
|
||||
* If the {@link Task} has an id than the task is added to the {@link #taskMap}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ch.zhaw.gartenverwaltung.io;
|
||||
|
||||
import ch.zhaw.gartenverwaltung.types.Crop;
|
||||
import ch.zhaw.gartenverwaltung.types.HardinessZone;
|
||||
import ch.zhaw.gartenverwaltung.types.Plant;
|
||||
import ch.zhaw.gartenverwaltung.types.Task;
|
||||
@@ -24,6 +25,10 @@ public interface TaskDatabase {
|
||||
*/
|
||||
List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException;
|
||||
|
||||
List<Task> getTaskForCrop(Crop crop); //TODO Javadoc
|
||||
|
||||
void removeTasksForCrop(Crop crop); // TODO Javadoc
|
||||
|
||||
/**
|
||||
* Saves the {@link Task} in the Cache.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package ch.zhaw.gartenverwaltung.taskList;
|
||||
|
||||
public class PlantNotFoundException extends Exception {
|
||||
public PlantNotFoundException() {
|
||||
super("The selected Plant was not found in Database!");
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TaskListModel {
|
||||
@@ -34,13 +35,18 @@ public class TaskListModel {
|
||||
taskDatabase.saveTask(task);
|
||||
}
|
||||
|
||||
public void planTasksForCrop(Crop crop) throws HardinessZoneNotSetException, IOException {
|
||||
Plant plant = plantDatabase.getPlantById(HardinessZone.ZONE_8A, crop.getPlantId()).orElseThrow();
|
||||
public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException {
|
||||
Plant plant = plantDatabase.getPlantById(HardinessZone.ZONE_8A, crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
|
||||
// TODO new exception
|
||||
// TODO HArdiness Zone
|
||||
return;
|
||||
}
|
||||
|
||||
public void removeTasksForCrop(Crop crop) {
|
||||
//TODO implement
|
||||
taskDatabase.removeTasksForCrop(crop);
|
||||
}
|
||||
|
||||
public void removeTask(Task task) throws IOException {
|
||||
taskDatabase.removeTask(task);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Task {
|
||||
private final LocalDate startDate;
|
||||
private Integer interval;
|
||||
private LocalDate endDate;
|
||||
private Crop cropId;
|
||||
|
||||
/**
|
||||
* default constructor
|
||||
|
||||
Reference in New Issue
Block a user