Compare commits

...

8 Commits

Author SHA1 Message Date
Gian-Andrea Hutter 8408af175d #27 gardenplanmodelTest bugfixed 2022-11-04 15:46:11 +01:00
Gian-Andrea Hutter e91773b360 #27 gardenplanmodelTest bugfixed 2022-11-04 15:35:45 +01:00
Gian-Andrea Hutter 2361afd537 #27 gardenplanmodel bugfixed cropid 2022-11-04 15:32:15 +01:00
Gian-Andrea Hutter d45b8e116e Merge remote-tracking branch 'origin/feature_taskList_m2' into feature_gardenplan-model_M2
# Conflicts:
#	src/test/java/ch/zhaw/gartenverwaltung/io/JsonTaskDatabaseTest.java
2022-11-04 07:39:57 +01:00
schrom01 541217c281 prepaired Tests for new Methods in JsonTaskDatabase 2022-10-31 16:36:24 +01:00
schrom01 bf5c5c8439 javadocs in TaskListModel 2022-10-31 16:31:59 +01:00
schrom01 5bfebdc92c implemented Methods
removeTasksForCrop and getTaskForCrop
in JsonTaskDatabase
2022-10-31 16:23:49 +01:00
schrom01 0e4e207581 completed Methods
created Config Class
2022-10-31 15:57:19 +01:00
14 changed files with 742 additions and 148 deletions

View File

@ -0,0 +1,19 @@
package ch.zhaw.gartenverwaltung;
import ch.zhaw.gartenverwaltung.types.HardinessZone;
public class Config {
private static HardinessZone currentHardinessZone;
static {
currentHardinessZone = HardinessZone.ZONE_8A;
}
public static HardinessZone getCurrentHardinessZone() {
return currentHardinessZone;
}
public static void setCurrentHardinessZone(HardinessZone currentHardinessZone) {
Config.currentHardinessZone = currentHardinessZone;
}
}

View File

@ -12,9 +12,9 @@ import ch.zhaw.gartenverwaltung.types.Task;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.function.Supplier;
/** /**
@ -24,6 +24,7 @@ public class Gardenplanmodel {
private GardenPlan gardenPlan; private GardenPlan gardenPlan;
private List<Crop> cropList; private List<Crop> cropList;
private TaskListModel taskListModel; private TaskListModel taskListModel;
private Object IllegalArgumentException;
/** /**
* Constructor of Gardenplan model * Constructor of Gardenplan model
@ -63,9 +64,8 @@ public class Gardenplanmodel {
* @throws IOException If the database cannot be accessed * @throws IOException If the database cannot be accessed
*/ */
public void removeCrop(Crop crop) throws IOException { public void removeCrop(Crop crop) throws IOException {
gardenPlan.removeCrop(crop); gardenPlan.removeCrop(crop);
taskListModel.removeTasksForCrop(crop); taskListModel.removeTasksForCrop(crop.getCropId().orElseThrow(IllegalArgumentException::new));
cropList = gardenPlan.getCrops(); cropList = gardenPlan.getCrops();
} }
/** /**

View File

@ -58,14 +58,29 @@ public class JsonTaskDatabase implements TaskDatabase{
return taskMap.values().stream().filter(task -> task.isInTimePeriode(start, end)).toList(); 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 @Override
public List<Task> getTaskForCrop(Crop crop) { public List<Task> getTaskForCrop(long cropId) throws IOException {
return null; //TODO implement 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 @Override
public void removeTasksForCrop(Crop crop) { public void removeTasksForCrop(long cropId) throws IOException {
// TODO implement if(taskMap.isEmpty()) {
loadTaskListFromFile();
}
taskMap.values().removeIf(task -> task.getCropId() == cropId);
} }
/** /**
@ -144,5 +159,8 @@ public class JsonTaskDatabase implements TaskDatabase{
(res, task) -> res.put(task.getId(), task), (res, task) -> res.put(task.getId(), task),
(existing, replacement) -> {}); (existing, replacement) -> {});
} }
Long maxId = taskMap.isEmpty() ? 0L : Collections.max(taskMap.keySet());
idProvider = new IdProvider(maxId);
} }
} }

View File

@ -25,9 +25,20 @@ public interface TaskDatabase {
*/ */
List<Task> getTaskList(LocalDate start, LocalDate end) throws IOException; 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. * Saves the {@link Task} in the Cache.

