issue-106 #107
@ -37,8 +37,7 @@ public class TaskSeriesService {
|
|||||||
int weekDayIndex = 0;
|
int weekDayIndex = 0;
|
||||||
for(Map.Entry<Task, Integer> repeatingTaskInfo: offsetMap.entrySet()) {
|
for(Map.Entry<Task, Integer> repeatingTaskInfo: offsetMap.entrySet()) {
|
||||||
Task rootTask = repeatingTaskInfo.getKey();
|
Task rootTask = repeatingTaskInfo.getKey();
|
||||||
TaskSerieItem rootItem = new TaskSerieItem(rootTask, weekDayIndex);
|
addRootSubTasksToTaskSerie(taskSerie, rootTask, weekDayIndex);
|
||||||
taskSerie.addItem(rootItem);
|
|
||||||
|
|
||||||
int itemIndex = weekDayIndex +1;
|
int itemIndex = weekDayIndex +1;
|
||||||
Tupel<Collection<Task>, Collection<AbstractSchedule>> repeatingResult = repeatTask(rootTask, taskRepeatInfo.getEndDate(), offsetMap, taskSerie, itemIndex);
|
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) {
|
public ServiceExitCode createTaskSeries(Task rootTask, TaskRepeatDayInfo taskRepeatInfo) {
|
||||||
TaskSerie taskSerie = new TaskSerie();
|
TaskSerie taskSerie = new TaskSerie();
|
||||||
TaskSerieItem rootItem = taskSerie.addTask(rootTask);
|
addRootSubTasksToTaskSerie(taskSerie, rootTask, 0);
|
||||||
rootTask.setTaskSerieItem(rootItem);
|
|
||||||
|
|
||||||
HashMap<Task, Integer> offsetMap = new HashMap<>();
|
HashMap<Task, Integer> offsetMap = new HashMap<>();
|
||||||
offsetMap.put(rootTask, taskRepeatInfo.getOffset());
|
offsetMap.put(rootTask, taskRepeatInfo.getOffset());
|
||||||
@ -120,6 +118,16 @@ public class TaskSeriesService {
|
|||||||
return ServiceExitCode.OK;
|
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) {
|
public void deleteTaskSeriesItem(Task task) {
|
||||||
TaskSerieItem item = task.getTaskSerieItem();
|
TaskSerieItem item = task.getTaskSerieItem();
|
||||||
TaskSerie taskSerie = task.getTaskSerieItem().getTaskSerie();
|
TaskSerie taskSerie = task.getTaskSerieItem().getTaskSerie();
|
||||||
|
Loading…
Reference in New Issue
Block a user