issue-106 #107

Merged
sebastian merged 18 commits from issue-106 into master 2024-03-17 09:17:11 +01:00
5 changed files with 54 additions and 2 deletions
Showing only changes of commit 4059500fa4 - Show all commits

View File

@ -196,4 +196,15 @@ public class TaskController {
Collection<Task> subtasks = taskPermissionResult.getResult().getSubtasks();
return ResponseEntity.ok(subtasks.stream().map(TaskEntityInfo::new).toList());
}
@DeleteMapping("/tasks/{taskID}/subtasks")
public ResponseEntity<?> onClearSubtasks(@PathVariable long taskID) {
var taskPermissionResult = taskService.getTaskPermissions(taskID, SecurityContextHolder.getContext().getAuthentication().getName());
if(taskPermissionResult.hasIssue()) {
return taskPermissionResult.mapToResponseEntity();
}
ServiceExitCode result = taskService.clearSubTasks(taskPermissionResult.getResult());
return result.mapToResponseEntity();
}
}

View File

@ -44,4 +44,9 @@ public interface TaskRepository extends CrudRepository<Task, Long> {
@Transactional
@Query(value = "UPDATE Task t SET t.parent = null WHERE t.taskgroup = ?1")
void deleteTaskHierarchyWhereTaskgroup(Taskgroup taskgroup);
@Modifying
@Transactional
@Query(value = "DELETE Task t WHERE t.parent = ?1")
void deleteTasksByParent(Task parentTask);
}

View File

@ -140,7 +140,7 @@ public class TaskSeriesService {
}
taskSerie.getTasks().clear();
taskSeriesRepository.delete(taskSerie);
} else {
} else if(task.getParent() == null){
repearIndexing(taskSerie, item.getSeriesIndex());
}
}

View File

@ -159,4 +159,9 @@ public class TaskService {
}
}
public ServiceExitCode clearSubTasks(Task parentTask) {
taskRepository.deleteTasksByParent(parentTask);
return ServiceExitCode.OK;
}
}

View File

@ -1349,7 +1349,38 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
delete:
security:
- API_TOKEN: []
tags:
- task
parameters:
- name: taskID
in: path
description: internal id of task
required: true
schema:
type: number
example: 1
responses:
200:
description: Operation successfull
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
403:
description: No permission
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
404:
description: Task not found
content:
application/json:
schema:
$ref: '#/components/schemas/SimpleStatusResponse'
/schedules: