Merge remote-tracking branch 'origin/feature_taskList_m2' into feature_gardenplan-model_M2

# Conflicts:
#	src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskDatabaseTest.java
This commit is contained in:
Gian-Andrea Hutter
2022-11-04 07:39:57 +01:00
7 changed files with 147 additions and 80 deletions
@@ -58,14 +58,29 @@ public class JsonTaskDatabase implements TaskDatabase{
return taskMap.values().stream().filter(task -> task.isInTimePeriode(start, end)).toList();
}
/**
* Method get all Tasks for a specific Crop
* @param cropId the cropId
* @return List of Tasks for given Crop
*/
@Override
public List<Task> getTaskForCrop(Crop crop) {
return null; //TODO implement
public List<Task> getTaskForCrop(long cropId) throws IOException {
if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
return taskMap.values().stream().filter(task -> task.getCropId() == cropId).toList();
}
/**
* Method remove all Tasks for a specific Crop
* @param cropId the crop
*/
@Override
public void removeTasksForCrop(Crop crop) {
// TODO implement
public void removeTasksForCrop(long cropId) throws IOException {
if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
taskMap.values().removeIf(task -> task.getCropId() == cropId);
}
/**
@@ -25,9 +25,20 @@ public interface TaskDatabase {
*/
List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException;
List<Task> getTaskForCrop(Crop crop); //TODO Javadoc
/**
* Method get all Tasks for a specific Crop
* @param cropId the cropId
* @return List of Tasks for given Crop
* @throws IOException If the database cannot be accessed
*/
List<Task> getTaskForCrop(long cropId) throws IOException;
void removeTasksForCrop(Crop crop); // TODO Javadoc
/**
* Method remove all Tasks for a specific Crop
* @param cropId the cropId
* @throws IOException If the database cannot be accessed
*/
void removeTasksForCrop(long cropId) throws IOException;
/**
* Saves the {@link Task} in the Cache.