#27 gardenplanmodel bugfixed cropid
This commit is contained in:
parent
d45b8e116e
commit
2361afd537
|
@ -12,9 +12,9 @@ import ch.zhaw.gartenverwaltung.types.Task;
|
|||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@ public class Gardenplanmodel {
|
|||
private GardenPlan gardenPlan;
|
||||
private List<Crop> cropList;
|
||||
private TaskListModel taskListModel;
|
||||
private Object IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Constructor of Gardenplan model
|
||||
|
@ -63,9 +64,8 @@ public class Gardenplanmodel {
|
|||
* @throws IOException If the database cannot be accessed
|
||||
*/
|
||||
public void removeCrop(Crop crop) throws IOException {
|
||||
|
||||
gardenPlan.removeCrop(crop);
|
||||
taskListModel.removeTasksForCrop(crop);
|
||||
taskListModel.removeTasksForCrop(crop.getCropId().orElseThrow(IllegalArgumentException::new));
|
||||
cropList = gardenPlan.getCrops();
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -159,5 +159,8 @@ public class JsonTaskDatabase implements TaskDatabase{
|
|||
(res, task) -> res.put(task.getId(), task),
|
||||
(existing, replacement) -> {});
|
||||
}
|
||||
|
||||
Long maxId = taskMap.isEmpty() ? 0L : Collections.max(taskMap.keySet());
|
||||
idProvider = new IdProvider(maxId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ public class Task {
|
|||
* default constructor
|
||||
* (used by Json deserializer)
|
||||
*/
|
||||
public Task(long cropId){
|
||||
public Task(){
|
||||
name= "";
|
||||
description= "";
|
||||
startDate = LocalDate.now();
|
||||
this.cropId = cropId;
|
||||
// this.cropId = cropId;
|
||||
}
|
||||
|
||||
public Task(String name, String description, LocalDate startDate, long cropId) {
|
||||
|
|
Loading…
Reference in New Issue