issue-106 #107
@ -51,7 +51,7 @@ public class TaskEntityInfo {
|
||||
this.hasActiveSchedules = task.hasActiveSchedule();
|
||||
this.hasPlannedSchedules = task.hasPlannedSchedules();
|
||||
this.hasTaskSerie = task.getTaskSerieItem() != null;
|
||||
this.hasSubtasks = !task.getSubtasks().isEmpty();
|
||||
this.hasSubtasks = task.getSubtasks() != null && !task.getSubtasks().isEmpty();
|
||||
this.hasParent = task.getParent() != null;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,12 @@ package core.repositories.timemanager;
|
||||
|
||||
import core.entities.timemanager.AbstractSchedule;
|
||||
import core.entities.timemanager.Taskgroup;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -20,4 +22,9 @@ public interface ScheduleRepository extends CrudRepository<AbstractSchedule, Lon
|
||||
@Query(value = "SELECT s FROM AbstractSchedule s WHERE s.task.taskgroup.user.username = ?1 AND s.startTime is NOT NULL and s.stopTime is NULL")
|
||||
Optional<AbstractSchedule> getActiveScheduleOfUser(String username);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Transactional
|
||||
@Query(value = "DELETE FROM AbstractSchedule a WHERE a.task IN (SELECT t FROM Task t WHERE t.taskgroup = ?1)")
|
||||
void deleteByTaskgroup(Taskgroup taskgroup);
|
||||
}
|
||||
|
@ -7,10 +7,7 @@ import core.api.models.timemanager.taskSchedule.scheduleInfos.AdvancedScheduleIn
|
||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.BasicScheduleFieldInfo;
|
||||
import core.api.models.timemanager.taskSchedule.ForgottenScheduleInfo;
|
||||
import core.api.models.timemanager.taskSchedule.scheduleInfos.ScheduleInfo;
|
||||
import core.entities.timemanager.AbstractSchedule;
|
||||
import core.entities.timemanager.AdvancedTaskSchedule;
|
||||
import core.entities.timemanager.BasicTaskSchedule;
|
||||
import core.entities.timemanager.Task;
|
||||
import core.entities.timemanager.*;
|
||||
import core.repositories.UserRepository;
|
||||
import core.repositories.timemanager.AdvancedScheduleRepository;
|
||||
import core.repositories.timemanager.ScheduleRepository;
|
||||
@ -259,4 +256,8 @@ public class TaskScheduleService {
|
||||
schedule.setStopTime(schedule.getStartTime().plusMinutes(manualScheduleStopInfo.getDuration()));
|
||||
scheduleRepository.save(schedule);
|
||||
}
|
||||
|
||||
public void deleteSchedulesByTaskgroup(Taskgroup taskgroup) {
|
||||
scheduleRepository.deleteByTaskgroup(taskgroup);
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +113,7 @@ public class TaskService {
|
||||
|
||||
public void clearTasks(Taskgroup taskgroup) {
|
||||
taskSeriesService.deleteTaskSerieByTaskgroup(taskgroup);
|
||||
taskScheduleService.deleteSchedulesByTaskgroup(taskgroup);
|
||||
taskRepository.deleteAllByTaskgroup(taskgroup);
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,12 @@ public class TaskgroupService {
|
||||
|
||||
private final TaskgroupRepository taskgroupRepository;
|
||||
private final UserRepository userRepository;
|
||||
private final TaskService taskService;
|
||||
public TaskgroupService(@Autowired TaskgroupRepository taskgroupRepository,
|
||||
@Autowired UserRepository userRepository) {
|
||||
@Autowired UserRepository userRepository, @Autowired TaskService taskService) {
|
||||
this.taskgroupRepository = taskgroupRepository;
|
||||
this.userRepository = userRepository;
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
public PermissionResult<Taskgroup> getTaskgroupByIDAndUsername(long taskgroupID, String username) {
|
||||
@ -97,6 +99,7 @@ public class TaskgroupService {
|
||||
}
|
||||
|
||||
public void deleteTaskgroup(Taskgroup taskgroup) {
|
||||
taskService.clearTasks(taskgroup);
|
||||
taskgroupRepository.delete(taskgroup);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user