javadocs in TaskListModel
This commit is contained in:
parent
5bfebdc92c
commit
bf5c5c8439
|
@ -62,27 +62,53 @@ public class TaskListModel {
|
||||||
/**
|
/**
|
||||||
* Method to remove all Tasks for a specific Crop
|
* Method to remove all Tasks for a specific Crop
|
||||||
* @param cropId The crop which is removed
|
* @param cropId The crop which is removed
|
||||||
|
* @throws IOException If the database cannot be accessed
|
||||||
*/
|
*/
|
||||||
public void removeTasksForCrop(long cropId) throws IOException {
|
public void removeTasksForCrop(long cropId) throws IOException {
|
||||||
taskDatabase.removeTasksForCrop(cropId);
|
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++) {
|
||||||
|
@ -92,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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue