issue-18 #28

Merged
sebastian merged 55 commits from issue-18 into master 2023-10-28 19:36:14 +02:00
4 changed files with 19 additions and 8 deletions
Showing only changes of commit 30d1bacbd6 - Show all commits

View File

@ -6,11 +6,9 @@
<component name="ChangeListManager">
<list default="true" id="3a869f59-290a-4ab2-b036-a878ce801bc4" name="Changes" comment="Removed unused TaskgroupShortInfo.java">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/api/controller/ScheduleController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Task.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/entities/timemanager/Task.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/repositories/timemanager/BasicTaskScheduleRepository.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskScheduleService.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../frontend/src/api/api/schedule.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../frontend/src/api/api/schedule.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../openapi.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../openapi.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/core/services/TaskService.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -101,6 +99,7 @@
<workItem from="1698067098771" duration="4770000" />
<workItem from="1698127431684" duration="2039000" />
<workItem from="1698164397550" duration="2329000" />
<workItem from="1698246651541" duration="766000" />
</task>
<task id="LOCAL-00001" summary="Structure Taskgroups in Hierarchies">
<option name="closed" value="true" />

View File

@ -2,6 +2,7 @@ package core.repositories.timemanager;
import core.entities.User;
import core.entities.timemanager.BasicTaskSchedule;
import core.entities.timemanager.Task;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
@ -19,6 +20,11 @@ public interface BasicTaskScheduleRepository extends CrudRepository<BasicTaskSch
@Query(value = "DELETE FROM BasicTaskSchedule bts WHERE bts.scheduleID = ?1")
void deleteBasicTaskScheduleByID(long id);
@Modifying
@Transactional
@Query(value = "DELETE FROM BasicTaskSchedule bts WHERE bts.task = ?1")
void deleteAllByTask(Task task);
@Query(value = "SELECT bts FROM BasicTaskSchedule bts WHERE bts.task.taskgroup.user = ?1")
List<BasicTaskSchedule> findAllByUser(User user);

View File

@ -76,4 +76,8 @@ public class TaskScheduleService {
return new ServiceResult<>(basicTaskSchedule);
}
}
public void deleteScheduleByTask(Task task) {
basicTaskScheduleRepository.deleteAllByTask(task);
}
}

View File

@ -3,25 +3,26 @@ package core.services;
import core.api.models.timemanager.tasks.TaskFieldInfo;
import core.entities.timemanager.Task;
import core.entities.timemanager.Taskgroup;
import core.repositories.timemanager.BasicTaskScheduleRepository;
import core.repositories.timemanager.TaskRepository;
import core.repositories.timemanager.TaskgroupRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@Service
public class TaskService {
private final TaskRepository taskRepository;
private final TaskgroupRepository taskgroupRepository;
private final TaskScheduleService taskScheduleService;
public TaskService(@Autowired TaskRepository taskRepository,
TaskgroupRepository taskgroupRepository) {
@Autowired TaskScheduleService taskScheduleService) {
this.taskRepository = taskRepository;
this.taskgroupRepository = taskgroupRepository;
this.taskScheduleService = taskScheduleService;
}
public ServiceResult<Task> createTask(Taskgroup taskgroup, TaskFieldInfo taskFieldInfo) {
@ -67,6 +68,7 @@ public class TaskService {
}
public void deleteTask(Task task) {
taskScheduleService.deleteScheduleByTask(task);
taskRepository.deleteByTaskID(task.getTaskID());
}