View File

@ -1,68 +1,114 @@
package ch.zhaw.gartenverwaltung.taskList; package ch.zhaw.gartenverwaltung.taskList;
import ch.zhaw.gartenverwaltung.Config;
import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException; import ch.zhaw.gartenverwaltung.io.HardinessZoneNotSetException;
import ch.zhaw.gartenverwaltung.io.JsonTaskDatabase; import ch.zhaw.gartenverwaltung.io.JsonTaskDatabase;
import ch.zhaw.gartenverwaltung.io.PlantDatabase; import ch.zhaw.gartenverwaltung.io.PlantDatabase;
import ch.zhaw.gartenverwaltung.io.TaskDatabase; import ch.zhaw.gartenverwaltung.io.TaskDatabase;
import ch.zhaw.gartenverwaltung.types.Crop; import ch.zhaw.gartenverwaltung.types.*;
import ch.zhaw.gartenverwaltung.types.HardinessZone;
import ch.zhaw.gartenverwaltung.types.Plant;
import ch.zhaw.gartenverwaltung.types.Task;
import java.io.IOException; import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TaskListModel { public class TaskListModel {
private TaskDatabase taskDatabase; private TaskDatabase taskDatabase;
private PlantDatabase plantDatabase; private PlantDatabase plantDatabase;
/**
* Comparators to create sorted Task List
*/
static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate); static final Comparator<Task> sortByStartDate = Comparator.comparing(Task::getStartDate);
public TaskListModel(){ public TaskListModel(){
taskDatabase = new JsonTaskDatabase(); taskDatabase = new JsonTaskDatabase();
} }
/**
* Constructor to create Database Objects.
*/
public TaskListModel(TaskDatabase taskDatabase, PlantDatabase plantDatabase) { public TaskListModel(TaskDatabase taskDatabase, PlantDatabase plantDatabase) {
this.taskDatabase = taskDatabase; this.taskDatabase = taskDatabase;
this.plantDatabase = plantDatabase; this.plantDatabase = plantDatabase;
} }
/**
* Method to save a new Task to Task Database
* @param task the Task to save
* @throws IOException If the database cannot be accessed
*/
public void addTask(Task task) throws IOException { public void addTask(Task task) throws IOException {
taskDatabase.saveTask(task); taskDatabase.saveTask(task);
} }
/**
* Method to add all Tasks for a new crop
* @param crop the crop which is added
* @throws PlantNotFoundException if the plantId in the crop doesn't exist in Plant Database
* @throws HardinessZoneNotSetException If there is no Hardiness Zone Set in Plant Database
* @throws IOException If the database cannot be accessed
*/
public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException { public void planTasksForCrop(Crop crop) throws PlantNotFoundException, HardinessZoneNotSetException, IOException {
Plant plant = plantDatabase.getPlantById(HardinessZone.ZONE_8A, crop.getPlantId()).orElseThrow(PlantNotFoundException::new); Plant plant = plantDatabase.getPlantById(Config.getCurrentHardinessZone(), crop.getPlantId()).orElseThrow(PlantNotFoundException::new);
// TODO new exception for (GrowthPhase growthPhase : plant.lifecycle()) {
// TODO HArdiness Zone for (TaskTemplate taskTemplate : growthPhase.taskTemplates()) {
return; addTask(taskTemplate.generateTask(crop.getStartDate(), crop.getCropId().orElse(0L)));
}
}
} }
public void removeTasksForCrop(Crop crop) { /**
//TODO implement * Method to remove all Tasks for a specific Crop
taskDatabase.removeTasksForCrop(crop); * @param cropId The crop which is removed
* @throws IOException If the database cannot be accessed
*/
public void removeTasksForCrop(long cropId) throws IOException {
taskDatabase.removeTasksForCrop(cropId);
} }
/**
* Method to remove a Task from Database
* @param task the Task to remove
* @throws IOException If the database cannot be accessed
*/
public void removeTask(Task task) throws IOException { public void removeTask(Task task) throws IOException {
taskDatabase.removeTask(task); taskDatabase.removeTask(task);
} }
/**
* Method to get all Tasks
* @return List of all Tasks
* @throws IOException If the database cannot be accessed
*/
public List<Task> getTaskList() throws IOException { public List<Task> getTaskList() throws IOException {
return getFilteredTaskList(LocalDate.MIN, LocalDate.MAX); return getFilteredTaskList(LocalDate.MIN, LocalDate.MAX);
} }
/**
* Method to get all Tasks which are today or in future
* @return List of Tasks
* @throws IOException If the database cannot be accessed
*/
public List<Task> getFutureTasks() throws IOException { public List<Task> getFutureTasks() throws IOException {
return getFilteredTaskList(LocalDate.now(), LocalDate.MAX); return getFilteredTaskList(LocalDate.now(), LocalDate.MAX);
} }
/**
* Method to get all Tasks which are today or in past
* @return List of Tasks
* @throws IOException If the database cannot be accessed
*/
public List<Task> getPastTasks() throws IOException { public List<Task> getPastTasks() throws IOException {
return getFilteredTaskList(LocalDate.MIN, LocalDate.now()); return getFilteredTaskList(LocalDate.MIN, LocalDate.now());
} }
/**
* Method to get an Array of 7 Tasklists for the next 7 days. Index 0 is Tasklist for Today.
* @return Array with length 7 (List<Task>[])
* @throws IOException If the database cannot be accessed
*/
public List<Task>[] getTasksUpcomingWeek() throws IOException { public List<Task>[] getTasksUpcomingWeek() throws IOException {
List<Task>[] listArray = new List[7]; List<Task>[] listArray = new List[7];
for(int i = 0; i < 7; i++) { for(int i = 0; i < 7; i++) {
@ -72,10 +118,23 @@ public class TaskListModel {
return listArray; return listArray;
} }
/**
* Method to get Tasklist filtered by date.
* @param start the start date for the filter
* @param end the end date for the filter
* @return List of Tasks matched by the filter
* @throws IOException If the database cannot be accessed
*/
public List<Task> getFilteredTaskList(LocalDate start, LocalDate end) throws IOException { public List<Task> getFilteredTaskList(LocalDate start, LocalDate end) throws IOException {
return getSortedTaskList(taskDatabase.getTaskList(start, end), sortByStartDate); return getSortedTaskList(taskDatabase.getTaskList(start, end), sortByStartDate);
} }
/**
* Method to sort a Tasklist by a given Comparator
* @param taskList The Tasklist to sort
* @param comparator the comparator to sort
* @return a sorted coppy of the given Tasklist
*/
private List<Task> getSortedTaskList(List<Task> taskList, Comparator<Task> comparator) { private List<Task> getSortedTaskList(List<Task> taskList, Comparator<Task> comparator) {
return taskList.stream().sorted(comparator).collect(Collectors.toList()); return taskList.stream().sorted(comparator).collect(Collectors.toList());
} }

View File

@ -15,7 +15,7 @@ public class Task {
private final LocalDate startDate; private final LocalDate startDate;
private Integer interval; private Integer interval;
private LocalDate endDate; private LocalDate endDate;
private Crop cropId; private long cropId;
/** /**
* default constructor * default constructor
@ -25,20 +25,23 @@ public class Task {
name= ""; name= "";
description= ""; description= "";
startDate = LocalDate.now(); startDate = LocalDate.now();
// this.cropId = cropId;
} }
public Task(String name, String description, LocalDate startDate) { public Task(String name, String description, LocalDate startDate, long cropId) {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.startDate = startDate; this.startDate = startDate;
this.cropId = cropId;
} }
public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval) { public Task(String name, String description, LocalDate startDate, LocalDate endDate, int interval, long cropId) {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.startDate = startDate; this.startDate = startDate;
this.endDate = endDate; this.endDate = endDate;
this.interval = interval; this.interval = interval;
this.cropId = cropId;
} }
// Builder-pattern-style setters // Builder-pattern-style setters
@ -56,10 +59,7 @@ public class Task {
} }
public boolean isInTimePeriode(LocalDate searchStartDate, LocalDate searchEndDate){ public boolean isInTimePeriode(LocalDate searchStartDate, LocalDate searchEndDate){
if(startDate.isAfter(searchStartDate) &&startDate.isBefore(searchEndDate)){ return startDate.isAfter(searchStartDate) && startDate.isBefore(searchEndDate);
return true;
}
return false;
} }
// Getters // Getters
@ -67,6 +67,7 @@ public class Task {
public String getName() { return name; } public String getName() { return name; }
public String getDescription() { return description; } public String getDescription() { return description; }
public LocalDate getStartDate() { return startDate; } public LocalDate getStartDate() { return startDate; }
public long getCropId() { return cropId; }
public Optional<Integer> getInterval() { public Optional<Integer> getInterval() {
return Optional.ofNullable(interval); return Optional.ofNullable(interval);

View File

@ -44,8 +44,8 @@ public class TaskTemplate {
this.relativeStartDate = relativeStartDate; this.relativeStartDate = relativeStartDate;
} }
public Task generateTask(LocalDate realStartDate) { public Task generateTask(LocalDate realStartDate, long cropId) {
Task task = new Task(name, description, realStartDate.plusDays(relativeStartDate)); Task task = new Task(name, description, realStartDate.plusDays(relativeStartDate), cropId);
if (relativeEndDate != null) { if (relativeEndDate != null) {
task.withEndDate(realStartDate.plusDays(relativeEndDate)); task.withEndDate(realStartDate.plusDays(relativeEndDate));
} }

View File

@ -6,7 +6,7 @@
"startDate" : "2022-05-01", "startDate" : "2022-05-01",
"endDate" : "2022-05-01", "endDate" : "2022-05-01",
"interval" : 0, "interval" : 0,
"cropID" : 0 "cropId" : 0
}, },
{ {
"id" : 2, "id" : 2,
@ -15,7 +15,7 @@
"startDate" : "2022-05-01", "startDate" : "2022-05-01",
"endDate" : "2022-09-01", "endDate" : "2022-09-01",
"interval" : 2, "interval" : 2,
"cropID" : 0 "cropId" : 0
}, },
{ {
"id" : 3, "id" : 3,
@ -24,7 +24,7 @@
"startDate" : "2022-06-01", "startDate" : "2022-06-01",
"endDate" : "2022-08-01", "endDate" : "2022-08-01",
"interval" : 28, "interval" : 28,
"cropID" : 0 "cropId" : 0
}, },
{ {
"id" : 4, "id" : 4,
@ -33,7 +33,7 @@
"startDate" : "2022-07-01", "startDate" : "2022-07-01",
"endDate" : "2022-07-01", "endDate" : "2022-07-01",
"interval" : 0, "interval" : 0,
"cropID" : 0 "cropId" : 0
}, },
{ {
"id" : 5, "id" : 5,
@ -42,7 +42,7 @@
"startDate" : "2022-05-01", "startDate" : "2022-05-01",
"endDate" : "2022-09-01", "endDate" : "2022-09-01",
"interval" : 5, "interval" : 5,
"cropID" : 0 "cropId" : 0
}, },
{ {
"id" : 6, "id" : 6,
@ -51,6 +51,6 @@
"startDate" : "2022-09-01", "startDate" : "2022-09-01",
"endDate" : "2022-09-01", "endDate" : "2022-09-01",
"interval" : 0, "interval" : 0,
"cropID" : 0 "cropId" : 0
} }
] ]

View File

@ -6,15 +6,15 @@ import ch.zhaw.gartenverwaltung.taskList.TaskListModel;
import ch.zhaw.gartenverwaltung.types.*; import ch.zhaw.gartenverwaltung.types.*;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.internal.stubbing.answers.DoesNothing;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.MonthDay; import java.time.MonthDay;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -34,6 +34,8 @@ public class GardenPlanModelTest {
@BeforeEach @BeforeEach
void setUp() throws IOException { void setUp() throws IOException {
examplePlantOnion = new Plant( examplePlantOnion = new Plant(
0, 0,
"summertime onion", "summertime onion",
@ -49,8 +51,8 @@ public class GardenPlanModelTest {
new GrowthPhase(MonthDay.of(2, 8), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()), new GrowthPhase(MonthDay.of(2, 8), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()),
new GrowthPhase(MonthDay.of(10, 2), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>()))); new GrowthPhase(MonthDay.of(10, 2), MonthDay.of(12, 4), 0, new WateringCycle(0, 0, null), GrowthPhaseType.PLANT, HardinessZone.ZONE_8A, new ArrayList<>())));
exampleCropOnion = new Crop(examplePlantOnion.id(), LocalDate.now()); exampleCropOnion = new Crop(examplePlantOnion.id(), LocalDate.of(2023,3,1));
exampleCropOnion.withId(13); exampleCropOnion.withId(3);
examplePlantCarrot = new Plant( examplePlantCarrot = new Plant(
1, 1,
"Early Carrot", "Early Carrot",
@ -70,9 +72,9 @@ public class GardenPlanModelTest {
exampleCrop2 = new Crop(1,LocalDate.of(2023,3,1)); exampleCrop2 = new Crop(1,LocalDate.of(2023,3,1));
exampleCrop2.withId(1); exampleCrop2.withId(1);
exampleCrop2.withArea(0.5); exampleCrop2.withArea(0.5);
exampleCrop3 = new Crop(0,LocalDate.of(2023,3,25)); exampleCrop3 = new Crop(0,LocalDate.of(2023,3,01));
exampleCrop3.withId(2); exampleCrop3.withId(2);
exampleCrop3.withArea(1.5); exampleCrop3.withArea(1.0);
cropList = new ArrayList<>(); cropList = new ArrayList<>();
cropList.add(exampleCrop1); cropList.add(exampleCrop1);
@ -88,7 +90,7 @@ public class GardenPlanModelTest {
GardenPlan gardenPlan = mock(GardenPlan.class); GardenPlan gardenPlan = mock(GardenPlan.class);
when(gardenPlan.getCrops()).thenReturn(cropList); when(gardenPlan.getCrops()).thenReturn(cropList);
when(gardenPlan.getCropById(5)).thenReturn(java.util.Optional.ofNullable(exampleCropCarrot)); when(gardenPlan.getCropById(5)).thenReturn(java.util.Optional.ofNullable(exampleCropCarrot));
when(gardenPlan.getCropById(13)).thenReturn(java.util.Optional.ofNullable(exampleCropOnion)); when(gardenPlan.getCropById(3)).thenReturn(java.util.Optional.ofNullable(exampleCropOnion));
return gardenPlan; return gardenPlan;
} }
@ -96,7 +98,9 @@ public class GardenPlanModelTest {
void plantAsCrop() throws HardinessZoneNotSetException, IOException, PlantNotFoundException { void plantAsCrop() throws HardinessZoneNotSetException, IOException, PlantNotFoundException {
model.plantAsCrop(examplePlantOnion, LocalDate.of(2023,3,1)); model.plantAsCrop(examplePlantOnion, LocalDate.of(2023,3,1));
assertTrue(model.getCrops().contains(exampleCropOnion)); exampleCropOnion = model.getCrop(2L).get();
assertEquals(model.getCrops().get(2),exampleCropOnion);
} }
@Test @Test

View File

@ -6,80 +6,42 @@ import org.junit.jupiter.api.*;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Optional;
public class JsonTaskDatabaseTest { public class JsonTaskDatabaseTest {
TaskDatabase testDatabase; TaskDatabase testDatabase;
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
@BeforeEach @BeforeEach
void connectToDb() { void connectToDb() {
testDatabase = new JsonTaskDatabase(); // testDatabase = new JsonTaskDatabase();
} }
@Test @Test
@DisplayName("Check if results are retrieved completely") @DisplayName("Check if results are retrieved completely")
void getTasks(){ void getTasks(){
/*
List<Task> taskList=null; List<Task> taskList=null;
try { try {
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022",formatter), taskList = testDatabase.getTaskList(formatter.parse("01.05.2022"), formatter.parse("01.08.2022"));
LocalDate.parse("31.05.2022",formatter));
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (ParseException e) {
throw new RuntimeException(e);
} }
Assertions.assertEquals(3,taskList.size()); Assertions.assertTrue(taskList.size()>0);
*/
}
//@Disabled("disabled until idProvider works")
@Test
@DisplayName("Add task.")
void addTask(){
Task task = new Task("Testtask","This is a test Task.",LocalDate.parse("01.05.2022",formatter));
try {
testDatabase.saveTask(task);
List<Task> taskList=null;
try {
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022",formatter),
LocalDate.parse("31.05.2022",formatter));
} catch (IOException e) {
throw new RuntimeException(e);
}
Assertions.assertEquals(4,taskList.size());
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
@Test @Test
@DisplayName("Remove task.") void getTaskForCrop() {
void removeTask(){ // TODO implement Test
Task task = new Task("Dummy","Dummy",LocalDate.parse("31.05.2022",formatter)).withId(2);
try {
testDatabase.removeTask(task);
List<Task> taskList=null;
try {
taskList = testDatabase.getTaskList(LocalDate.parse("30.04.2022",formatter),
LocalDate.parse("31.05.2022",formatter));
} catch (IOException e) {
throw new RuntimeException(e);
} }
Assertions.assertEquals(2,taskList.size()); @Test
} catch (IOException e) { void removeTasksForCrop() {
throw new RuntimeException(e); // TODO implement Test
} }
}
} }

View File

@ -0,0 +1,257 @@
[
{
"id": 0,
"name": "Potato",
"description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.",
"light": 6,
"spacing": "35",
"soil": "sandy",
"image": "potato.jpg",
"pests": [
{
"name": "Rot",
"description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
"measures": "Less water."
}
],
"lifecycle": [
{
"startDate": "03-10",
"endDate": "04-10",
"type": "SOW",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": []
},
"taskTemplates": [
{
"name": "Germinate",
"relativeStartDate": -14,
"relativeEndDate": null,
"description": "\"Take an egg carton and fill it with soil. Put the seedling deep enaugh so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.\"",
"interval": null,
"isOptional": false
}
]
},
{
"startDate": "04-10",
"endDate": "07-10",
"type": "PLANT",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 25,
"interval": 7,
"notes": []
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "\"When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.\"",
"interval": 21,
"isOptional": false
}
]
},
{
"startDate": "06-10",
"endDate": "08-10",
"type": "HARVEST",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": []
},
"taskTemplates": [
{
"name": "Harvest",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
"interval": null,
"isOptional": false
}
]
}
]
},
{
"id": 1,
"name": "Early Carrot",
"description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.",
"image": "carrot.jpg",
"lifecycle": [
{
"startDate": "02-20",
"endDate": "03-10",
"zone": "ZONE_8A",
"type": "SOW",
"wateringCycle": {
"litersPerSqM": 15,
"interval": 3,
"notes": []
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": 0,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": null,
"isOptional": false
}
]
},
{
"startDate": "03-10",
"endDate": "05-10",
"zone": "ZONE_8A",
"type": "PLANT",
"wateringCycle": {
"litersPerSqM": 25,
"interval": 3,
"notes": [
"Be careful not to pour water over the leaves, as this will lead to sunburn."
]
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": 15,
"isOptional": true
}
]
},
{
"startDate": "05-10",
"endDate": "05-20",
"zone": "ZONE_8A",
"type": "HARVEST",
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": []
},
"taskTemplates": [
{
"name": "Harvesting",
"relativeStartDate": 0,
"relativeEndDate": 14,
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
"interval": null,
"isOptional": false
}
]
}
],
"soil": "sandy to loamy, loose soil, free of stones",
"spacing": "5,35,2.5",
"pests": [
{
"name": "Rot",
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
"measures": "less water"
}
]
},
{
"id": 2,
"name": "Summertime Onion",
"description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
"image": "onion.jpg",
"lifecycle": [
{
"startDate": "03-15",
"endDate": "04-10",
"type": "SOW",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 15,
"interval": 4,
"notes": [
]
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": 0,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": null,
"isOptional": false
}
]
},
{
"startDate": "04-10",
"endDate": "07-10",
"type": "PLANT",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 25,
"interval": 3,
"notes": [
""
]
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": 15,
"isOptional": true
}
]
},
{
"startDate": "07-10",
"endDate": "09-20",
"type": "HARVEST",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": [
]
},
"taskTemplates": [
{
"name": "Harvesting",
"relativeStartDate": 0,
"relativeEndDate": 14,
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
"interval": null,
"isOptional": false
}
]
}
],
"soil": "sandy to loamy, loose soil, free of stones",
"spacing": "15,30,2",
"pests": [
{
"name": "Rot",
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
"measures": "less water"
}
]
}
]

