issue-106 #107

Merged
sebastian merged 18 commits from issue-106 into master 2024-03-17 09:17:11 +01:00
Showing only changes of commit 7336daddb1 - Show all commits

View File

@ -37,8 +37,7 @@ public class TaskSeriesService {
int weekDayIndex = 0;
for(Map.Entry<Task, Integer> repeatingTaskInfo: offsetMap.entrySet()) {
Task rootTask = repeatingTaskInfo.getKey();
TaskSerieItem rootItem = new TaskSerieItem(rootTask, weekDayIndex);
taskSerie.addItem(rootItem);
addRootSubTasksToTaskSerie(taskSerie, rootTask, weekDayIndex);
int itemIndex = weekDayIndex +1;
Tupel<Collection<Task>, Collection<AbstractSchedule>> repeatingResult = repeatTask(rootTask, taskRepeatInfo.getEndDate(), offsetMap, taskSerie, itemIndex);
@ -101,8 +100,7 @@ public class TaskSeriesService {
public ServiceExitCode createTaskSeries(Task rootTask, TaskRepeatDayInfo taskRepeatInfo) {
TaskSerie taskSerie = new TaskSerie();
TaskSerieItem rootItem = taskSerie.addTask(rootTask);
rootTask.setTaskSerieItem(rootItem);
addRootSubTasksToTaskSerie(taskSerie, rootTask, 0);
HashMap<Task, Integer> offsetMap = new HashMap<>();
offsetMap.put(rootTask, taskRepeatInfo.getOffset());
@ -120,6 +118,16 @@ public class TaskSeriesService {
return ServiceExitCode.OK;
}
private void addRootSubTasksToTaskSerie(TaskSerie taskSerie, Task rootTask, int index) {
Queue<Task> taskQueue = new LinkedList<>(Collections.singletonList(rootTask));
while(!taskQueue.isEmpty()) {
Task currentTask = taskQueue.poll();
TaskSerieItem taskSerieItem = new TaskSerieItem(currentTask, index);
taskSerie.addItem(taskSerieItem);
}
}
public void deleteTaskSeriesItem(Task task) {
TaskSerieItem item = task.getTaskSerieItem();
TaskSerie taskSerie = task.getTaskSerieItem().getTaskSerie();