issue-77 #105

Merged
sebastian merged 17 commits from issue-77 into master 2024-03-16 10:12:35 +01:00
2 changed files with 8 additions and 5 deletions
Showing only changes of commit 717e8d4e45 - Show all commits

View File

@ -14,7 +14,7 @@ public class TaskSerieItem {
@JoinColumn(referencedColumnName = "taskSerieID")
private TaskSerie taskSerie;
@OneToOne(cascade = CascadeType.ALL)
@OneToOne
@JoinColumn(name = "task_id")
private Task task;

View File

@ -35,12 +35,11 @@ public class TaskSeriesService {
}
List<Task> taskList = new ArrayList<>();
taskList.add(rootTask);
LocalDate currentTaskDate = rootTask.getStartDate().plusDays(taskRepeatInfo.getOffset());
TaskSerie taskSerie = new TaskSerie();
TaskSerieItem rootItem = taskSerie.addTask(rootTask);
rootTask.setTaskSerieItem(rootItem);
LocalDate currentTaskDate = rootTask.getStartDate().plusDays(taskRepeatInfo.getOffset());
int index = 2;
while(currentTaskDate.isBefore(taskRepeatInfo.getEndingDate())) {
Task task = Task.cloneTask(rootTask);
@ -69,7 +68,11 @@ public class TaskSeriesService {
TaskSerie taskSerie = task.getTaskSerieItem().getTaskSerie();
task.setTaskSerieItem(null);
taskSerieItemRepository.delete(item);
if(taskSerie.getTasks().size() <= 1) {
if(taskSerie.getTasks().isEmpty()) {
for(TaskSerieItem taskSerieItem : taskSerie.getTasks()) {
taskSerieItem.setTaskSerie(null);
}
taskSerie.getTasks().clear();
taskSeriesRepository.delete(taskSerie);
}
}