View File

@ -0,0 +1,56 @@
[
{
"id" : 1,
"name" : "sow plant",
"description": "Plant the seeds, crops in de bed.",
"startDate" : "2022-05-01",
"endDate" : "2022-05-01",
"interval" : 0,
"cropID" : 0
},
{
"id" : 2,
"name" : "water plant",
"description": "water the plant, so that the soil is wet around the plant.",
"startDate" : "2022-05-01",
"endDate" : "2022-09-01",
"interval" : 2,
"cropID" : 0
},
{
"id" : 3,
"name" : "fertilize plant",
"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,
"cropID" : 0
},
{
"id" : 4,
"name" : "covering plant",
"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,
"cropID" : 0
},
{
"id" : 5,
"name" : "look after plant",
"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,
"cropID" : 0
},
{
"id" : 6,
"name" : "harvest plant",
"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,
"cropID" : 0
}
]

View File

@ -0,0 +1,257 @@
[
{
"id": 0,
"name": "Potato",
"description": "The potato is a tuber, round or oval, with small white roots called 'eyes', that are growth buds. The size varies depending on the variety; the colour of the skin can be white, yellow or even purple.",
"light": 6,
"spacing": "35",
"soil": "sandy",
"image": "potato.jpg",
"pests": [
{
"name": "Rot",
"description": "Rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
"measures": "Less water."
}
],
"lifecycle": [
{
"startDate": "03-10",
"endDate": "04-10",
"type": "SOW",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": []
},
"taskTemplates": [
{
"name": "Germinate",
"relativeStartDate": -14,
"relativeEndDate": null,
"description": "\"Take an egg carton and fill it with soil. Put the seedling deep enaugh so its half covered with soil. Keep it in 10-15 * Celsius with lots of light.\"",
"interval": null,
"isOptional": false
}
]
},
{
"startDate": "04-10",
"endDate": "07-10",
"type": "PLANT",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 25,
"interval": 7,
"notes": []
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "\"When the plants are 20 cm tall, begin hilling the potatoes by gently mounding the soil from the center of your rows around the stems of the plant. Mound up the soil around the plant until just the top few leaves show above the soil. Two weeks later, hill up the soil again when the plants grow another 20 cm.\"",
"interval": 21,
"isOptional": false
}
]
},
{
"startDate": "06-10",
"endDate": "08-10",
"type": "HARVEST",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": []
},
"taskTemplates": [
{
"name": "Harvest",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "Once the foliage has wilted and dried completely, harvest on a dry day. Store in a dark and cool location.",
"interval": null,
"isOptional": false
}
]
}
]
},
{
"id": 1,
"name": "Early Carrot",
"description": "Carrot, (Daucus carota), herbaceous, generally biennial plant of the Apiaceae family that produces an edible taproot. Among common varieties root shapes range from globular to long, with lower ends blunt to pointed. Besides the orange-coloured roots, white-, yellow-, and purple-fleshed varieties are known.",
"image": "carrot.jpg",
"lifecycle": [
{
"startDate": "02-20",
"endDate": "03-10",
"zone": "ZONE_8A",
"type": "SOW",
"wateringCycle": {
"litersPerSqM": 15,
"interval": 3,
"notes": []
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": 0,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": null,
"isOptional": false
}
]
},
{
"startDate": "03-10",
"endDate": "05-10",
"zone": "ZONE_8A",
"type": "PLANT",
"wateringCycle": {
"litersPerSqM": 25,
"interval": 3,
"notes": [
"Be careful not to pour water over the leaves, as this will lead to sunburn."
]
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": 15,
"isOptional": true
}
]
},
{
"startDate": "05-10",
"endDate": "05-20",
"zone": "ZONE_8A",
"type": "HARVEST",
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": []
},
"taskTemplates": [
{
"name": "Harvesting",
"relativeStartDate": 0,
"relativeEndDate": 14,
"description": "When the leaves turn to a yellowish brown. Do not harvest earlier. The plant will show when it's ready.",
"interval": null,
"isOptional": false
}
]
}
],
"soil": "sandy to loamy, loose soil, free of stones",
"spacing": "5,35,2.5",
"pests": [
{
"name": "Rot",
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
"measures": "less water"
}
]
},
{
"id": 2,
"name": "Summertime Onion",
"description": "Onion, (Allium cepa), herbaceous biennial plant in the amaryllis family (Amaryllidaceae) grown for its edible bulb. The onion is likely native to southwestern Asia but is now grown throughout the world, chiefly in the temperate zones. Onions are low in nutrients but are valued for their flavour and are used widely in cooking. They add flavour to such dishes as stews, roasts, soups, and salads and are also served as a cooked vegetable.",
"image": "onion.jpg",
"lifecycle": [
{
"startDate": "03-15",
"endDate": "04-10",
"type": "SOW",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 15,
"interval": 4,
"notes": [
]
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": 0,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": null,
"isOptional": false
}
]
},
{
"startDate": "04-10",
"endDate": "07-10",
"type": "PLANT",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 25,
"interval": 3,
"notes": [
""
]
},
"taskTemplates": [
{
"name": "hilling",
"relativeStartDate": 0,
"relativeEndDate": null,
"description": "Mound up the soil around the plant until just the top few leaves show above the soil. ",
"interval": 15,
"isOptional": true
}
]
},
{
"startDate": "07-10",
"endDate": "09-20",
"type": "HARVEST",
"zone": "ZONE_8A",
"group": 0,
"wateringCycle": {
"litersPerSqM": 0,
"interval": null,
"notes": [
]
},
"taskTemplates": [
{
"name": "Harvesting",
"relativeStartDate": 0,
"relativeEndDate": 14,
"description": "When ready for harvest, the leaves on your onion plants will start to flop over. This happens at the \"neck\" of the onion and it signals that the plant has stopped growing and is ready for storage. Onions should be harvested soon thereafter",
"interval": null,
"isOptional": false
}
]
}
],
"soil": "sandy to loamy, loose soil, free of stones",
"spacing": "15,30,2",
"pests": [
{
"name": "Rot",
"description": "rot, any of several plant diseases, caused by any of hundreds of species of soil-borne bacteria, fungi, and funguslike organisms (Oomycota). Rot diseases are characterized by plant decomposition and putrefaction. The decay may be hard, dry, spongy, watery, mushy, or slimy and may affect any plant part.",
"measures": "less water"
}
]
}
]

