Fix storing multiple TaskSerieItems for RootTask
This commit is contained in:
parent
e102b91a1f
commit
717e8d4e45
@ -14,7 +14,7 @@ public class TaskSerieItem {
|
|||||||
@JoinColumn(referencedColumnName = "taskSerieID")
|
@JoinColumn(referencedColumnName = "taskSerieID")
|
||||||
private TaskSerie taskSerie;
|
private TaskSerie taskSerie;
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
@OneToOne
|
||||||
@JoinColumn(name = "task_id")
|
@JoinColumn(name = "task_id")
|
||||||
private Task task;
|
private Task task;
|
||||||
|
|
||||||
|
@ -35,12 +35,11 @@ public class TaskSeriesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Task> taskList = new ArrayList<>();
|
List<Task> taskList = new ArrayList<>();
|
||||||
taskList.add(rootTask);
|
|
||||||
LocalDate currentTaskDate = rootTask.getStartDate().plusDays(taskRepeatInfo.getOffset());
|
|
||||||
TaskSerie taskSerie = new TaskSerie();
|
TaskSerie taskSerie = new TaskSerie();
|
||||||
|
|
||||||
TaskSerieItem rootItem = taskSerie.addTask(rootTask);
|
TaskSerieItem rootItem = taskSerie.addTask(rootTask);
|
||||||
rootTask.setTaskSerieItem(rootItem);
|
rootTask.setTaskSerieItem(rootItem);
|
||||||
|
|
||||||
|
LocalDate currentTaskDate = rootTask.getStartDate().plusDays(taskRepeatInfo.getOffset());
|
||||||
int index = 2;
|
int index = 2;
|
||||||
while(currentTaskDate.isBefore(taskRepeatInfo.getEndingDate())) {
|
while(currentTaskDate.isBefore(taskRepeatInfo.getEndingDate())) {
|
||||||
Task task = Task.cloneTask(rootTask);
|
Task task = Task.cloneTask(rootTask);
|
||||||
@ -69,7 +68,11 @@ public class TaskSeriesService {
|
|||||||
TaskSerie taskSerie = task.getTaskSerieItem().getTaskSerie();
|
TaskSerie taskSerie = task.getTaskSerieItem().getTaskSerie();
|
||||||
task.setTaskSerieItem(null);
|
task.setTaskSerieItem(null);
|
||||||
taskSerieItemRepository.delete(item);
|
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);
|
taskSeriesRepository.delete(taskSerie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user