issue-106 #107
@ -33,6 +33,13 @@ public class Task {
|
|||||||
@OneToOne(mappedBy = "task", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToOne(mappedBy = "task", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
private TaskSerieItem taskSerieItem;
|
private TaskSerieItem taskSerieItem;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
|
private Set<Task> subtasks;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "parent")
|
||||||
|
private Task parent;
|
||||||
|
|
||||||
public Task() {
|
public Task() {
|
||||||
this.basicTaskSchedules = new ArrayList<>();
|
this.basicTaskSchedules = new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -149,6 +156,27 @@ public class Task {
|
|||||||
this.basicTaskSchedules = basicTaskSchedules;
|
this.basicTaskSchedules = basicTaskSchedules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addSubtask(Task subtask) {
|
||||||
|
subtask.setParent(this);
|
||||||
|
this.subtasks.add(subtask);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Task> getSubtasks() {
|
||||||
|
return subtasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubtasks(Set<Task> subtasks) {
|
||||||
|
this.subtasks = subtasks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParent(Task parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
|
@ -49,6 +49,21 @@ public class TaskService {
|
|||||||
return new ServiceResult<>(task);
|
return new ServiceResult<>(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceResult<Task> createSubTask(Task parentTask, TaskFieldInfo taskFieldInfo) {
|
||||||
|
if(taskFieldInfo.getStartDate().isBefore(parentTask.getStartDate()) ||
|
||||||
|
taskFieldInfo.getDeadline().isAfter(parentTask.getDeadline()) ||
|
||||||
|
taskFieldInfo.getDeadline().isBefore(taskFieldInfo.getStartDate())) {
|
||||||
|
return new ServiceResult<>(ServiceExitCode.INVALID_PARAMETER);
|
||||||
|
}
|
||||||
|
|
||||||
|
Task task = new Task(parentTask.getTaskgroup(), taskFieldInfo);
|
||||||
|
parentTask.getTaskgroup().getTasks().add(task);
|
||||||
|
parentTask.addSubtask(task);
|
||||||
|
|
||||||
|
taskRepository.save(task);
|
||||||
|
return new ServiceResult<>(task);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean existTaskByName(Collection<Task> tasks, String name) {
|
private boolean existTaskByName(Collection<Task> tasks, String name) {
|
||||||
for(Task task : tasks) {
|
for(Task task : tasks) {
|
||||||
if(task.getTaskName().equals(name)) {
|
if(task.getTaskName().equals(name)) {
|
||||||
@ -94,7 +109,6 @@ public class TaskService {
|
|||||||
taskSeriesService.deleteTaskSeriesItem(task);
|
taskSeriesService.deleteTaskSeriesItem(task);
|
||||||
}
|
}
|
||||||
taskRepository.delete(task);
|
taskRepository.delete(task);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearTasks(Taskgroup taskgroup) {
|
public void clearTasks(Taskgroup taskgroup) {
|
||||||
|
Loading…
Reference in New Issue
Block a user