View File

@ -1,50 +0,0 @@
[
{
"id" : "1",
"name" : "sow plant",
"description": "Plant the seeds/ crops in de bed.",
"startDate" : "01.05.2022",
"endDate" : "01.05.2022",
"interval" : "null"
},
{
"id" : "2",
"name" : "water plant",
"description": "water the plant, so that the soil is wet around the plant.",
"startDate" : "01.05.2022",
"endDate" : "01.09.2022",
"interval" : "2"
},
{
"id" : "3",
"name" : "fertilize plant",
"description": "The fertilizer has to be mixed with water. Then fertilize the plant's soil with the mixture",
"startDate" : "01.06.2022",
"endDate" : "01.08.2022",
"interval" : "28"
},
{
"id" : "4",
"name" : "covering plant",
"description": "Take a big enough coverage for the plants. Cover the whole plant with a bit space between the plant and the coverage",
"startDate" : "15.07.2022",
"endDate" : "15.07.2022",
"interval" : "null"
},
{
"id" : "5",
"name" : "look after plant",
"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" : "01.05.2022",
"endDate" : "01.09.2022",
"interval" : "5"
},
{
"id" : "6",
"name" : "harvest plant",
"description": "Pull the ripe vegetables out from the soil. Clean them with clear, fresh water. ",
"startDate" : "01.09.2022",
"endDate" : "01.09.2022",
"interval" : "null"
}
]