added Methods in TaskListModel
added Field Crop ID in Task added method removeTasksforCrop
This commit is contained in:
parent
007fc81b22
commit
d1d9d11b66
|
@ -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;
|
||||
|
@ -51,6 +52,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
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
"description": "Plant the seeds, crops in de bed.",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-05-01",
|
||||
"interval" : 0
|
||||
"interval" : 0,
|
||||
"cropID" : 0
|
||||
},
|
||||
{
|
||||
"id" : 2,
|
||||
|
@ -13,7 +14,8 @@
|
|||
"description": "water the plant, so that the soil is wet around the plant.",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-09-01",
|
||||
"interval" : 2
|
||||
"interval" : 2,
|
||||
"cropID" : 0
|
||||
},
|
||||
{
|
||||
"id" : 3,
|
||||
|
@ -21,7 +23,8 @@
|
|||
"description": "The fertilizer has to be mixed with water. Then fertilize the plants soil with the mixture",
|
||||
"startDate" : "2022-06-01",
|
||||
"endDate" : "2022-08-01",
|
||||
"interval" : 28
|
||||
"interval" : 28,
|
||||
"cropID" : 0
|
||||
},
|
||||
{
|
||||
"id" : 4,
|
||||
|
@ -29,7 +32,8 @@
|
|||
"description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage",
|
||||
"startDate" : "2022-07-01",
|
||||
"endDate" : "2022-07-01",
|
||||
"interval" : 0
|
||||
"interval" : 0,
|
||||
"cropID" : 0
|
||||
},
|
||||
{
|
||||
"id" : 5,
|
||||
|
@ -37,7 +41,8 @@
|
|||
"description": "Look for pest or illness at the leaves of the plant. Check the soil around the plant, if the roots are enough covered with soil",
|
||||
"startDate" : "2022-05-01",
|
||||
"endDate" : "2022-09-01",
|
||||
"interval" : 5
|
||||
"interval" : 5,
|
||||
"cropID" : 0
|
||||
},
|
||||
{
|
||||
"id" : 6,
|
||||
|
@ -45,6 +50,7 @@
|
|||
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
|
||||
"startDate" : "2022-09-01",
|
||||
"endDate" : "2022-09-01",
|
||||
"interval" : 0
|
||||
"interval" : 0,
|
||||
"cropID" : 0
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue